最近因为开发需要要更新amlogic的recovery分区。普通的设置时不更跟新recovery分区。只更新boot分区和system分区。
通过查资料和对比m3添加了更新recovery分区方法。普通的update.zip升级包不更新recovery分区。
下面是普通不带更新recovery的updater-script的脚本部分:
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/recognition/face.face.y0-y0-22-b-N/full_model.bin"); set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin"); unmount("/system"); show_progress(0.200000, 5); write_raw_image(package_extract_file("boot.img"), "boot"); write_raw_image(package_extract_file("bootloader.img"), "bootloader"); set_bootloader_env("upgrade_step", "3"); show_progress(0.100000, 0);
首先在ota_from_target_files
OPTIONS.extra_script = None OPTIONS.aslr_mode = True OPTIONS.worker_threads = 3 boot_img_exists = 0 recovery_img_exists = 1 def MostPopularKey(d, default): """Given a dict, return the key corresponding to the largest value. Returns 'default' if the dict is empty.""" x = [(v, k) for (k, v) in d.iteritems()] if not x: return default x.sort() return x[-1][1]添加
recovery_img_exists = 1
这句话意思若存在 recovery.img就就更新新recovery分区
然后在
script.UnmountAll() if recovery_img_exists: common.CheckSize(recovery_img.data, "recovery.img", OPTIONS.info_dict) common.ZipWriteStr(output_zip, "recovery.img", recovery_img.data) script.WriteRawImage("/recovery", "recovery.img") 因为上面以定义recovery_img_exists =1 所以这段话被执行,script.WriteRawImage("/recovery", "recovery.img")是向recovery分区写recovery.img
if boot_img_exists: common.CheckSize(boot_img.data, "boot.img", OPTIONS.info_dict) common.ZipWriteStr(output_zip, "boot.img", boot_img.data) #script.ShowProgress(0.2, 0) script.ShowProgress(0.2, 5) script.WriteRawImage("/boot", "boot.img") if bootloader_img_exist: common.CheckSize(bootloader_img.data, "bootloader.img", OPTIONS.info_dict) common.ZipWriteStr(output_zip, "bootloader.img", bootloader_img.data) script.WriteRawImage("/bootloader", "bootloader.img") script.SetBootloaderEnv("upgrade_step", "3") else: script.SetBootloaderEnv("upgrade_step", "2") if spi_img_exist: script.FormatPartition("/ubootwhole") common.CheckSize(spi_img.data, "ubootwhole.img", OPTIONS.info_dict) common.ZipWriteStr(output_zip, "ubootwhole.img", spi_img.data) #script.ShowProgress(0.1, 0) #script.ShowProgress(0.1, 10) script.WriteRawImage("/ubootwhole", "ubootwhole.img")
然后添加以上粗线部分;修改后make otapackage生成zip包解压发现updater-script带有写入新recovery功能,就是下面黑体部分
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.6/head-y0-yi45-p0-pi45-rn30-ri30.5-v24/full_model.bin"); set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.6/head-y0-yi45-p0-pi45-rp30-ri30.5-v24/full_model.bin"); set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/recognition/face.face.y0-y0-22-b-N/full_model.bin"); set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin"); unmount("/system"); write_raw_image(package_extract_file("recovery.img"), "recovery"); show_progress(0.200000, 5); write_raw_image(package_extract_file("boot.img"), "boot"); write_raw_image(package_extract_file("bootloader.img"), "bootloader"); set_bootloader_env("upgrade_step", "3"); show_progress(0.100000, 0);
记得修改ota_from_target_files的权限,chmod 777 ota_from_target_files
不然编译有可permission错误。
编译出来update.zip即可有刷recovery分区功能