Recovery介绍

Recovery介绍

Recovery相关源码路径/bootloader/recovery
编辑此区域
进入RecoveryMode的两种方式

开机过程中按下RecoveryKey键(一般为POWER和VOLUME+组合键)
系统指定进入RecoveryMode(如系统要求进入还原模式;OTA升级) # 与主系统通信 Recovery是一个独立的小系统,它与主系统通过/cache目录通信
/cache/recovery/command - INPUT - command line for tool, one arg per line
/cache/recovery/log - OUTPUT - combined log file from recovery run(s)

编辑此区域
支持的Command如下

The arguments which may be supplied in the recovery.command file:
--update_package=path - verify install an OTA package file
--wipe_data - erase user data (and cache), then reboot
--prompt_and_wipe_data - prompt the user that data is corrupt, with their consent erase user
data (and cache), then reboot
--wipe_cache - wipe cache (but not user data), then reboot
--show_text - show the recovery text menu, used by some bootloader (e.g. http://b/36872519).
--set_encrypted_filesystem=on|off - enables / diasables encrypted fs
--just_exit - do nothing; exit and reboot

编辑此区域
Recovery的两大功能,FactoryReset和OTA Install
编辑此区域
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

BCB:bootloader control block.是专门用于recovery和bootloader互相通信的一个flash块。存放在misc分区中

struct bootloader_message {
char command[32];
char status[32];
char recovery[768];

// The 'recovery' field used to be 1024 bytes.  It has only ever
// been used to store the recovery command line, so 768 bytes
// should be plenty.  We carve off the last 256 bytes to store the
// stage string (for multistage packages) and possible future
// expansion.
char stage[32];

// The 'reserved' field used to be 224 bytes when it was initially
// carved off from the 1024-byte recovery field. Bump it up to
// 1184-byte so that the entire bootloader_message struct rounds up
// to 2048-byte.
char reserved[1184];

};

编辑此区域
OTA INSTALL

1. main system downloads OTA package to /cache/some-filename.zip
2. main system writes "--update_package=/cache/some-filename.zip"
3. main system reboots into recovery
4. get_args() writes BCB with "boot-recovery" and "--update_package=..."
-- after this, rebooting will attempt to reinstall the update --
5. install_package() attempts to install the update
NOTE: the package install must itself be restartable from any point
6. finish_recovery() erases BCB
-- after this, rebooting will (try to) restart the main system --
7. ** if install failed ** 7a. prompt_and_wait() shows an error icon and waits for the user 7b. the user reboots (pulling the battery, etc) into the main system
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FW_G8Z

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值