1

a year ago a I had installed a custom recovery on my Lenovo S5000-F and it caused a bootloop and I lost the recovery, fastboot is working fine but it only allow me flash boot, system, userdata and cache partitions. I already tried do:

1-Unpack boot.img

2-Edit default.prop to allow adb debugging and then create a custom OTA update to install by adb sideload.

But when I boot the system I get device offline. So looking through system.img I found an interesting thing, a flash recovery script: install-recovery.sh

#!/system/bin/sh
  echo 1 > /sys/module/sec/parameters/recovery_done        #tony
if ! applypatch -c EMMC:recovery:6156288:b1d3582729e0f954b16931a7a87d4c09b6854396; then
  log -t recovery "Installing new recovery image"
  applypatch -b /system/etc/recovery-resource.dat EMMC:boot:5781504:94079a17dc0e061e417363e4d44d7d8d0e609f16 EMMC:recovery b1d3582729e0f954b16931a7a87d4c09b6854396 6156288 94079a17dc0e061e417363e4d44d7d8d0e609f16:/system/recovery-from-boot.p
  if applypatch -c EMMC:recovery:6156288:b1d3582729e0f954b16931a7a87d4c09b6854396; then        #tony
    echo 0 > /sys/module/sec/parameters/recovery_done        #tony
        log -t recovery "Install new recovery image completed"
  else
    echo 2 > /sys/module/sec/parameters/recovery_done        #tony
        log -t recovery "Install new recovery image not completed"
  fi
else
  echo 0 > /sys/module/sec/parameters/recovery_done              #tony
  log -t recovery "Recovery image already installed"
fi

This script means to replace any recovery installed by the user to the original one, but for some reason its not working.

So I would like to know if there is any way to flash a recovery partition through a script, so I can write this script to init.rc to install the stock recovery and fix bootloop.

  • what is the error message for 'fastboot flash recovery recovery.img'? how did you re-pack boot is it re-signed? /system/recovery-from-boot.p exist? – alecxs Nov 07 '21 at 17:06
  • when I try flash recovery it says "recovery partition does not support flash". I compiled this project to unpack and re-pack the boot.img (https://github.com/rom1nux/mtkimg) I'm not sure if its re-sign too, and yes there's a file recovery-from-boot.p on /system. – Carlos Henrique Nov 07 '21 at 21:01
  • of course you could modify content of install-recovery.sh but I guess device becomes unbootable once recovery partition was modified. Unlock bootloader, root with Magisk and flash recovery from official TWRP app – alecxs Nov 08 '21 at 07:53
  • you could also flash recovery from mtk-su or SP Flash Tool, but it might render device unbootable on locked bootloader – alecxs Nov 08 '21 at 19:56
  • Yeah I know this but the problem is I dont have the stock ROM with the scatter file and I didn't found the original ROM of my tablet, most I found is the chinese ROM and android version 4.2 but my device is 4.4.2 version, but I already unpacked this chinese rom and most files are broken and incomplete. – Carlos Henrique Nov 09 '21 at 10:41
  • carefully read last link, there is explained how one can create scatter file based on device and get stock ROM off device itself – alecxs Nov 09 '21 at 11:06
  • probably boot-loop is caused by something different (maybe emmc wear-out) because /system/recovery-from-boot.p should already have restored stock recovery automatically. try 'fastboot format:ext4 cache' that sometimes fixes boot-loop – alecxs Nov 09 '21 at 12:05
  • I know its possible create your own scatter file to flash only recovery, but I can't do this because uboot, boot, logo, recovery and others partitions are in the same file (mmcblk0) so I need to know the exact start address of recovery partition and its size to write the stock recovery in the right range. – Carlos Henrique Nov 09 '21 at 23:52
  • I was looking the applypatch source code to understand how its works, and I found when sha1 of boot doesn't match its return failure, thats why its not working because after 4.4.2 upgrade the size of boot image was modified so consequently sha1 of the file was modified too, I'll try to fix the script adding the right sha1 and size values. – Carlos Henrique Nov 09 '21 at 23:56
  • Oh sorry for not read your answer I though it could be a link to download SP Flash tool lol – Carlos Henrique Nov 10 '21 at 00:19
  • yes it doesn't make sense changes in sha checksum but the original boot.img size is 6MB not 5,7MB as its on script, sorry bad english – Carlos Henrique Nov 10 '21 at 00:22

0 Answers0