今天开始移植yaffs到linux2.6
1)首先选择的突破口是为u-boot增加nand write.yaffs命令,按照《嵌入式Linux应用开发完全手册(韦东山)》上的教程完成对u-boot的修改,编译后,write.yaffs指令报错,无奈,放弃。
2)给2.6.26内核添加yaffs2驱动,发现没有编译进内核,用里面的Makefile.kernel替换Makefile,编译内核时发生错误。网上指出新版的内核与yaffs2文件有冲突,有patch,未找到,暂缓,放弃。
3)转换到2.6.14.1内核,编译yaffs驱动,顺利通过。因为前天移植了u-boot-1.3.1,放弃了u-boot旧式的nand_legacy,采用linux mtd 的标准ecc算法,因此现在2.6.14.1内核也可以打开NAND_ECC_SOFT。
启动信息:
yaffs Sep 3 2008 19:54:24 Installing.
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
VFS: Mounted root (yaffs filesystem) readonly.
mount_devfs_fs(): unable to mount devfs, err: -2
Freeing init memory: 112K
Warning: unable to open an initial console.
Failed to execute /linuxrc. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
当然有错误,因为还没有烧入yaffs文件系统。
4)采用NFS加载文件系统可以看到:
/cat /proc/filesystems
nodev sysfs
nodev rootfs
nodev bdev
nodev proc
nodev sockfs
nodev usbfs
nodev pipefs
nodev futexfs
nodev tmpfs
nodev inotifyfs
nodev eventpollfs
nodev devpts
cramfs
nodev ramfs
msdos
vfat
nodev nfs
ntfs
romfs
yaffs
yaffs2
nodev rpc_pipefs
系统的确支持yaffs
5)mount yaffs分区
/dev # mount -t yaffs /dev/mtdblock2 /mnt
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
block 2537 is bad
/dev #
貌似出错了,不过mount上了,里面有一个lost-found目录
网上说首要先对分区mkyaffs经行格式化
6)以前收集的资料中找到一个mkyaffs
拷贝到bin目录(现在还是NFS挂载的)
执行命令chmod +x mkyaffs,增加 mkyaffs 的可执行属性
执行:
mkyaffs /dev/mtdblock2
报错:
argc 2 sh 0 optcnt 1
MEMGETINFO: Inappropriate ioctl for device
找到一篇资料说必须要使用mkyaffs来初始化字符设备,既设备号为90的。
执行:
mkyaffs /dev/mtd2
还是同样的错误
argc 2 sh 0 optcnt 1
MEMGETINFO: Inappropriate ioctl for device
7)无法格式化yaffs分区,接近崩溃边缘ToT
这时发现挂载的/mnt分区可以读写,尝试下赋值文件系统里面的所有东西到/nfs目录,用go命令加载zimage(因为我uimage默认加载NFS分区),竟然启动起来了!
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
block 2537 is bad
VFS: Mounted root (yaffs filesystem) readonly.
Freeing init memory: 108K
init started: BusyBox v1.9.2 (2008-08-15 10:15:54 CST)
starting pid 712, tty '': '/etc/init.d/rcS'
----------mount all
mount: mounting none on /tmp failed: No such file or directory
----------Starting mdev......
*********************************************************
Rootfs(nfs) 2008.9
*********************************************************
set ip=192.168.0.12
starting pid 719, tty '': '/bin/sh'
id: unknown user name: 鈥搖n
-/bin/sh: W]$: not found
/ #
/ #
/ # ls
bin etc lib lost+found sbin usr
dev home linuxrc proc sys
/ # mkdir tmp
mkdir: cannot create directory 'tmp': Read-only file system
但怎么是只读的?
8)修改u-boot启动参数,改变bootargs后用uimage成功启动为可读写的yaffs!
bootargs=noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0 rootfstype=yaffs
启动输出:
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
block 2537 is bad
VFS: Mounted root (yaffs filesystem).
Freeing init memory: 108K
init started: BusyBox v1.9.2 (2008-08-15 10:15:54 CST)
starting pid 710, tty '': '/etc/init.d/rcS'
----------mount all
----------Starting mdev......
*********************************************************
Rootfs(nfs) 2008.9
*********************************************************
set ip=192.168.0.12
starting pid 717, tty '': '/bin/sh'
id: unknown user name: 鈥搖n
-/bin/sh: W]$: not found
/ #
/ #
/ # ls
bin etc lib lost+found sbin tmp
dev home linuxrc proc sys usr
/ # mkdir var
/ # ls
bin home lost+found sys var
dev lib proc tmp
etc linuxrc sbin usr
/ #