昨天解包了一天,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
我们修改 为
# 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