NO IMAGE

最近因為開發需要要更新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生成updater-scrip指令碼。所以修改ota_from_target_files會影響updater-script內容。

首先在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分割槽功能