关于recovery更新相关的几点总结记录:
1、recovery升级的大致流程:
①编译:执行make otapackage
②.main system模式下,将升级包重名为update.zip,下载到/cache目录下
③.创建文件/cache/recovery/command,并向command中写入:--update_package=/cache/update.zip
④终端执行reboot recovery进入recovery模式,也可以通过android上层调用函数android_reboot,并设置进入recovery模式的代码
⑤.系统重启,进入recovery模式,并启动recovery进程,该进程会检测/cache/recovery/command的内容,然后升级update.zip。
2、命令文件/cache/recovery/command:保存着Main
system传给Recovery的命令行,每一行就是一条命令,支持一下几种的组合。
--send_intent=anystring
//write the text out to recovery/intent
//在Recovery结束时在finish_recovery函数中将定义的intent字符串作为参数传进来,并写入到/cache/recovery/intent中
--update_package=root:path
//verify install an OTA package file Main system将这条命令写入时,代表系统需要升级,在进入Recovery模式后,
//将该文件中的命令读取并写入BCB中,然后进行相应的更新update.zip包的操作。
--wipe_data
//erase user data(and cache),then reboot。擦除用户数据。擦除data分区时必须要擦除cache分区。
--wipe_cache //wipe
cache(but not user data),then reboot。擦除cache分区。
3、recovery时分区相关需要与system主模式的分区号一致
位置:bootable/bootloader/uboot-imx/include/autoconf.mk
CONFIG_ANDROID_CACHE_PARTITION_MMC=12
CONFIG_ANDROID_RECOVERY_PARTITION_MMC=6
CONFIG_ANDROID_SYSTEM_PARTITION_MMC=5
CONFIG_ANDROID_RECOVERY_CMD_FILE="/recovery/command"
4、bootable/recovery/recovery.c修改
#LOCAL_MODULE_TAGS := eng
如果放开这行,将只会在eng版本软件中有copy到/system/bin的动作
5、build/core/Makefile修改
$(INTERNAL_OTA_PACKAGE_TARGET):
$(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
@echo "Package OTA: $@"
$(hide) ./build/tools/releasetools/ota_from_target_files -v \
-p $(HOST_OUT) \
-k $(KEY_CERT_PAIR) \
-n \
-w \
-n在升级时是否不检查时间戳,缺省要检查,即缺省情况下只能基于旧版本升级
-w是否清除userdata分区
注:如果/cache/recovery/last_log中出现如下错误则说明升级包较旧导致终止执行,可以加上上面说的-n项
assert failed: !less_than_int(1397801920,
getprop("ro.build.date.utc"))
6、recovery的log文件放在/cache/recovery/
last_install
last_locale:上次recovery使用的语言,如在更新时界面显示的提示语的语种,英语、日语等
last_log:log
7、检测命令文件/cache/recovery/command函数是int check_recovery_cmd_file(void)在如下文件中定义
"bootable/bootloader/uboot-imx/board/freescale/mx6q_sabresd/mx6q_sabresd.c"
8、recovery升级最终是通过执行updater-script脚本来进行的。下面是部分注释供参考。
-
assert(getprop("ro.product.device") == "sabresd_6dq" ||
-
getprop("ro.build.product") == "sabresd_6dq");
-
//show_progress(frac,sec):frac表示进度完成的数值,sec表示整个过程的总秒数。主要用与显示UI上的进度条。
-
show_progress(0.500000, 0);
-
//format(fs_type,partition_type,location):fs_type,文件系统类型,取值一般为“yaffs2”或“ext4”。Partition_type,分区类型,一般取值为“MTD”或则“EMMC”。主要用于格式化为指定的文件系统。
-
format("ext4", "EMMC", "/dev/block/mmcblk0p5", "0", "/system");
-
//挂在一个文件系统/system到指定挂载点mmcblk0p5
-
mount("ext4", "EMMC", "/dev/block/mmcblk0p5", "/system");
-
//package_extract_dir(src_path,destination_path):src_path,要提取的目录,destination_path目标目录。作用:从升级包内,提取目录到指定的位置。
-
package_extract_dir("recovery", "/system");//提取recovery
-
package_extract_dir("system", "/system");//提取system
-
//创建符号链接
-
symlink("Roboto-Bold.ttf", "/system/fonts/DroidSans-Bold.ttf");
-
symlink("Roboto-Regular.ttf", "/system/fonts/DroidSans.ttf");
-
symlink("mksh", "/system/bin/sh");
-
symlink("toolbox", "/system/bin/cat", "/system/bin/chmod",
-
"/system/bin/chown", "/system/bin/cmp", "/system/bin/cp",
-
"/system/bin/date", "/system/bin/dd", "/system/bin/df",
-
"/system/bin/dmesg", "/system/bin/du", "/system/bin/getevent",
-
"/system/bin/getprop", "/system/bin/grep", "/system/bin/hd",
-
"/system/bin/id", "/system/bin/ifconfig", "/system/bin/iftop",
-
"/system/bin/insmod", "/system/bin/ioctl", "/system/bin/ionice",
-
"/system/bin/kill", "/system/bin/ln", "/system/bin/log",
-
"/system/bin/ls", "/system/bin/lsmod", "/system/bin/lsof",
-
"/system/bin/md5", "/system/bin/mkdir", "/system/bin/mount",
-
"/system/bin/mv", "/system/bin/nandread", "/system/bin/netstat",
-
"/system/bin/newfs_msdos", "/system/bin/notify", "/system/bin/printenv",
-
"/system/bin/ps", "/system/bin/reboot", "/system/bin/renice",
-
"/system/bin/rm", "/system/bin/rmdir", "/system/bin/rmmod",
-
"/system/bin/route", "/system/bin/schedtop", "/system/bin/sendevent",
-
"/system/bin/setconsole", "/system/bin/setprop", "/system/bin/sleep",
-
"/system/bin/smd", "/system/bin/start", "/system/bin/stop",
-
"/system/bin/sync", "/system/bin/top", "/system/bin/touch",
-
"/system/bin/umount", "/system/bin/uptime", "/system/bin/vmstat",
-
"/system/bin/watchprops",
-
"/system/bin/wipe");
-
//设置文件或目录权限
-
set_perm_recursive(0, 0, 0755, 0644, "/system");
-
set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");
-
set_perm(0, 3003, 02750, "/system/bin/netcfg");
-
set_perm(0, 3004, 02755, "/system/bin/ping");
-
set_perm(0, 2000, 06750, "/system/bin/run-as");
-
set_perm(1002, 1002, 0440, "/system/etc/dbus.conf");
-
set_perm(1014, 2000, 0550, "/system/etc/dhcpcd/dhcpcd-run-hooks");
-
set_perm(0, 2000, 0550, "/system/etc/init.goldfish.sh");
-
set_perm(0, 0, 0544, "/system/etc/install-recovery.sh");
-
set_perm_recursive(0, 0, 0755, 0555, "/system/etc/ppp");
-
set_perm_recursive(0, 2000, 0755, 0644, "/system/vendor");
-
set_perm(0, 0, 0644, "/system/vendor/etc/audio_effects.conf");
-
set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");
-
show_progress(0.200000, 0);
-
show_progress(0.200000, 10);
-
//将升级包中的boot.img文件写入到/dev/block/mmcblk0p1
-
package_extract_file("boot.img", "/dev/block/mmcblk0p1");
-
show_progress(0.100000, 0);
-
unmount("/system");
9、updater-script脚本是从python脚本build/tools/releasetools/ota_from_target_files中生成的。
10、更新时的图片显示是在/android4.2-imx6/bootable/recovery/res/images下面
11、Android recovery模式时界面显示的文字是从png文本图片中读取的。目录也是在/android4.2-imx6/bootable/recovery/res/images
如果要显示文字是需要从上层传递locale变量的。如果没有设置或者不知如何设置(我就不知),可以直接修改bootable/recovery/recovery.cpp文件中locale 定义时赋予初始值,如下表示英语_英国
char* locale = "en_GB"
阅读(16206) | 评论(0) | 转发(1) |