有关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 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 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

Ubifs文件系统和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


                
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值