[Linux Device Driver] 分区大小导致的adb remount失败解决方法

0. 背景

这个问题一般是系统组来搞,但是adb remount失败,特别影响audio/camera干活,于是我请教了下大佬,学习了一下。

对比log如下:

正常remount成功的设备:

Disabling verity for /system
Using overlayfs for /system
Disabling verity for /system_ext
Using overlayfs for /system_ext
Disabling verity for /product
Using overlayfs for /product
Disabling verity for /vendor
Using overlayfs for /vendor
Disabling verity for /odm
Using overlayfs for /odm
Now reboot your device for settings to take effect
remount succeeded

异常remount失败的设备:

C:\Users\Administrator
$ adb remount
[liblp]Device size does not match (got 6442450944, expected 12884901888)
[liblp]Block device super size mismatch (expected12884901888, got 6442450944)
[libfs_mgr]add partition scratch
Overlayfs setup for /system failed, skipping: No such file or directory
[liblp]Device size does not match (got 6442450944, expected 12884901888)
[liblp]Block device super size mismatch (expected12884901888, got 6442450944)
[libfs_mgr]add partition scratch
Overlayfs setup for /system_ext failed, skipping: No such file or directory
[liblp]Device size does not match (got 6442450944, expected 12884901888)
[liblp]Block device super size mismatch (expected12884901888, got 6442450944)
[libfs_mgr]add partition scratch
Overlayfs setup for /product failed, skipping: No such file or directory
[liblp]Device size does not match (got 6442450944, expected 12884901888)
[liblp]Block device super size mismatch (expected12884901888, got 6442450944)
[libfs_mgr]add partition scratch
Overlayfs setup for /vendor failed, skipping: No such file or directory
[liblp]Device size does not match (got 6442450944, expected 12884901888)
[liblp]Block device super size mismatch (expected12884901888, got 6442450944)
[libfs_mgr]add partition scratch
Overlayfs setup for /odm failed, skipping: No such file or directory
No partitions to remount
remount failed

C:\Users\Administrator

1. 关键log分析以及检索

Device size does not match (got 6442450944, expected 12884901888)
Block device super size mismatch (expected12884901888, got 6442450944)

这里说有个值不匹配,实际上获得的是6442450944,但是它期望或者的值是: 12884901888。 据此分析是软件某个地方对“分区”、“某个空间大小”的设置有问题,人家都说了只有6442450944这么大,然后你非要设置多了,当然报错了。

于是在整个代码环境中检索: 12884901888

grep -nr  "12884901888"   ./

在这里插入图片描述

问了下大佬,这个其实是分区的设置,实际有效的位置在:

./device/qcom/"对应lunch项"/BoardConfig.mk:69:        BOARD_SUPER_PARTITION_SIZE := 12884901888

对应lunch项是客制化的,找到之后打开这个文件:

在这里插入图片描述

这个两个位置都很重要,BOARD_SUPER_PARTITION_SIZE := 12884901888是报错的地方,我们设置的太大了,BOARD_QTI_DYNAMIC_PARTITIONS_SIZE 这个值需要符合高通的修改,这个有固定的计算方法。

2. 修改

BOARD_SUPER_PARTITION_SIZE := 12884901888

这个要修改为:6442450944,没啥说的,但是我们要搞清除这个是哪来的。下载的版本里面有个partition_XXXX.xml,
这个是高通分区表,

<partition label="super" size_in_kb="6291456" type="xxxxx" bootable="false" 
readonly="false" filename="super.img" sparse="true"/>

回到上面的报错:

Block device super size mismatch

我们需要转换成字节: 6291456*1024=6442450944

在这里插入图片描述

光改这个还不行,上面说了BOARD_QTI_DYNAMIC_PARTITIONS_SIZE 也要改,不然会报错:

RuntimeError: sum of sizes of ['qti_dynamic_partitions'] is 
greater than BOARD_SUPER_PARTITION_SIZE / 2:
6438256640 == 6438256640 > 3221225472 == 3221225472

这个值的字节数计算如下: BOARD_SUPER_PARTITION_SIZE/2 - 4MB

所以: BOARD_QTI_DYNAMIC_PARTITIONS_SIZE = 6442450944/2- 4 x 1024 x 1024=3217031168。

在这里插入图片描述
在这里插入图片描述

这个改了之后,问题就解决了,remount不会出错了。

(此问题还有后续,影响OTA升级,年后有时间更新。)

#更新 2021.03.19
这个影响OTA升级问题,原因是分配的内存不够了,modem重新配置了分区表,然后重新计算了super分区的大小,
问题就解决了,还是用的上面的计算方法。
#更新 2021.03.19

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值