宅男
分类: LINUX
2011-02-28 12:07:44
一.在内核选项中配置好ubifs
Device Drivers
Memory Technology Device (MTD) support
UBI - Unsorted block images
2)File systems --->Miscellaneous filesystems --->UBIFS file system support
File systems
Miscellaneous filesystems
UBIFS file system support
二.编译用户工具
wget
好了,将这个工具拷贝到/usr/sbin目录下面
三.使用步骤
由于没有提供flash_eraseall 用户工具,我们擦除nandflash只能在U_boot控制台下擦除了
(1)在U_boot控制台下擦除nandflash
(2)挂载nfs文件系统,在nfs文件系统下执行下面操作
(3)ubiattach /dev/ubi_ctrl -m 3
/ # ubiattach /dev/ubi_ctrl -m 3
UBI: attaching mtd3 to ubi0
UBI: physical eraseblock size: 16384 bytes (16 KiB)
UBI: logical eraseblock size: 15872 bytes
UBI: smallest flash I/O unit: 512
UBI: sub-page size: 256
UBI: VID header offset: 256 (aligned 256)
UBI: data offset: 512
UBI: empty MTD device detected
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
UBI: attached mtd3 to ubi0
UBI: MTD device name: "user"
UBI: MTD device size: 34 MiB
UBI: number of good PEBs: 2176
UBI: number of bad PEBs: 0
UBI: max. allowed volumes: 92
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 0
UBI: available PEBs: 2151
UBI: total number of reserved PEBs: 25
UBI: number of PEBs reserved for bad PEB handling: 21
UBI: max/mean erase counter: 0/0
UBI: background thread "ubi_bgt0d" started, PID 393
UBI device number 0, total 2176 LEBs (34537472 bytes, 32.9 MiB), available 2151 LEBs (34140672 bytes, 32.6 MiB), LEB size 15872 bytes (15.5 KiB)
(4)mdev -s
这样我们可以在/dev目录下看见ubi0设备了
(5)ubimkvol /dev/ubi0 -N ubifs -s 15MiB
/ # ubimkvol /dev/ubi0 -N ubifs -s 15MiB
Volume ID 0, size 991 LEBs (15729152 bytes, 15.0 MiB), LEB size 15872 bytes (15.5 KiB), dynamic, name "ubifs", alignment 1
(6)mount -t ubifs ubi0:ubifs /mnt
/ # mount -t ubifs ubi0:ubifs /mnt
UBIFS: default file-system created
UBIFS: background thread "ubifs_bgt0_0" started, PID 402
UBIFS: mounted UBI device 0, volume 0, name "ubifs"
UBIFS: file system size: 15538688 bytes (15174 KiB, 14 MiB, 979 LEBs)
UBIFS: journal size: 777728 bytes (759 KiB, 0 MiB, 49 LEBs)
UBIFS: default compressor: LZO
UBIFS: media format 4, latest format 4
(7)下面就可以创建我们的文件系统了
/ # cp -af bin/ usr/ etc/ root/ home/ sbin/ /mnt
/ # cd /mnt
/mnt # mkdir sys/ dev/ var/ mnt/ proc/ tmp/
/mnt # cd dev
由于我们的sep4020上不能自刷新,所以创建了一个ubi0节点
/mnt/dev # mknod ubi0 c 254 0
/mnt/dev # mknod console c 5 1
(8)重启启动开发板,切换到U_boot控制台界面下设置bootargs参数
set bootargs console=ttyS0,115200 ubi.mtd=3 root=ubi0:ubifs rootfstype=ubifs
(9)重新启动开发板,就会看见下面的启动信息
----------------如有不对,欢迎指正,谢谢