Lession 20 文件系统移植实践三:Flash分区与文件系统镜像烧录
如何将文件系统镜像烧录到嵌入式Flash设备中,怎么样进行Flash的布局?
一、Flash设备分区
1. 嵌入式通用Flash布局
bootloader + kernel + rootfs + appfs
2. 内核启动参数bootargs: mtparts
mtdparts: mtdparts=mtd-id:<size1>@<offset1>(<name1>),<size2>@<offset2>(<name2>)
mtdparts=s5pv210-nand:1M(boot),5M(kernel),80M(rootfs),426M(usrfs)
mtdparts=s5pv210-nand:1M(boot),5M(kernel),80M(rootfs),16M(jffs2),394M(yaffs2)
要想这个参数起作用,内核中的mtd驱动必须要支持,即内核配置时需要选上
Device Drivers ---> Memory Technology Device (MTD) support ---> Command line partition table parsing
0x000000000000-0x000000100000 : "boot"
0x000000100000-0x000000600000 : "kernel"
0x000000600000-0x000005600000 : "rootfs"
0x000005600000-0x000006600000 : "jffs2"
0x000006600000-0x000020000000 : "yaffs2"
二、uboot环境下的Flash命令
nand - NAND sub-system
nand info - show available NAND devices
nand device [dev] - show or set current device
nand read - addr off|partition size
nand write - addr off|partition size
read/write 'size' bytes starting at offset 'off'
to/from memory address 'addr', skipping bad blocks.
nand write.yaffs - addr off|partition size
write 'size' bytes starting at offset 'off' with yaffs format
from memory address 'addr', skipping bad blocks.
nand erase[.spread] [clean] off size - erase 'size' bytes from offset 'off'
With '.spread', erase enough for given file size, otherwise,
'size' includes skipped bad blocks.
二、文件系统镜像烧录
0. 镜像制作: Flash型号的Page大小与Block大小,查看Datasheet手册
K9F4G08X0B Array Organization:
1 Page = (2K + 64)Bytes
1 Block = 64 Pages = (128K + 4K) Bytes
mkfs.jffs2 -d mini_busybox --pad=0x1000000 -s 2048 -e 0x20000 -l -o rootfs_128K.jffs2
1. 下载镜像到系统内存中: 确定内存地址
tftp 0x20008000 <image>
2. 确定烧录要使用的分区: 确定Flash地址
Flash地址偏移
0x000005600000-0x000006600000 : "jffs2"
0x000006600000-0x000020000000 : "yaffs2"
3. 烧录内存中的镜像到Flash分区中
nand erase[.spread] <flash-offset> <size>
nand write <memory-address> <flash-offset> <size>
nand write.yaffs <memory-address> <flash-offset> <size>
完整命令:
tftp 0x20008000 rootfs.jffs2;nand erase 0x5600000 0x1000000;nand write 0x20008000 0x6600000 0x1000000
tftp 0x20008000 rootfs.yaffs2;nand erase 0x6600000 0x19a00000;nand write.yaffs 0x20008000 0x6600000 0x4194c0