1. 打补丁。因为linux没有自带yaffs2文件系统制作工具,所以需要打补丁。
在kernel/fs中:
a. vim Makefile ,添加:
obj-$(CONFIG_DEBUG_FS) += debugfs/
obj-$(CONFIG_OCFS2_FS) += ocfs2/
obj-$(CONFIG_GFS2_FS) += gfs2/ // 在这个位置
+# Patched by YAFFS
+obj-$(CONFIG_YAFFS_FS) += yaffs2/
b. vim Kconfig, 添加:
To compile the EFS file system support as a module, choose M here: the
module will be called efs.
+
+# Patched by YAFFS
+source "fs/yaffs2/Kconfig"
+
config JFFS2_FS
tristate "Journalling Flash File System v2 (JFFS2) support"
select CRC32
c.
[root@localhost fs_yaffs2]# cp yaffs2/ /opt/STM/STLinux-2.3/devkit/sources/kernel/linux-sh4/fs/
2. 编译内核,制作vmlinux.ub
make kernel MENUCONFIG=1
在 Device Drivers --->Memory Technology Device (MTD) support --->NAND Device Support ---> 中,选中:
<*> STMicroelectronics: EMI 'bit-banging'
<*> STMicroelectronics: H/W FLEX Controller
然后编译,制作vmlinux.ub.
3.通过NFS启动系统,进入系统,登入:root
a. 查看内核分区情况:cat /proc/mtd.
dev: size erasesize name
mtd0: 04000000 00020000 "yaffs2-nand0"
mtd1: 3bd00000 00020000 "RestOfNand0"
//可见有两个分区, mtd0和mtd1
b. 擦除mtd1:
root@wtCAB7167:/# flash_eraseall /dev/mtd1
Erasing 128 Kibyte @ 3fe0000 -- 99 % complete.
c. 烧写文件系统到mtd1。
root@wtCAB7167:/# nandwrite -a -o /dev/mtd1 /yaffs2fs_app.yaffs2
这样文件系统就烧写进mtdblock1中了。
4. 设置启动参数,bootargs:
setenv a1 console=ttyAS0,115200 nwhwconf=device:eth0,hwaddr:00:80:E1:12:06:57 stmmaceth=msglvl:0,phyaddr:1,watchdog:5000 ide0=noprobe root=/dev/mtdblock1 rootfstype=yaffs2 rw
setenv a2 ip=192.168.1.173::192.168.1.1:255.255.255.0:wtCAB7167yaffs2:eth0:off bigphysarea=2000
setenv a3 mtdparts=stm-nand-flex.0:64M@0x300000(yaffs2-nand0),-(RestOfNand0)
setenv bootargs ${a1}${a2}${a3}
setenv bootcmd nand read 0x80000000 0x100000 0x300000\;bootm 0x80000000
这样就可以启动了。