Problem:
- ClockworkMod recovery (and others) use timestamps to identify and list backup sets in sequence. Unfortunately, many modern devices using SOC (system on chip) lack a battery backed system clock. The result is that the Linux time is set to sometime 1969ish on boot, and devices use network time to reset it once connected. However, recovery is not network connected. This results in backup sets timestamped out of sequence and makes them more difficult to track which is which.
Solutions:
Use ROM Manager to initiate backup sets.
- Is available today as a work around for Rom Manager supported devices
- Requires Rom Manager, which many prefer not to use
- Does not address the core problem with standalone recovery
Connect to the network and sync time
- No one is doing this that I know of
- Increases the complexity of making custom recovery considerably
Pass a token to recovery from Android and use it to set time on Linux boot
- On reboot to recovery, will be accurate within a minute or so
- On boot to recovery after extended shutdown will not be accurate, but will still allow timestamped backup set name to be in sequence. The long the time the phone is down before starting recovery, the older the time token is.
- This could be implemented via a root some Android app and a start up script in recovery (I don’t know of any yet).
- This can be implemented on any device with this issue with init.d jobs and a start up script in recovery (how to is here).
Passing a time token from Android to Recovery using initd:
Prerequisites:
- Working init.d on ROM
- Knowing how to build custom recovery or unpack, modify and repack a recovery image
Example of an init.d script on ROM:
#!/bin/sh
# 99timemachine attn1 01/2013
top() {
date -u +%Y.%m.%d-%T > /cache/timemachine
sleep 15
top
}
Addition of the following to /sbin/postrecoveryboot.sh
#!/bin/sh
# postrecoveryboot.sh script attn1 01/2013
if [ -f /cache/timemachine ]; then
ln -s /sbin/toolbox /tmp/busybox
read ntime < /cache/timemachine
/tmp/busybox date -s $ntime -u
rm -f /tmp/busybox
fi
Then rename a current version of busy box for your platform to toolbox and THEN place it in /sbin in recovery. Why? Busybox is built into ClockworkMod and does not support date -s function like good standalone binaries do.
One other note:
To get this working reliably, I had to mount /cache early in recovery boot, so I added a mount statement in init.rc:
from the top, init.rc might look like this:
import /init.recovery.${ro.hardware}.rc
on early-init
start ueventd
on emmc-fs
mount ext4 /dev/block/mmcblk0p16 /cache nosuid nodev barrier=1
Your mount statements will need to be correct for your device, of course.
If permissions are set correctly, this should work fine. This system is installed with the Burst Hack Kit for the Pantech Burst.