添加更新amlogic的recovery分区的代码

最近因为开发需要要更新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分区功能







评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

九霄的爸爸

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

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

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

打赏作者

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

抵扣说明:

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

余额充值