有关ubi文件格式的解压
http://www.at91.com/linux4sam/bin/view/Linux4SAM/SDCardBootNoticeHow to extract the files of pre-compiled demo (UBI, JFFS2), and copy them to SD card's ext2/4 partition?To do this, mount the ubi
http://www.at91.com/linux4sam/bin/view/Linux4SAM/SDCardBootNotice
How to extract the files of pre-compiled demo (UBI, JFFS2), and copy them to SD card's ext2/4 partition?
To do this, mount the ubi/jffs2 pre-compiled demo image as a loopback device in your PC, and then copy all files to your SD card's partition.Here are the steps: (tested in Ubuntu 11.04.)
- Install "mtd-utils" package in PC.
sudo apt-get install mtd-utils
- Mount UBIFS images as a loopback:
modprobe nandsim first_id_byte=0x2c second_id_byte=0xda third_id_byte=0x00 fourth_id_byte=0x15 modprobe ubi mtd=0 ubidetach /dev/ubi_ctrl -m 0 ubiformat /dev/mtd0 -s 2048 -f Angstrom-x11-at91sam9-image-eglibc-ipk-v20110624-at91sam9x5ek.rootfs.ubi ubiattach /dev/ubi_ctrl -m 0 -O 2048 mkdir /mnt/loop mount -t ubifs ubi0 /mnt/loop cp -R /mnt/loop/* /new/directory
- Mount JFFS2 images as a loopback:
modprobe nandsim first_id_byte=0x2c second_id_byte=0xda third_id_byte=0x00 fourth_id_byte=0x15 modprobe mtdblock modprobe mtdchar modprobe mtd mtd=0 dd if=Angstrom-x11-at91sam9m10-image-glibc-ipk-2009.X-stable-at91sam9m10g45ek.rootfs.jffs2 of=/dev/mtd0 mkdir /mnt/loop mount -t jffs2 /dev/mtdblock0 /mnt/loop cp -R /mnt/loop/* /new/directory/
Tip: if you are using sama5d4ek
or sama5d4_xplained
board, the nand flash is different, so please use following line to do the nandsim, and change the page size to 4096.
sudo modprobe nandsim first_id_byte=0x2c second_id_byte=0xdc third_id_byte=0x90 fourth_id_byte=0xa6
解包system.img成HIT archive data格式的包
http://ye-good-job.iteye.com/blog/2055570昨天解包了一天,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 ubi4,载入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/mtddev: 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,可以看到
预期512开始的header,我的机子是4096UBI 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-imageUbifs文件系统和mkfs.ubifs以及ubinize工具的用法
http://blog.sina.com.cn/s/blog_9452251d0102v482.html
科胜讯
/opt/conexant/sdk/target/ubifs中的文件
Config.in 在make menuconfig时使用
ubifsroot.mk在make ubifsroot时使用
ubinize.cfg 在make ubifsroot生成rootfs.arm.ubifs.ubi文件系统镜像时使用
make ubifsroot将使用mkfs.ubifs和ubinize两个工具
有了mkfs.ubifs和ubinize两个工具后,就可以制作UBIFS镜像了,具体步骤如下:
1. 使用mkfs.ubifs命令将某个文件夹制作为UBIFS镜像,具体命令为:
mkfs.ubifs -r /opt/conexant/sdk/output/target -m 2048 -e 126976-c 992 -o rootfs.arm.ubifs
以上命令的含义为将/opt/conexant/sdk/output/target文件夹制作为UBIFS文件系统镜像,输出的镜像名为rootfs.arm.ubifs,-m参数指定了最小的I/O操作的大小,也就是NAND FLASH一个page的大小,-e参数指定了逻辑擦除快的大小,-c指定了最大的逻辑块号。
通过此命令制作的出的UBIFS文件系统镜像可在u-boot下使用ubi write命令烧写到NAND FLASH上。
2. 使用ubinize命令可将使用mkfs.ubifs命令制作的UBIFS文件系统镜像转换成可直接在FLASH上烧写的格式(带有UBI文件系统镜像卷标):
通过此命令生成的ubi.img可直接使用NAND FLASH的烧写命令烧写到FLASH上。
ubinize -o /opt/conexant/sdk/output/images/rootfs.arm.ubifs.ubi -m 2048 -p 128KiB-s 512 -O 2048 ubinize.cfg
ubinize.cfg为一些配置参数:
[ubifs]
mode=ubi
image=/opt/conexant/sdk/output/images/rootfs.arm.ubifs
vol_id=0
vol_type=dynamic
vol_name=dc-rootfs
vol_flags=autoresize
更多推荐
所有评论(0)