system分区挂载失败案例分析

最近项目需要升级高通base,具体从LA3.0.1升级到LA3.1.1,发现一个问题:Android go版本可以正常开机,但是Android O版本无法正常开机,UART log显示system分区挂载失败,会自动进入fastboot。

[    6.943432] EXT4-fs (mmcblk0p6): bad geometry: block count 309656 exceeds size of device (230400 blocks)
[    6.952984] init: [libfs_mgr]__mount(source=/dev/block/platform/soc/7824900.sdhci/by-name/system,target=/system,type=ext4)=-1: Invalid argument
[    6.965488] init: Failed to mount '/system': Invalid argument
[    6.972605] init: Failed to mount required partitions early ...
[    6.977989] init: panic: rebooting to bootloader
[    6.982840] init: Reboot start, reason: reboot, rebootTarget: bootloader

在分析过程中,发现使用fastboot烧录system.img和vendor.img都会失败,并提示:

C:\Users\yangxinwei>
C:\Users\yangxinwei>fastboot flash system Z:\benz_la_311\LINUX\android\out\target\product\msm8909_benz\system.img
target reported max download size of 262144000 bytes
erasing 'system'...
OKAY [  0.109s]
sending sparse 'system' (254578 KB)...
OKAY [ 10.230s]
writing 'system'...
FAILED (remote: size too large)
finished. total time: 10.367s

C:\Users\yangxinwei>

跟踪fastboot flash相关代码发现,所烧写的镜像的确超过了分区大小,并得到了如下详细信息:

[1280] fastboot: processing commands
[20720] fastboot: getvar:partition-type:system
[20740] fastboot: getvar:max-download-size
[31310] fastboot: erase:system
[31310] Erasing card: 0x50c60:0x1c2000
[31310] erasing 0x50c60:0x3a0
[31410] erasing 0x212c00:0x60
[31580] fastboot: download:0f89c934
[41650] fastboot: flash:system
[41650] yxw test0627 here!! sparse_header->magic = ed26ff3a
[41650] yxw test0627 here111!![41660] yxw test0627 size = 943718400
[41660] yxw test0627 111sparse_header->total_blks = 314573
[41660] yxw test0627 222sparse_header->blk_sz = 4096
[41670] yxw test0627 222

system分区挂载失败案例分析_第1张图片

314573 x 4096 = 1288491008 (镜像大小)> 943718400(分区大小)

1288491008这个数字怎么来的呢?因为实际烧写的system.img大小只有737965720,原来system.img是经过simg2img压缩之后的大小,当使用fastboot命令烧写时,会将其解压缩为1288491008

system分区挂载失败案例分析_第2张图片

这让我产生了怀疑,难道是分区大小不对?或者编译有问题,导致镜像过大?

首先,检查是否编译,重新编译system镜像,编译log如下:

[ 99% 2793/2794] Target system fs image: out/target/product/msm8909_benz/obj/PACKAGING/systemimage_intermediates/system.img
Running:  build_verity_tree -s 1288491008
10153984
Running:  system/extras/verity/build_verity_metadata.py size 1288491008
32768
Running:  fec -s 1298677760
10276864
Running:  build_verity_tree -s 1278259200
10076160
Running:  system/extras/verity/build_verity_metadata.py size 1278259200
32768
Running:  fec -s 1288368128
10194944
Running:  build_verity_tree -s 1273143296
10031104
Running:  system/extras/verity/build_verity_metadata.py size 1273143296
32768
Running:  fec -s 1283207168
10153984
Running:  build_verity_tree -s 1270583296
10010624
Running:  system/extras/verity/build_verity_metadata.py size 1270583296
32768
Running:  fec -s 1280626688
10129408
Running:  build_verity_tree -s 1269305344
10002432
Running:  system/extras/verity/build_verity_metadata.py size 1269305344
32768
Running:  fec -s 1279340544
10121216
Running:  build_verity_tree -s 1268666368
9994240
Running:  system/extras/verity/build_verity_metadata.py size 1268666368
32768
Running:  fec -s 1278693376
10113024
Running:  build_verity_tree -s 1268346880
9994240
Running:  system/extras/verity/build_verity_metadata.py size 1268346880
32768
Running:  fec -s 1278373888
10113024
Running:  build_verity_tree -s 1268506624
9994240
Running:  system/extras/verity/build_verity_metadata.py size 1268506624
32768
Running:  fec -s 1278533632
10113024
Running:  build_verity_tree -s 1268428800
9994240
Running:  system/extras/verity/build_verity_metadata.py size 1268428800
32768
Running:  fec -s 1278455808
10113024
Running:  build_verity_tree -s 1268387840
9994240
Running:  system/extras/verity/build_verity_metadata.py size 1268387840
32768
Running:  fec -s 1278414848
10113024
Running:  build_verity_tree -s 1268367360
9994240
Running:  system/extras/verity/build_verity_metadata.py size 1268367360
32768
Running:  fec -s 1278394368
10113024
Running:  build_verity_tree -s 1268359168
9994240
Running:  system/extras/verity/build_verity_metadata.py size 1268359168
32768
Running:  fec -s 1278386176
10113024
Running:  build_verity_tree -s 1268355072
9994240
Running:  system/extras/verity/build_verity_metadata.py size 1268355072
32768
Running:  fec -s 1278382080
10113024
Running:  build_verity_tree -s 1268350976
9994240
Running:  system/extras/verity/build_verity_metadata.py size 1268350976
32768
Running:  fec -s 1278377984
10113024
Running:  mkuserimg.sh -s out/target/product/msm8909_benz/system out/target/product/msm8909_benz/obj/PACKAGING/systemimage_intermediates/system.img ext4 system 1268350976 -D out/target/product/msm8909_benz/system -L system out/target/product/msm8909_benz/obj/ETC/file_contexts.bin_intermediates/file_contexts.bin
make_ext4fs -s -T -1 -S out/target/product/msm8909_benz/obj/ETC/file_contexts.bin_intermediates/file_contexts.bin -L system -l 1268350976 -a system out/target/product/msm8909_benz/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/msm8909_benz/system out/target/product/msm8909_benz/system
Creating filesystem with parameters:
    Size: 1268350976
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 7744
    Inode size: 256
    Journal blocks: 4838
    Label: system
    Blocks: 309656
    Block groups: 10
    Reserved block group size: 79
Created filesystem with 3028/77440 inodes and 179993/309656 blocks

这个与device/qcom/msm8909/BoardConfig.mk中配置一致

BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1288491008

所以编译没有问题,那是不是分区太小了呢?

先查看system分区大小:

common/build/partition.xml

从上面可以看出system分区大小为921600 x 1024 = 943718400(可以上面分区大小正好对应哦)

所以有两种解决办法:

1、修改BoardConfig配置,使其不超分区大小

2、修改分区大小,以适应BoardConfig配置

由于手机实际system镜像大小只有737965720,所以选用方案1

你可能感兴趣的:(Android,Experience)