int check_recovery_cmd_file(void)
{
.
.
.
switch (get_boot_device()) {
case MMC_BOOT:
case SD_BOOT:
{
for (i = 0; i < 2; i++) {
block_dev_desc_t *dev_desc = NULL;
struct mmc *mmc = find_mmc_device(i);
dev_desc = get_dev("mmc", i);
if (NULL == dev_desc) {
printf("** Block device MMC %d not supported\n", i);
continue;
}
mmc_init(mmc);
if (get_partition_info(dev_desc, CONFIG_ANDROID_CACHE_PARTITION_MMC,
&info)) {
printf("** Bad partition %d **\n",CONFIG_ANDROID_CACHE_PARTITION_MMC);
continue;
}
part_length = ext2fs_set_blk_dev(dev_desc, CONFIG_ANDROID_CACHE_PARTITION_MMC);
if (part_length == 0) {
printf("** Bad partition - mmc %d:%d **\n", i, CONFIG_ANDROID_CACHE_PARTITION_MMC);
ext2fs_close();
continue;
}
if (!ext2fs_mount(part_length)) {
printf("** Bad ext2 partition or "
"disk - mmc %d:%d **\n",
i, CONFIG_ANDROID_CACHE_PARTITION_MMC);
ext2fs_close();
continue;
}
filelen = ext2fs_open(CONFIG_ANDROID_RECOVERY_CMD_FILE);
ext2fs_close();
break;
}
}
break;
.
.
.
}
主要来看看下面这个ext2fs_open所打开的内容,CONFIG_ANDROID_RECOVERY_CMD_FILE,这个正是上面所提
到的rocovery cmd file的宏定义,内容如下:
#define CONFIG_ANDROID_RECOVERY_CMD_FILE "/recovery/command"S
当检测到有这个文件存在时,将会进入到setup_recovery_env这个函数中,其相应的代码如下:
void setup_recovery_env(void)
{
char *env, *boot_args, *boot_cmd;
int bootdev = get_boot_device();
boot_cmd = supported_reco_envs[bootdev].cmd;
boot_args = supported_reco_envs[bootdev].args;
if (boot_cmd == NULL) {
printf("Unsupported bootup device for recovery\n");
return;
}
printf("setup env for recovery..\n");
env = getenv("bootargs_android_recovery");
/* Set env to recovery mode */
/* Only set recovery env when these env not exist, give user a
* chance to change their recovery env */
if (!env)
setenv("bootargs_android_recovery", boot_args);
env = getenv("bootcmd_android_recovery");
if (!env)
setenv("bootcmd_android_recovery", boot_cmd);
setenv("bootcmd", "run bootcmd_android_recovery");
}
在这里主要是将bootcmd_android_recovery这个环境变量加到uboot启动的environment中,这样当系统启动加载完
评论5
最新资源