在linux-2。6。27以前,谈到Flash文件系统,大家很多时候多会想到cramfs、jffs2、yaffs2等文件系统。它们也都是基于文件系统+mtd+flash设备的架构。linux-2。6。27后,内核加入了一种新型的FLASH文件系统UBI(UnsortedBlockImages)。这里简单介绍下UBI文件系统加入的原因,及使用方法。我也是刚接触到这个文件系统,可能有理解不对的地方,也请指正。
l#L_overhead#mkfs。ubifs-rrootfs-m2048-e129024-c812-oubifs。img
#ubinize-oubi。img-m2048-p128KiB-s512/home/lht/omap3530/tools/ubinize。cfg
-r:制定文件内容的位置
-m:页面大小
-e:逻辑擦除块大小
-p:物理擦除块大小
-c:最大的逻辑擦除块数量
对我们这种情况,文件系统最多可以访问卷上的129024812=100M空间
-s:最小的硬件输入输出页面大小,如:k9f1208为256(上下半页访问)
其中,ubinize。cfg的内容为:
[ubifs]
mode=ubi
image=ubifs。img
vol_id=0
vol_size=100MiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
4、利用uboot烧写、启动UBIFS镜像
1)烧写UBIFS镜像
OMAP3DevKit8000#mmcinit
OMAP3DevKit8000#fatloadmmc0:181000000ubi。img
readingubi。img
12845056bytesread
OMAP3DevKit8000#nandunlock
device0wholechip
nand_unlock:start:00000000,length:235456!
NANDflashsuccessfullyunlocked
OMAP3DevKit8000#nandeccsw
OMAP3DevKit8000#nanderase6800007980000
NANDerase:device0offset0x680000,size0x7980000
Erasingat0x7fe0000--100%complete。
OK
OMAP3DevKit8000#nandwrite。i81000000680000$(filesize)
NANDwrite:device0offset0x680000,size0xc40000
Writingdataat0x12bf800--100%complete。
12845056byteswritten:OK
烧写过程和烧写内核镜像的过程一致,所以UBI文件系统应该不像yaffs文件系统那样用到了nand的OOB区域。
2)设置UBIFS文件系统作为根文件系统启动的参数
OMAP3DevKit8000#setenvbootargsconsole=ttyS2,115200n8ubi。mtd=4root=ubi0:rootfs
rootfstype=ubifsvideo=omapfb:mode:4。3inch_LCD
OMAP3DevKit8000#setenvbootcmdnandread。i80300000280000200000;bootm80300000
根文件系统的位置在MTD4上
系统启动时会打印出如下和UBI相关的信息:
Creating5MTDpartitionsnumbergoodPEBs:970
UBI:numberofbadPEBs:2
UBI:max。allowedvolumes:128
UBI:wear-levelingthreshold:4096
UBI:numberofinternalvolumes:1
UBI:numberofuservolumes:1
UBI:availablePEBs:0
UBI:totalnumberofreservedPEBs:970
UBI:numberofPEBsreservedforbadPEBhandling:9
UBI:max/meanerasecounter:2/0