昨天解包了一天,HIT archive data格式的system.img用simg2img解不了,在網上查了好久,終於把HIT archive data格式的system.img成功掛載,以下把我解包過程中所遇到的問題在這裏和大家分享一下,希望能幫到大家。
我的機器環境:ubuntu 12.04 lts(64位)
1,創建一個需要被掛在的目錄
# mkdir /mnt/system
2,載入mtd模塊
# modprobe mtdblock
3,載入ubi模塊(前提你的linux環境以支持ubi模塊)
# modprobe ubi
4,載入nandsim來模擬nand設備
# modprobe nandsim first_id_byte=0xec second_id_byte=0xd5 third_id_byte=0x51 fourth_id_byte=0xa6 //- 2GiB, 4096 bytes page.
要根據自己機器的情況來選擇:
modprobe nandsim first_id_byte=0x20 second_id_byte=0x33 - 16MiB, 512 bytes page;
modprobe nandsim first_id_byte=0x20 second_id_byte=0x35 - 32MiB, 512 bytes page;
modprobe nandsim first_id_byte=0x20 second_id_byte=0x36 - 64MiB, 512 bytes page;
modprobe nandsim first_id_byte=0x20 second_id_byte=0x78 - 128MiB, 512 bytes page;
modprobe nandsim first_id_byte=0x20 second_id_byte=0x71 - 256MiB, 512 bytes page;
modprobe nandsim first_id_byte=0x20 second_id_byte=0xa2 third_id_byte=0x00 fourth_id_byte=0x15 - 64MiB, 2048 bytes page;
modprobe nandsim first_id_byte=0xec second_id_byte=0xa1 third_id_byte=0x00 fourth_id_byte=0x15 - 128MiB, 2048 bytes page;
modprobe nandsim first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=0x15 - 256MiB, 2048 bytes page;
modprobe nandsim first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte=0x15 - 512MiB, 2048 bytes page;
modprobe nandsim first_id_byte=0xec second_id_byte=0xd3 third_id_byte=0x51 fourth_id_byte=0x95 - 1GiB, 2048 bytes page;我昨天解包的時候就是在這裏搞錯了(我的機器需要4096 bytes page),然後再最後mount的時候老是mount不上,記住這步至關重要! 5,檢查加入模塊的環境
# cat /proc/mtd
dev: size erasesize name
mtd0: 10000000 00020000 "NAND simulator partition 0"
# ls -la /dev/mtd*
crw-rw---- 1 root root 90, 0 2013-08-17 20:02 /dev/mtd0
crw-rw---- 1 root root 90, 1 2013-08-17 20:02 /dev/mtd0ro
brw-rw---- 1 root disk 31, 0 2013-08-17 20:03 /dev/mtdblock0
6,把system.img直接載到mtd的塊設備
dd if=system.img of=/dev/mtdblock0 bs=2048
以上步驟一般都可以順利進行下去
7,在這裏 需要安裝mtd-utils工具箱(ubuntu下 直接apt-get install mtd-utils),這一步是將ubi模塊與已載入了system.img的mtd模塊關聯
# ubiattach /dev/ubi_ctrl -m 0
在這裏 很多Linux環境會不成功,提示
ubiattach: error!: cannot attach mtd0
error 22 (Invalid argument)
此時 可以通過查看dmesg,可以看到
UBI error: validate_ec_hdr: bad VID header offset 4096
預期512開始的header,我的機子是4096
我們修改 爲
# ubiattach /dev/ubi_ctrl -m 0 -O 4096
到這裏,模塊載入成功
UBI device number 0, total 2048 LEBs (264241152 bytes, 252.0 MiB), available 0 LEBs (0 bytes), LEB size 129024 bytes (126.0 KiB)
8,掛載該模塊到指定目錄就OK
# mount -t ubifs /dev/ubi0_0 /mnt/system/
以上內容借鑑於
http://blog.csdn.net/wise622453/article/details/10062953(大部分源自這裏)
http://www.androidquestions.org/threads/2192-how-to-mount-android_root-img-as-ubifs-image