高通Android13本地Recovery差分升级失败报错kInstallDeviceOpenError (7)原因分析

编译版本差分包出来验证差分升级过程中发现有时候能成功升级有时候不能。

现象描述:adb reboot recovery,选择Apply update from ADB。 然后输入命令adb reboot sideload ./OTApackage.zip进行本地差分升级。升级过程中升级失败并且提示如下信息:

问题分析:更换debug版本固件,重复上述操作步骤,看到升级失败提示后提取recovery.log出来分析。

js 复制代码
adb pull /tmp/recovery.log

把升级失败的日志和成功的日志进行对比发现存在如下区别:

js 复制代码
    成功部分日志
[   28.880965] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3447] Successfully created snapshot partition for odm_b
[   28.885833] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3447] Successfully created snapshot partition for product_b
[   28.904324] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3447] Successfully created snapshot partition for system_b
[   28.904664] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3447] Successfully created snapshot partition for system_dlkm_b
[   28.906182] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3447] Successfully created snapshot partition for system_ext_b
[   28.909221] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3447] Successfully created snapshot partition for vendor_b
[   28.909635] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3447] Successfully created snapshot partition for vendor_dlkm_b
[   28.909711] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3459] Successfully created snapshot for odm_b
[   28.909750] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3459] Successfully created snapshot for product_b
[   28.909788] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3459] Successfully created snapshot for system_b
[   28.909826] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3459] Successfully created snapshot for system_dlkm_b
[   28.909862] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3459] Successfully created snapshot for system_ext_b
[   28.909900] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3459] Successfully created snapshot for vendor_b
[   28.909937] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3459] Successfully created snapshot for vendor_dlkm_b
[   29.161509] update_engine_sideload I 01-01 02:40:52   445   445 snapshot.cpp:3314] Successfully created all snapshots for target slot _b
js 复制代码
    失败部分日志
[    6.701408] update_engine_sideload I 01-06 03:09:12   405   405 snapshot.cpp:3447] Successfully created snapshot partition for odm_b
[    6.706411] update_engine_sideload I 01-06 03:09:12   405   405 snapshot.cpp:3447] Successfully created snapshot partition for product_b
[    6.786439] update_engine_sideload I 01-06 03:09:12   405   405 snapshot.cpp:3447] Successfully created snapshot partition for system_b
[    6.786776] update_engine_sideload I 01-06 03:09:12   405   405 snapshot.cpp:3447] Successfully created snapshot partition for system_dlkm_b
[    6.788708] update_engine_sideload I 01-06 03:09:12   405   405 snapshot.cpp:3447] Successfully created snapshot partition for system_ext_b
[    6.856357] update_engine_sideload I 01-06 03:09:13   405   405 snapshot.cpp:3447] Successfully created snapshot partition for vendor_b
[    6.860247] update_engine_sideload I 01-06 03:09:13   405   405 snapshot.cpp:3447] Successfully created snapshot partition for vendor_dlkm_b
[    6.860324] update_engine_sideload I 01-06 03:09:13   405   405 snapshot.cpp:3459] Successfully created snapshot for odm_b
[    6.860361] update_engine_sideload I 01-06 03:09:13   405   405 snapshot.cpp:3459] Successfully created snapshot for product_b
[    6.860398] update_engine_sideload I 01-06 03:09:13   405   405 snapshot.cpp:3459] Successfully created snapshot for system_b
[    6.860434] update_engine_sideload I 01-06 03:09:13   405   405 snapshot.cpp:3459] Successfully created snapshot for system_dlkm_b
[    6.860471] update_engine_sideload I 01-06 03:09:13   405   405 snapshot.cpp:3459] Successfully created snapshot for system_ext_b
[    6.860565] update_engine_sideload E 01-06 03:09:13   405   405 fiemap_writer.cpp:664] Failed to create file at: /data/gsi/ota/vendor_b-cow-img.img: No such file or directory
[    6.860606] update_engine_sideload E 01-06 03:09:13   405   405 split_fiemap_writer.cpp:68] Could not determine maximum file size for /data/gsi/ota/vendor_b-cow-img.img

可以看到失败的日志少了如下三行,合理推测升级失败原因可能和vendor_b、vendor_dlkm_b这两个分区快照创建失败有关。

js 复制代码
Successfully created snapshot for vendor_b
Successfully created snapshot for vendor_dlkm_b
Successfully created all snapshots for target slot _b

目前安卓的升级机制是ab分区,平时的时候一个分区a是在用的,另一个分区b是空的,升级之前先在b分区准备好,然后再整体切换过去。升级完成之后就在使用b分区,a分区开始变成空的。如果你是在没有准备升级的过程中直接切换成另一个分区,机器会直接卡开机logo

js 复制代码
fastboot getvar current-slot
fastboot set_active a\b

同时重点关注下面这两行日志,这两行日志是出现在理应出现Successfully created snapshot for vendor_b的位置出现的

js 复制代码
update_engine_sideload E 01-06 03:09:13   405   405 fiemap_writer.cpp:664] Failed to create file at: /data/gsi/ota/vendor_b-cow-img.img: No such file or directory
update_engine_sideload E 01-06 03:09:13   405   405 split_fiemap_writer.cpp:68] Could not determine maximum file size for /data/gsi/ota/vendor_b-cow-img.img

通过关键词/data/gsi搜索,在网上搜到了这篇文章对Virtual A/B 分区工作方式的进一步探索 - LibXZR 的小本本,文章中提到升级内容默认会在super分区中创建临时的逻辑分区来进行存储,而在super分区空间不够用时,才会在/data下创建,同时也提到这些内容会创建在/data/gsi/ota路径下。

日志中正好提到Failed to create file at: /data/gsi/ota/vendor_b-cow-img.img: No such file or directory,是不是因为super分区不够才会升级失败的呢?查询发现当前设备设置的super分区是6g,尝试改成8g之后发现确实升级成功率会高很多,具体要设置多少才合适,是不是越大越好呢?在查阅谷歌官方文档和查找资料过程中,发现该项目实际采用的是虚拟ab分区,对super分区的要求如下

那么问题来了,不增加super分区升级会经常失败,但是谷歌又不推荐增加super分区。它的设计机制是使用/data的空间,但是日志中为什么在/data分区中创建文件失败了呢?

也是在查找资料过程中,发现安卓源码bootable/recovery/中有个updater_sample的app。尝试用这个app对设备进行差分升级,发现使用这种方式升级就能成功。那就是说在recovery模式下/data分区无法正常调用,但是在设备进系统使用的情况下是能使用的。

相关推荐
水瓶丫头站住4 小时前
安卓APP如何适配不同的手机分辨率
android·智能手机
xvch4 小时前
Kotlin 2.1.0 入门教程(五)
android·kotlin
倔强的石头1065 小时前
解锁辅助驾驶新境界:基于昇腾 AI 异构计算架构 CANN 的应用探秘
人工智能·架构
qzhqbb5 小时前
web服务器 网站部署的架构
服务器·前端·架构
weixin_SAG6 小时前
第3天:阿里巴巴微服务解决方案概览
微服务·云原生·架构
xvch8 小时前
Kotlin 2.1.0 入门教程(七)
android·kotlin
望风的懒蜗牛8 小时前
编译Android平台使用的FFmpeg库
android
helianying558 小时前
云原生架构下的AI智能编排:ScriptEcho赋能前端开发
前端·人工智能·云原生·架构
浩宇软件开发9 小时前
Android开发,待办事项提醒App的设计与实现(个人中心页)
android·android studio·android开发
ac-er88889 小时前
Yii框架中的多语言支持:如何实现国际化
android·开发语言·php