Saturday, September 21, 2013

upgrade_check.sh in Tolino Shine

#!/system/bin/b    ash -x
i=0
rm /data/no_sd_upgrade

upgrade_check(){
sleep 6
if [ -e /mnt/sdcard/extsd/update.zip ] ; then
        echo "---> recovery mode setting ---------------------------------------"
        rm /cache/downloadfile*
        sync
        sync
        if [ -e /mnt/sdcard/extsd/update_mark ] ; then
#                mv /mnt/sdcard/extsd/update.zip /mnt/sdcard/extsd/update.zip_old
                rm /mnt/sdcard/extsd/update.zip
                rm /mnt/sdcard/extsd/update_mark
                upgrade_check
#        else
#                mkdir /cache/recovery
#                echo '--update_package=/sdcard/update.zip' > /cache/recovery/command
#                am start -n com.ntx.msg/.MsgUpgradeActivity
#                sync
#                sync
#                sleep 10
#                sync
#                sync
#                reboot

        fi
elif [ -e /mnt/sdcard/extsd/waveform.bin ]; then
        echo "---> Programming waveform ----------------------------------------"
        busybox dd if=/mnt/sdcard/extsd/waveform.bin of=/dev/mmcblk0 bs=512 seek=14336
        sync
        sync
        mv /mnt/sdcard/extsd/waveform.bin /mnt/sdcard/extsd/waveform.bin_old
        sync
        sync
        am start -n com.ntx.msg/.MsgWaveformActivity
        sync
        sync
# xiaobo begin of adb_open
# elif [ -e /mnt/sdcard/extsd/adb_open ]; then
#        setprop persist.service.adb.enable 1
#        sync
#        sync
# elif [ -e /mnt/sdcard/extsd/adb_close ]; then
#        setprop persist.service.adb.enable 0
#        sync
#        sync
# xiaobo end of adb open
elif [ -e /mnt/sdcard/extsd/recovery.img ] || [ -e /cache/upgrade/recovery.img ]; then
        echo "---> Programming partition RECOVERY ----------------------------------"
        busybox dd if=/mnt/sdcard/extsd/recovery.img of=/dev/block/mmcblk0p4 bs=8M
        busybox dd if=/cache/upgrade/recovery.img of=/dev/block/mmcblk0p4 bs=8M
        sync
        sync
        e2fsck -dy /dev/block/mmcblk0p4
        sync
        sync
        mv /mnt/sdcard/extsd/recovery.img /mnt/sdcard/extsd/recovery.img_old
        rm /cache/upgrade/recovery.img
        sync
        sync
        am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN
elif [ -e /mnt/sdcard/show_info ] || [ -e /mnt/sdcard/extsd/show_info ]; then
        echo "---> Programming show info. ----------------------------------"
        sync
        sync
        am start -n com.ntx.msg/.MsgShowInfoActivity
        sync
        sync
else
        if [ "$i" -le 5 ]; then
            i=$((i + 1))
            upgrade_check
        else
            busybox touch /data/no_sd_upgrade
        fi
fi
}

upgrade_check


Recovering rooted and bricked Tolino Shine reader via ADB

[Draft]

Having rooted your Tolino Shine (a post to be written), you have been using it for a while. As the days passed by and the Internal Storage was bursting at its seams from the installed apps, you may have noticed that your new ereader has become sluggish.
What is worse, some autostart system applications (Button Savior, Floating Toolbar) fail to start on their own. Have you remembered about  checking the external and internal drives for errors and defragging them? No? Give them a try.

Despite these measures, one day Tolino may just die on you. There will be not even the creeping boxes boot animation - only the initial Tolino leaf will show. Of course you won't have a nandroid backup to speak of, either.

What did not work for me:
  • fastboot
  • flashing recovery.img with tools or manually
  • toying with init.rc or /system files

That is what helped me instead:

  • Make sure you have the right ADB driver files (e.g. Xiaomi), see How I rooted my Tolino post (to be written). 
  • Check if you can see Tolino in the Device Manager as Google ADB, not Tolino
  • Find the newest ADB.EXE package or download it off the Net.
  • Connect a hung Tolino via a good micro USB cable. Try different USB ports.
  • Check if Tolino has been discovered by the desktop computer. In the Windows command line run 
ADB devices
  • If you see the identification number of the connected Tolino device (e.g. "00096e7549872f  device"), run
ADB logcat
to see the booting process. Most probably you will see a boot loop: a service refuses to start and the panic daemon keeps restarting it. Run
ADB shell
  • If you are lucky, you should see #, which means you are running it as a root. Run
ps
  • to list the processes. Try to find the PID of the service monitor, to kill it, e.g.:
Kill 2683

- that way, the booting loop should stop and you will have more processor power. You will need it, trust me.
  • Run the QtADB front end and see if you can browse the root file system.
  • Remount /system  as read and write:
busybox mount -o remount,rw /system
  • Run
busybox mount /dev/block/mmcblk0p1 /sdcard
  • to mount the SD card. (You may experiment with mounting the other images, e.g. busybox mount /dev/block/mmcblk0p4  /mnt/obb/, just to try)
  • Copy one of the original Tolino update.zip files, select any from this forum, to the root directory of the internal sdcard (yes)
  • Find and analyze the /system/bin/upgrade_check.sh script on your Tolino, the bolded part, see also Naberius' post. We will use a trick from there.
  • On your computer, create a file named just command with the following content:
--update_package=/sdcard/update.zip

  • Copy this command file to the /cache/recovery directory with QtADB, so that you get /cache/recovery/command
  • You may need to change its permissions: chmod 777 command, just in case.
  • Run this command, taken from the script:
am start -n com.ntx.msg/.MsgUpgradeActivity
  • Run:
Reboot
in the shell, or press and hold the Power button to do it manually. 

If you are lucky, you will see the Recovery/Update screen. If you are very lucky, the update process will accept the update.zip file and you will have your /system and init files fixed.  Proceed to root your Tolino. See my "Root your Tolino" post (in the making) with more details.