How to update the recovery.img in android

Document created by Sanshan Zhang Employee on Oct 30, 2014
Version 1Show Document
  • View in full screen mode

In recovery mode, recovery may update /boot or /system, but it never overwrite itself. The update of /recovery is in the normal bootup. When system boot up, it will execute init.rc which will call install-recovery.sh.

 

The install-recovery.sh is in update.zip. when the system is in recovery mode, updater-script will  unzip update.zip, and the install-recovery.sh will be unzip into /system/etc/. So if you update your image through recovery mode, the install-recovery.sh will be unzip to /system/etc/ automatically.

 

If your update.zip do not include install-recovery.sh. You can edit it and copy it to /system/etc. the below is content in install-recovery.sh.

 

#!/system/bin/sh

if ! applypatch -c EMMC:/dev/block/mmcblk3p2:7762488:374c3807940a38d9497a4c5ef64a069e553bc218; then

  log -t recovery "Installing new recovery image"

  applypatch -b EMMC:/dev/block/mmcblk3p1:7203059:238a297e7e3c7197b2f5af646d0e7e49cef0fd9f EMMC:/dev/block/mmcblk3p2  374c3807940a38d9497a4c5ef64a069e553bc218 7762488 c3c9482c8616805ea4c071ee9184240936f260e5:/system/recovery-from-boot.p

else

  log -t recovery "Recovery image already installed"

fi

 

Explain of the install-recovery.sh:

1、 judge whether the recovery-imx6q.img’s sha1 is the same with mmcblk3p2 on board.

374c3807940a38d9497a4c5ef64a069e553bc218 is the new recovery-imx6q.img’s sha1. 7762488 is the length of recovery-imx6q.img.

2、 if not the same , that mean it was a new recovery-imx6q.img. make a new recovery-imx6q.img through patch recovery-from-boot.p on boot.img.

7203059 and 238a297e7e3c7197b2f5af646d0e7e49cef0fd9f is the length and sha1 of boot.img.     src-file

EMMC:/dev/block/mmcblk3p2 is the recovery partition.      tgt-file

c3c9482c8616805ea4c071ee9184240936f260e5 is the sha1 of recovery-from-boot.p which is in update.zip.

Note:

1、 recovery-from-boot.p is in update.zip. And it is unzip into /system. It is the patch of boot-imx6q.img and recovery-imx6q.img.

2、 for EMMC:/dev/block/mmcblk3p2 is the partition, you can check ./out/target/product/sabresd_6dq/recovery/root/etc/recovery.fstab to see detail partition.

 

Check whether recovery is updated, there are two ways to check:

1、 you can write printf() in file bootable/recovery/recovery.cpp. On the board you can check the file /cache/recovery/last_log. You can find what you printf if the recovery.img was updated.

2、 Also you can use the adb the pull the recovery file system to check whether the recovery was updated.

2 people found this helpful

Attachments

    Outcomes