可能大家都非常熟悉jffs2和yaffs2文件系统在flash上的搭建,当然对于存储系统必须文件,比如配置文件,可执行文件和数据文件等,他们是非常棒的,但是如果需要将开发板模拟成u盘来让操作系统通过usb识别的话,还需要从flash中事先保留一块分区给fat才行,下面就着重介绍如何将flash预留的6M空间做成fat32分区[luther.gliethttp].
RedBoot> fis create -l 0x600000 gliethttp.vfat // 创建一个6M的空分区,用来格式化成fat32
... Erase from 0x60c00000-0x61200000: ........................
... Program from 0x00000000-0x00000000 at 0x60c00000:
... Erase from 0x61fc0000-0x62000000: .
... Program from 0x03fbf000-0x03fff000 at 0x61fc0000: .
RedBoot> fis list
Name FLASH addr Mem addr Length Entry point
RedBoot 0x60000000 0x60000000 0x00040000 0x00000000
RedBoot config 0x61F80000 0x61F80000 0x00001000 0x00000000
FIS directory 0x61FC0000 0x61FC0000 0x00040000 0x00000000
initramfs 0x60900000 0x00800000 0x00300000 0x00800000
zImage 0x60040000 0x00080000 0x00200000 0x00080000
gliethttp.jffs2 0x60400000 0x60400000 0x00500000 0x00080000
gliethttp.vfat 0x60C00000 0x00000000 0x00600000 0x00000000
进入busybox的shell
# cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00040000 "RedBoot"
mtd1: 00200000 00040000 "zImage"
mtd2: 00500000 00040000 "gliethttp.jffs2"
mtd3: 00300000 00040000 "initramfs"
mtd4: 00600000 00040000 "gliethttp.vfat"
mtd5: 00001000 00040000 "RedBoot config"
mtd6: 00040000 00040000 "FIS directory"
# mtd_debug read /dev/mtd4 0 512 gliethttp.bin;hexdump gliethttp.bin -Cv
Copied 512 bytes from address 0x00000000 in flash to gliethttp.bin
00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000030 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000040 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000050 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000060 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000070 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000080 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000090 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000000a0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000000b0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000000c0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000000d0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000000e0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000000f0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000100 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000110 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000120 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000130 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000140 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000150 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000160 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000170 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000180 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000190 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000001a0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000001b0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000001c0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000001d0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000001e0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
000001f0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
# mkfs.vfat /dev/mtd4 6144 // 0x600000/1024=6144K
# mtd_debug read /dev/mtd4 0 512 gliethttp.bin;hexdump gliethttp.bin -Cv
Copied 512 bytes from address 0x00000000 in flash to gliethttp.bin
00000000 eb 58 90 6d 6b 64 6f 73 66 73 00 00 02 01 06 00 |.X.mkdosfs......|
00000010 02 00 00 00 30 f8 00 00 3f 00 ff 00 00 00 00 00 |....0...?.......|
00000020 00 30 00 00 5f 00 00 00 00 00 00 00 02 00 00 00 |.0.._...........|
00000030 01 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000040 00 00 29 20 04 00 00 00 00 00 00 00 00 00 00 00 |..) ............|
00000050 00 00 46 41 54 33 32 20 20 20 0e 1f be 77 7c ac |..FAT32 ...w|.|
00000060 22 c0 74 0b 56 b4 0e bb 07 00 cd 10 5e eb f0 32 |".t.V.......^..2|
00000070 e4 cd 16 cd 19 eb fe 54 68 69 73 20 69 73 20 6e |.......This is n|
00000080 6f 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 64 69 |ot a bootable di|
00000090 73 6b 0d 0a 00 00 00 00 00 00 00 00 00 00 00 00 |sk..............|
000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
# mount -t vfat /dev/mtdblock4 /mnt
# df -h
Filesystem Size Used Available Use% Mounted on
/dev/mtdblock4 5.9M 512 5.9M 0% /mnt
# cp /bin/busybox /mnt/
# df -h
Filesystem Size Used Available Use% Mounted on
/dev/mtdblock4 5.9M 808.0K 5.1M 13% /mnt
# umount /mnt
# reboot开机之后可以看到busybox实实在在的存储到了fat32分区中[luther.gliethttp].
(PS:不知道为什么
# fdisk /dev/mtd4
# fdisk /dev/mtdblock4 都不能正常创建fat分区[luther.gliethttp].
)
阅读(6142) | 评论(0) | 转发(0) |