- Please refer to Linux Kernel configuration.
Device Drivers --->
<*> Memory Technology Device (MTD) support --->
< > Parallel port support --->
<*> Enable UBI - Unsorted block images --->
<*> NAND Device Support --->
File systems --->
[*] Miscellaneous filesystems --->
[*] Network File Systems --->
<*> UBIFS file system support
2. Please erase the MTD device.
# flash_eraseall /dev/mtdNum
# ubiformat /dev/mtdNum -y
3. Capture the parameter of ubifs and then create the rootfs.ubi.
# ubiattach /dev/ubi_ctrl -m 4
UBI: attaching mtd4 to ubi0
UBI: scanning is finished
UBI: attached mtd4 (name "NAND Compressed RFS Image", size 500 MiB) to ubi0
UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
UBI: good PEBs: 3996, bad PEBs: 4, corrupted PEBs: 0
UBI: user volume: 0, internal volumes: 1, max. volumes count: 128
UBI: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 590956223
UBI: available PEBs: 3916, total reserved PEBs: 80, PEBs reserved for bad PEB handling: 76
UBI: background thread "ubi_bgt0d" started, PID 1235
UBI device number 0, total 3996 LEBs (507396096 bytes, 483.9 MiB), available 3916 LEBs (497238016 bytes, 474.2 MiB), LEB size 126976 bytes (124.0 KiB)
>mkfs.ubifs -q -r rootfs/ -m 2048 -e 126976 -c 4000 -o ubifs.img
>ubinize -o ubi.img -m 2048 -p 128KiB -s 2048 ubinize.cfg
Where the ubinize.cfg, here is the e.g:
###################
[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=200MiB
vol_type=dynamic
vol_name=rootfs
####################
For the value of the parameters listed above can be got the info:
-m smallest flash I/O unit
-e logical eraseblock size( May be "logical erase block size + 1k (or 2k) = physical eraseblock size ")
-c available LEBs
-p physical eraseblock size
-s -sub-page-size=<bytes> 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)
4. Detach the ubi device, then format the rootfs into the MTD block and re-attach the UBI
# ubidetach /dev/ubi_ctrl -m 4
# ubiformat /dev/mtd4 -f ./ubi.img
# ubiattach /dev/ubi_ctrl -m 4
# mount -t ubifs ubi0_0 /mnt
# ls /mnt/
=>setenv bootargs ubi.mtd=<MTD_num> root=ubi0_0 rw rootfstype=ubifs console=ttyS0,115200