您的位置:首页 > 移动开发 > Android开发

安卓OTA升级文件的制作

2015-09-21 15:09 627 查看

OTA刷机包制作

整个项目编译完成后再执行make otapackage

生成的完整升级包会存放在out\debug\target\product[project name]\ 下

具体名字根据make otapackage的install来确定

生成的过程文件包在out/target/product/ardbeg/obj/PACKAGING/target_files_intermediates/目录下,该文件可用于创建差分升级包

OTA包解压后META-INF\com\google\android目录下有两个文件

update-binary是一个二进制文件,相当于一个脚本解释器,能够识别updater-script中描述的操作。该文件在Android源码编译后out/target/product/streambox/system bin/updater生成,可将updater重命名为update-binary得到。

该文件在具体的更新包中的名字由源码中bootable/recovery/install.c中的宏ASSUMED_UPDATE_BINARY_NAME的值而定。

updater-script:此文件是一个脚本文件,具体描述了更新过程。我们可以根据具体情况编写该脚本来适应我们的具体需求。该文件的命名由源码中bootable/recovery/updater/updater.c文件中的宏SCRIPT_NAME的值而定。

升级时的进度条,升级哪些文件都是这个脚本里指定的。updater-script是由alps/build/tools/releasetools/edify_generator.py生成的,后续会介绍如何生成updater-script脚本

updater-script中使用的命令都需要在alps/bootable/recovery/updater/install.c中注册,如下所示:

void RegisterInstallFunctions() {
RegisterFunction("mount", MountFn);
RegisterFunction("is_mounted", IsMountedFn);
RegisterFunction("unmount", UnmountFn);
RegisterFunction("format", FormatFn);
RegisterFunction("show_progress", ShowProgressFn);
RegisterFunction("set_progress", SetProgressFn);
RegisterFunction("delete", DeleteFn);
RegisterFunction("delete_recursive", DeleteFn);
RegisterFunction("package_extract_dir", PackageExtractDirFn);
RegisterFunction("package_extract_file", PackageExtractFileFn);
RegisterFunction("symlink", SymlinkFn);

// Maybe, at some future point, we can delete these functions? They have been
// replaced by perm_set and perm_set_recursive.
RegisterFunction("set_perm", SetPermFn);
RegisterFunction("set_perm_recursive", SetPermFn);

// Usage:
//   set_metadata("filename", "key1", "value1", "key2", "value2", ...)
// Example:
//   set_metadata("/system/bin/netcfg", "uid", 0, "gid", 3003, "mode", 02750, "selabel", "u:object_r:system_file:s0", "capabilities", 0x0);
RegisterFunction("set_metadata", SetMetadataFn);

// Usage:
//   set_metadata_recursive("dirname", "key1", "value1", "key2", "value2", ...)
// Example:
//   set_metadata_recursive("/system", "uid", 0, "gid", 0, "fmode", 0644, "dmode", 0755, "selabel", "u:object_r:system_file:s0", "capabilities", 0x0);
RegisterFunction("set_metadata_recursive", SetMetadataFn);

RegisterFunction("getprop", GetPropFn);
RegisterFunction("file_getprop", FileGetPropFn);
RegisterFunction("write_raw_image", WriteRawImageFn);

RegisterFunction("apply_patch", ApplyPatchFn);
RegisterFunction("apply_patch_check", ApplyPatchCheckFn);
RegisterFunction("apply_patch_space", ApplyPatchSpaceFn);

RegisterFunction("read_file", ReadFileFn);
RegisterFunction("sha1_check", Sha1CheckFn);
RegisterFunction("rename", RenameFn);

RegisterFunction("wipe_cache", WipeCacheFn);

#if 1 //wschen 2012-07-25
RegisterFunction("special_factory_reset", SpecialFactoryResetFn);
#endif

RegisterFunction("ui_print", UIPrintFn);

RegisterFunction("run_program", RunProgramFn);

#ifdef MTK_SYS_FW_UPGRADE
RegisterFunction("retouch_binaries_ext", RetouchBinariesFnExt);
RegisterFunction("undo_retouch_binaries_ext", UndoRetouchBinariesFnExt);
RegisterFunction("apply_data_app", ApplyDataAppsFn);
#endif
}


注册后的命令才能在升级脚本中直接使用。

差分升级包制作

针对MTK平台,其他平台也应该类似

对于采用差分包进行升级,步骤如下:

- ./mk [project] new— 工程的版本是 V2

- ./mk [project] otapackage — 工程的版本是 V2

- 将v2版本download到对应的手机上

- 拷贝out/target/product/{project}/obj/packaging/ckt75_cu_gb2-

target_files-eng.ckt.zip到根目录下,

并改名为 v2_org —–工程的版本是 V2

- ./mk [project] new — 工程的版本是 V3

- ./mk [project] otapackage — 工程的版本是 V3

- 拷贝out/target/product/{project}/obj/packaging/ckt75_cu_gb2-

target_files-eng.ckt.zip到根目录下,

并改名为 v3_org —–工程的版本是 V3

- ./build/tools/releasetools/ota_from_target_files -i v2_org.zip

v3_org.zip v2_3.zip—在alps 目录下执行此命令

- copy 差分包v2_3.zip到SDcard,手动开机到recovery mode,进行升级。

差分包升级时签章问题

download版本的key与制作差分包时使用的key不一致的话,会导致在recovery mode升级时验证

通不过。

解决:先确定在ProjectConfig.mk文件中的宏:MTK_SIGNATURE_CUSTOMIZATION设置,

如果设置为yes, 客户需要自己去gen releasekey,生成key的文档参考DMS如下路径的资料:

/Product Line/WCX/3G Phone Data/Smart Phone/Software_Customer/Standard Package/MT6575

SW Doc Package/Build/V2.3 /Application Signing Process Enhancement.ppt ,

产生releasekey之后(releasekey在:alps/build/target/product/security/project下),

Build第一个版本,build A new, build A otapackage, 将A版download到手机上,再build第二版

,build B new, build Botapackage。最后用命令

./build/tools/releasetools/ota_from_target_files –k

alps/build/target/product/security/project/release –n –i oldotapackage.zip

newotapackage.zip update.zip.

如果宏MTK_SIGNATURE_CUSTOMIZATION设置为no,则不需要产生key,使用默认的

alps/build/target/product/security下的testkey。这时在build 完A、B两个版本后直接用命令:

./build/tools/releasetools/ota_from_target_files –n –i oldotapackage.zip

newotapackage.zip update.zip.来制作差分包
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android ota