Hi,

Please see if I am interpreting your message correctly:

When you select "Reset Factory Defaults" (or similar text... not sure) your 
device reboots, but data are not reset.

First please answer these questions: Does your device has recovery? When 
executing `reboot recovery` does your device reboot into recovery 
automatically?

If the answers are "no" then your device would probably NOT handle factory 
reset properly.

According to `bootable/recovery/recovery.c`, recovery handles wiping 
`userdata` and `cache` partitions:

 * FACTORY RESET * 1. user selects "factory reset" * 2. main system writes 
"--wipe_data" to /cache/recovery/command * 3. main system reboots into recovery 
* 4. get_args() writes BCB with "boot-recovery" and "--wipe_data" *    -- after 
this, rebooting will restart the erase -- * 5. erase_volume() reformats /data * 
6. erase_volume() reformats /cache * 7. finish_recovery() erases BCB *    -- 
after this, rebooting will restart the main system -- * 8. main() calls 
reboot() to boot main system


So to *actually* perform the factory reset operation the system needs to 
enter recovery.

You may ask, how does the bootloader know that the system needs to enter 
recovery? A stackoverflow.com 
question<http://stackoverflow.com/questions/5472761/how-does-the-bootloader-pick-up-the-command-after-a-restarting-system-with-comm>explained
 that. Most probably there isn't any implementations that will 
keep the command so you may need to implement it yourself. *But I am not 
sure.* This is how I actually implemented it in the 
kernel<https://sourceforge.net/p/ipaq214android/kernel/ci/32364be1e8b81953f17aeb99394ceed18c551bec/tree/arch/arm/mach-pxa/hpipaq214.c?diff=0734ae264bd656b7b78f1142ec6f076ccf0c3170>,
 
and in 
U-Boot<https://sourceforge.net/p/ipaq214android/u-boot/ci/fd8fece399eb48f9d4bce96fb1ba1a9b0f7dba8d/tree/board/ipaq214/ipaq214.c?diff=c5cd74816709aaad9454cffa8349186d0ffa8d37>.
 
The kernel sets a register to a magic number and when U-Boot sees the magic 
number, it will reboot to recovery. Of course I need to clear the register 
after that or else the device will boot into recovery infinitely!

Of course it can *differs in a high degree* for different boards. For 
example if your implementation doesn't clear SRAM or whatever in a soft 
reset, you can simply write the command into that portion, but for my 
implementation I need to write a magic number to a register that can 
survive in a reboot.

If unluckily I've misunderstood your message then simply ignore my message. 
Hope it helps. :)

Regards,
Alvin Wong

Bill Zhong於 2012年9月23日星期日UTC+8下午10時13分03秒寫道:
>
> Hi all,
>
> I will to how to save changing to factory default setting. How to save 
> changing when user reset factory setting?
>
> Thanks 
> Bill
>

>

-- 
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting

Reply via email to