1. 程式人生 > >[IMX6Q][Android5.1]移植筆記 --- 無法掛載system檔案系統

[IMX6Q][Android5.1]移植筆記 --- 無法掛載system檔案系統

platform: imx6q

os: Android5.1

branch: l5.1.1_2.1.0-ga

編譯好system image之後開機提示如下log,注意紅色部分:

Freeing unused kernel memory: 432K (c0be3000 - c0c4f000)
usb 1-1: USB disconnect, device number 2
Console: switching to colour dummy device 80x30
EXT4-fs (mmcblk2p5): VFS: Can't find ext4 filesystem
fs_mgr: __mount(source=/dev/block/mmcblk2p5,target=/system,type=ext4)=-1
fs_mgr: Failed to mount an un-encryptable or wiped partition on/dev/block/mmcblk2p5 at /system options: barrier=1 error: Invalid argument
fs_mgr: __mount(source=/dev/block/mmcblk2p4,target=/data,type=ext4)=-1
fs_mgr: fs_mgr_mount_all(): possibly an encryptable blkdev /dev/block/mmcblk2p4 for mount /data type ext4 )
fs_mgr: __mount(source=/dev/block/mmcblk2p6,target=/cache,type=ext4)=-1
fs_mgr: Failed to mount an un-encryptable or wiped partition on/dev/block/mmcblk2p6 at /cache options: nomblk_io_submit error: Read-only file system
EXT4-fs (mmcblk2p7): INFO: recovery required on readonly filesystem
EXT4-fs (mmcblk2p7): write access unavailable, cannot proceed
fs_mgr: __mount(source=/dev/block/mmcblk2p7,target=/device,type=ext4)=-1
fs_mgr: Failed to mount an un-encryptable or wiped partition on/dev/block/mmcblk2p7 at /device options: (null) error: Invalid argument
init: fs_mgr_mount_all returned an error
init: fs_mgr_mount_all returned unexpected error 255
Unable to find swap-space signature
fs_mgr: swapon failed for /dev/block/zram0
......
android_usb gadget: high-speed config #1: android
android_work: sent uevent USB_STATE=CONFIGURED
binder: 153:153 transaction failed 29189, size 0-0
binder: 153:153 transaction failed 29189, size 0-0

嘗試在本地上掛載system.img也失敗,而之前的imx6dl平臺是可以的,所以對比兩者system.img格式:


發現imx6q的是data格式,這種格式也叫sparse image,是Android為了解決system image越來越大而引進的,有如下說明:


因此我將sparse image轉換成了raw image.

[[email protected]:~/myandroid/out/target/product/sabresd_6dq]$ ./../../../../out/host/linux-x86/bin/simg2img  system.img  system_raw.img


download system_raw.img後確實可以正常開機了,所以應該是freescale對sparse image還沒有完全支援。

來看看系統流程是如何編譯為sparse image的:

build/core/Makefile:






build/tools/releasetools/build_image.py:


關注其中extfs_sparse_flag來源:


build/core/Makefile:


因此最終由TARGET_USERIMAGES_SPARSE_EXT_DISABLED來控制來決定make_ext4fs是否需要帶-s引數,

它的意義是用來控制生成的是否是sparse image,然而系統定義TARGET_USERIMAGES_SPARSE_EXT_DISABLED為false,

也就是使用了-s,可以從build log中看到:


解決方法:

定義TARGET_USERIMAGES_SPARSE_EXT_DISABLED為true, 讓系統預設編譯為system raw image.


參考: