ubifs

UBIFS分区制作 UBIFS烧写 启动 (转载)

2014年04月05日  ⁄ 综合 ⁄ 共 4117字 ⁄ 字号  小 中 大  ⁄ 评论关闭
id="cproIframe_u1788635_2" width="336" height="280" src="http://pos.baidu.com/acom?adn=3&at=103&aurl=&cad=1&ccd=24&cec=UTF-8&cfv=16&ch=0&col=zh-CN&conOP=0&cpa=1&dai=2&dis=0&ltr=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26f%3D8%26rsv_bp%3D1%26rsv_idx%3D1%26tn%3Dbaidu%26wd%3Duboot%25E7%2583%25A7%25E5%2586%2599%2520ubifs%26rsv_pq%3D85b1f0d6000055b9%26rsv_t%3D409a7Yc8TnHemR3P40QPGN5159ZotBDW%252BYvB869FCoZ1wKzpRNn%252BMs5vi28%26rsv_enter%3D1%26rsv_sug3%3D35%26rsv_sug4%3D2251%26rsv_sug1%3D33%26rsv_sug2%3D0%26inputT%3D20653&ltu=http%3A%2F%2Fwww.xuebuyuan.com%2F2029140.html&lunum=6&n=83099053_cpr&pcs=1280x933&pis=10000x10000&ps=326x866&psr=1280x1024&pss=1280x346&qn=5bd609456e0e0362&rad=&rsi0=336&rsi1=280&rsi5=4&rss0=%23FFFFFF&rss1=%23FFFFFF&rss2=%230000ff&rss3=%23444444&rss4=%23008000&rss5=&rss6=%23e10900&rss7=&scale=&skin=&td_id=1788635&tn=text_default_336_280&tpr=1420791141008&ts=1&xuanting=0&dtm=BAIDU_DUP2_SETJSONADSLOT&dc=2&di=u1788635" align="center,center" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" allowtransparency="true" style="margin: 0px; padding: 0px; border-width: 0px; background: transparent;">

相关命令工具
1.ubiattach version 1.0 - a tool to attach MTD device to UBI.

Usage: ubiattach  <UBI control device node file name>  [-m <MTD device number>] [-d <UBI device number>]  [--mtdn=<MTD device number>] [--devn <UBI device number>]

Example 1: ubiattach /dev/ubi_ctrl -m 0 (attach MTD device 0 (mtd0) to UBI)

Example 2: ubiattach /dev/ubi_ctrl -m 0 -d 3(attach MTD device 0 (mtd0) to UBI and create UBI device number 3 (ubi3))


2.ubimkvol version 1.0 - a tool to create UBI volumes.
Usage: 
ubimkvol <UBI device node file name> [-h] [-a <alignment>] [-n <volume ID>] [-N <name>] [-s <bytes>] [-S <LEBs>] [-t <static|dynamic>] [-V] [-m] 

[--alignment=<alignment>][--vol_id=<volume ID>] [--name=<name>] [--size=<bytes>] [--lebs=<LEBs>] [--type=<static|dynamic>] [--help] [--version] 

[--maxavsize]

Example: 

ubimkvol
/dev/ubi0 -s 20MiB -N config_data     (reate a 20 Megabytes volume 
named "config_data" on UBI device /dev/ubi0.)


3.ubidetach version 1.0 - a tool to remove UBI devices (detach MTD devices from UBI)
Usage: 
ubidetach<UBI control device node file name> [-d <UBI device number>] [-m <MTD device number>] [--devn <UBI device number>]

 [--mtdn=<MTD device number>]

Example 1: ubidetach /dev/ubi_ctrl -d 2
      (delete UBI device 2 (ubi2))

Example 2: ubidetach /dev/ubi_ctrl -m 0      (detach MTD device 0 (mtd0))


4.ubiformat version 1.0 - a tool to format MTD devices and flash UBI images
Usage: ubiformat <MTD device node file name> [-h] [-V] [-y] [-q] [-v][-x <num>] [-E <value>] [-s <bytes>] [-O <offs>] [-n]
[--help] [--version] [--yes] [--verbose] [--quiet][--ec=<value>] [--vid-hdr-offset=<offs>][--ubi-ver=<num>] [--no-volume-table]
Example 1: ubiformat /dev/mtd0 -y  format MTD device number 0 and do  not ask questions.
Example 2: ubiformat /dev/mtd0 -q -e 0format MTD device number 0,be quiet and force erase counter value 0.


使用实例
1.分区制作:将一个MTD分区挂载为UBIFS格式 

● flash_eraseall /dev/mtd5 //擦除mtd5 
● ubiattach /dev/ubi_ctrl -m 5 -d 0 //UBI和mtd5关联 ->ubi0
● ubimkvol /dev/ubi0 -n 0 -N rootfs0 -s 256MiB 
//创建分区ubi0_0设定volume 大小

● mount -t ubifs ubi0_0 /mnt/ubi或mount -t ubifs ubi0:rootfs0 /mnt/ubi //挂载


2.烧写:烧写UBIFS文件系统映像

方法一:U-Boot烧写ubifs:(mmc)

#mmcinit
#fatload mmc 0:1 81000000 ubi.img
#nand unlock
#nand ecc sw
#nand erase 680000 7980000
#nand write.i 81000000 680000 $(filesize)   (或nand write.e)

方法二:在u-boot下通过nand write命令烧写
使用ubinize命令制作的带有卷标的UBIFS文件系统镜像可以直接使用nand flash的烧写命令烧写到NAND FLASH上,具体命令为:
tftp 0xc1180000 ubi.img
nand erase 0x400000 0x7c00000
nand write.e 0xc1180000 0x400000 0x3660000
关于tftp,nand 等命令使用格式请参见u-boot的help。

方法三:在u-boot下通过ubi write命令烧写
使用mkfs.ubifs命令制作的UBIFS文件系统镜像可以使用命令ubi write烧写到NAND FLASH上,具体命令为:
1. 设置FLASH的分区,此处以128M NAND FLASH为例,分为5个区:
setenv mtdids nand0=nand0
setenv mtdparts mtdparts=nand0:0x20000(u-boot env),0x20000(UBL),0x1c0000(u-boot),0x200000(kernel),0x7c00000(filesystem)
设置完后,使用mtdparts命令可以看到分区信息:
device nand0 <nand0>, # parts = 5
 #: name size offset mask_flags
 0: u-boot env 0x00020000 0x00000000 0
 1: UBL 0x00020000 0x00020000 0
 2: u-boot 0x001c0000 0x00040000 0
 3: kernel 0x00200000 0x00200000 0
 4: filesystem 0x07c00000 0x00400000 0
active partition: nand0,0 - (u-boot env) 0x00020000 @ 0x00000000

2. 烧写文件系统:
nand erase 0x400000 0x7c00000
tftp 0xc1180000 ubifs.img
ubi create rootfs
ubi part nand filesystem
ubi write 0xc1180000 rootfs 0x1d1000
通过以上命令,可以将文件系统烧写到第4个分区上,UBIFS文件系统卷标为rootfs。
3. 设置内核启动参数:
setenv bootargs 'console=ttyS2,115200n8 ubi.mtd=4,2048 root=ubi0:rootfs rootwait rootfstype=ubifs rw ip=off'
这样就可以将烧写的UBIFS文件系统用作根分区了。


方法四:NFS文件系统上烧写

(1)使用ubiformat工具

./ubiformat -q /dev/mtd5 -f ubi.img  (ubiformat
/dev/mtd4 -
s 2048  -f ubi.img >  /dev/null 2>&1

我们在uboot中用nand markbad 试过mark bad block(一块在mtd device的首块,一块在中间,一块在最后),测试表面ubi在attach时的scan能认出
bad block nand skip bad block.同时用ubiformat烧写ubi.img时也会自动跳过bad block.

(2)不必烧写映像,将ROOTFS打包,解压到UBIFS

ubiattach /dev/ubi_ctrl -m 5 -d 0

ubimkvol /dev/ubi0 -n 0 -N rootfs -s 128MiB

mount -t ubifs ubi0_0 /mnt/ubi0

tar -jxv -C /mnt/ubi0 rootfs.tar.bz2

umount /mnt/ubi0


3.启动:UBI文件系统启动

设置UBIFS文件系统作为根文件系统启动的参数

#setenv bootargs console=ttyAM0,115200n8 ubi.mtd=5 root=ubi0:rootfs rootfstype=ubifs init=linuxrc
# setenv bootcmd nand read.i 80300000 280000 200000\;bootm 80300000




参考文献:

1.UBIFS分区制作及UBIFS烧写和启动
(转载)
http://hi.baidu.com/dreammerge/item/57055f299e561dc9a5275a95

2.ubifs烧写到nand flash中的几种方法  http://blog.163.com/shaohj_1999@126/blog/static/63406851201212305156639/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值