一般情况下进行OTA升级,是不会清除用户数据,如果想清除用户数据,制作升级包时添加–wipe_user_data参数。
制作清除用户数据的差分包
./out/soong/host/linux-x86/bin/ota_from_target_files --wipe_user_data -v --block -p out/host/linux-x86/ -i v1.zip v2.zip update.zip
制作清除用户数据的全包
1.先使用make otapackage编译出素材包,文件是\out\target\product\k61v1_32_bsp_2g_ago\obj\PACKAGING\target_files_intermediates\full_k61v1_32_bsp_2g_ago-target_files-mp1V15202.zip
这个也是用来制作差分包的文件
2.使用命令生成可清除用户数据的全包
./out/soong/host/linux-x86/bin/ota_from_target_files --wipe_user_data out/target/product/k61v1_32_bsp_2g_ago/obj/PACKAGING/target_files_intermediates/full_k61v1_32_bsp_2g_ago-target_files-mp1V15202.zip full.zip
如果编译失败报如下错误,修改ota_from_target_files.py脚本
xxxx@xxxx:~/work1/xxx/xxx$ ./out/soong/host/linux-x86/bin/ota_from_target_files --wipe_user_data out/target/product/k61v1_32_bsp_2g_ago/obj/PACKAGING/target_files_intermediates/full_k61v1_32_bsp_2g_ago-target_files-mp1V15202.zip full.zip
2024-07-15 17:07:27 - common.py - WARNING : Failed to read SYSTEM/etc/build.prop
2024-07-15 17:07:27 - common.py - WARNING : Failed to read VENDOR/etc/build.prop
2024-07-15 17:07:27 - common.py - WARNING : Failed to read SYSTEM_EXT/etc/build.prop
2024-07-15 17:07:27 - common.py - WARNING : Failed to read SYSTEM_EXT/build.prop
2024-07-15 17:07:27 - common.py - WARNING : Failed to read ODM/etc/build.prop
2024-07-15 17:07:27 - common.py - WARNING : Failed to read ODM/build.prop
2024-07-15 17:07:27 - common.py - WARNING : Failed to read VENDOR_DLKM/etc/build.prop
2024-07-15 17:07:27 - common.py - WARNING : Failed to read VENDOR_DLKM/build.prop
2024-07-15 17:07:27 - common.py - WARNING : Failed to read ODM_DLKM/etc/build.prop
2024-07-15 17:07:27 - common.py - WARNING : Failed to read ODM_DLKM/build.prop
2024-07-15 17:07:28 - common.py - WARNING : Can't find META/ab_partitions.txt
Traceback (most recent call last):
File "/home/software001/work1/MT6XXX-S/p301/out/soong/host/linux-x86/bin/ota_from_target_files/internal/stdlib/runpy.py", line 174, in _run_module_as_main
File "/home/software001/work1/MT6XXX-S/p301/out/soong/host/linux-x86/bin/ota_from_target_files/internal/stdlib/runpy.py", line 72, in _run_code
File "/home/software001/work1/MT6XXX-S/p301/out/soong/host/linux-x86/bin/ota_from_target_files/__main__.py", line 12, in <module>
File "/home/software001/work1/MT6XXX-S/p301/out/soong/host/linux-x86/bin/ota_from_target_files/internal/stdlib/runpy.py", line 174, in _run_module_as_main
File "/home/software001/work1/MT6XXX-S/p301/out/soong/host/linux-x86/bin/ota_from_target_files/internal/stdlib/runpy.py", line 72, in _run_code
File "/home/software001/work1/MT6XXX-S/p301/out/soong/host/linux-x86/bin/ota_from_target_files/ota_from_target_files.py", line 1500, in <module>
File "/home/software001/work1/MT6XXX-S/p301/out/soong/host/linux-x86/bin/ota_from_target_files/ota_from_target_files.py", line 1375, in main
ValueError: Cannot generate downgradable full OTAs
3.修改ota_from_target_files.py脚本
- build/tools/releasetools/ota_from_target_files.py
if OPTIONS.wipe_user_data:
if not OPTIONS.vabc_downgrade:
logger.info("Detected downgrade/datawipe OTA."
"When wiping userdata, VABC OTA makes the user "
"wait in recovery mode for merge to finish. Disable VABC by "
"default. If you really want to do VABC downgrade, pass "
"--vabc_downgrade")
OPTIONS.disable_vabc = True
# We should only allow downgrading incrementals (as opposed to full).
# Otherwise the device may go back from arbitrary build with this full
# OTA package.
- if OPTIONS.incremental_source is None:
- raise ValueError("Cannot generate downgradable full OTAs")
+ # if OPTIONS.incremental_source is None:
+ # raise ValueError("Cannot generate downgradable full OTAs")
最好使用vim去修改