UBIFS分区制作及UBIFS烧写和启动

UBIFS分区制作及UBIFS烧写和启动
相关命令工具
ubiattach version 1.0 - a tool to attach MTD device to UBI.
Usage: ubiattach   
[-m ] [-d ]
[--mtdn=] [--devn ]

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
and create UBI device number 3 (ubi3)

-d, --devn=  the number to assign to the newly created UBI       device(the number is assigned automatically if this is not specified)
-m, --mtdn=  MTD device number to attach
-O, --vid-hdr-offset            VID header offset (do not specify this unless you really know what you do and the optimal defaults will be used)
-h, --help                      print help message
-V, --version                   print program version

ubimkvol version 1.0 - a tool to create UBI volumes.
Usage: ubimkvol [-h] [-a ] [-n ] [-N ] [-s ] [-S ] [-t ] [-V] [-m] [--alignment=][--vol_id=] [--name=] [--size=] [--lebs=] [--type=] [--help] [--version] [--maxavsize]

Example: ubimkvol/dev/ubi0 -s 20MiB -N config_data - create a 20 Megabytes volume
named "config_data" on UBI device /dev/ubi0.

-a, --alignment=   volume alignment (default is 1)
-n, --vol_id=      UBI volume ID, if not specified, the volume ID
will be assigned automatically
-N, --name=             volume name
-s, --size=            volume size volume size in bytes, kilobytes (KiB)
or megabytes (MiB)
-S, --lebs=       alternative way to give volume size in logical
eraseblocks
-m, --maxavsize               set volume size to maximum available size
-t, --type=   volume type (dynamic, static), default is dynamic
-h, -?, --help                print help message
-V, --version                 print program version

The following is a compatibility option which is deprecated, do not use it
-d, --devn=             UBI device number - may be used instead of the UBI
device node name in which case the utility assumes
that the device node is "/dev/ubi"

ubidetach version 1.0 - a tool to remove UBI devices (detach MTD devices from UBI)
Usage: ubidetach [-d ] [-m ] [--devn ] [--mtdn=]
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)

-d, --devn=  UBI device number to delete
-m, --mtdn=  or altrnatively, MTD device number to detach -
this will delete corresponding UBI device
-h, --help                      print help message
-V, --version                   print program version

ubiformat version 1.0 - a tool to format MTD devices and flash UBI images
Usage: ubiformat [-h] [-V] [-y] [-q] [-v]
[-x ] [-E ] [-s ] [-O ] [-n]
[--help] [--version] [--yes] [--verbose] [--quiet]
[--ec=] [--vid-hdr-offset=]
[--ubi-ver=] [--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 0 - format MTD device number 0,
be quiet and force erase counter value 0.

-s, --sub-page-size=  minimum input/output unit used for UBI
headers, e.g. sub-page size in case of NAND
flash (equivalent to the minimum input/output
unit size by default)
-O, --vid-hdr-offset=  offset if the VID header from start of the
physical eraseblock (default is the next
minimum I/O unit or sub-page after the EC
header)
-n, --no-volume-table        only erase all eraseblock and preserve erase
counters, do not write empty volume table
-f, --flash-image=     flash image file
-e, --erase-counter=  use as the erase counter value for all
eraseblocks
-y, --yes                    assume the answer is "yes" for all question
this program would otherwise ask
-q, --quiet                  suppress progress percentage information
-v, --verbose                be verbose
-x, --ubi-ver=          UBI version number to put to EC headers
(default is 1)
-h, -?, --help               print help message
-V, --version                print program version

使用实例
将一个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 //挂载

烧写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)

NFS文件系统上烧写

法一,使用 ubiformat工具

./ubiformat -q /dev/mtd5 -f ubi.img  

法二,不必烧写映像,将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

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

你可能感兴趣的:(linux设备驱动)