1.获得yaffs
先安装git命令:
sudo apt-get install git
获得yaffs2命令:
git clone git://www.aleph1.co.uk/yaffs2
进入yaffs2目录,阅读README,按说明对linux3.17内核打补丁。
配置内核支持YAFFS2后,make uImage
编译出错,yaffs_flush_file函数参数多出了一个
在这里我改用其他版本的yaffs
2.下载其他版本yaffs
用linux虚拟机的浏览器搜(用WINDOWS下载的不知道为什么压缩包是gitwab.gz,知道的留言谢谢)
http://www.aleph1.co.uk/gitweb?p=yaffs2.git;a=shortlog
点击:snapshot
下载下面这个版本。
2014-06-18 Charles Manning Update to support Linux 3.14/3.15 commit | commitdiff | tree | snapshot
tar xvzf yaffs2-4e188b0.tar.gz
3.按README中的命令重新对内核打补丁
4.查看yaffs代码,发现LINUX_VERSION_CODE和KERNEL_VERSION在新版内核中没有定义!!
在这里我们自己在include/linux目录下新建一个文件version.h
代码是
#define LINUX_VERSION_CODE 200962
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
5.在linux目录下make uImage,出错:yaffs_vfs.c文件中,在yaffs_file_operations初始化中没有
generic_file_aio_read,generic_file_aio_write,generic_file_splice_write,
在这里可以知道新版内核已经没有这些函数了,参考fs目录下的其他文件的file_operations结构体,
将以上三个函数分别改为new_sync_read,new_sync_write,iter_file_splice_write
重新make uImage,在板子上烧写可以用的yaffs2文件系统,烧写修改好的内核,启动内核
系统崩溃!!!!信息如下:
yaffs: dev is 32505859 name is "mtdblock3" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs2 filesystem) on device 31:3.
Freeing unused kernel memory: 176K (c0609000 - c0635000)
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0104000
[00000000] *pgd=00000000
Internal error: Oops: 80000005 [#1] ARM
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 3.17.2 #7
task: c3827b20 ti: c3828000 task.ti: c3828000
PC is at 0x0
LR is at do_sync_read+0x84/0xb0
pc : [<00000000>] lr : [] psr: a0000013
sp : c3829ec0 ip : c04d8d20 fp : c06403b0
r10: c0640440 r9 : c3a0cda0 r8 : c39e8558
r7 : c3829f40 r6 : c3829ec8 r5 : c3829f40 r4 : 00000000
r3 : 00000000 r2 : 00000001 r1 : c3829f00 r0 : c3829ec8
Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: c000717f Table: 30104000 DAC: 00000017
Process swapper (pid: 1, stack limit = 0xc38281c0)
Stack: (0xc3829ec0 to 0xc382a000)
9ec0: 00000000 00000000 c3979660 00000000 00000000 00000000 c3827b20 00000000
9ee0: 00000000 00000000 00000000 00000000 00000080 00000000 00000000 00000000
9f00: c3b59d00 00000080 c3b59d00 00000080 c3979660 c019c2b0 0000003f 00000000
9f20: 00000000 c3829f40 00000000 c3978000 c3b59d00 c39e8558 c0640440 c01a0be4
9f40: 00000000 00000000 c3a0cda0 c3b59d00 000081ed c01a0cd0 c3b59d00 00000080
9f60: c3978000 00000002 c3828000 c01a1028 00000008 c3a0cdd4 c3827ce4 00000000
9f80: 00000000 c066e2c0 c04c58a8 00000000 00000000 00000000 00000000 00000000
9fa0: 00000000 c04c590c 00000000 c0109810 00000000 00000000 00000000 00000000
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 33cc33cc 32c433cc
[] (do_sync_read) from [] (vfs_read+0xac/0x154)
[] (vfs_read) from [] (kernel_read+0x48/0x80)
[] (kernel_read) from [] (prepare_binprm+0xb4/0x110)
[] (prepare_binprm) from [] (do_execve+0x2fc/0x4a8)
[] (do_execve) from [] (kernel_init+0x64/0xec)
[] (kernel_init) from [] (ret_from_fork+0x14/0x24)
Code: bad PC value
---[ end trace 790e079d867b2081 ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
可以看出在do_sync_read函数中出的问题,查看yaffs2代码,
static const struct file_operations yaffs_file_operations = {
.read = do_sync_read,
.write = do_sync_write,
查看新版内核fs目录下其他文件是怎么调用的,发现在ext3中
const struct file_operations ext3_file_operations = {
.llseek = generic_file_llseek,
.read = new_sync_read,
.write = new_sync_write,
.read_iter = generic_file_read_iter,
.write_iter = generic_file_write_iter,
.unlocked_ioctl = ext3_ioctl,
可见新版内核应该用new_sync_read和new_sync_write修改后的yaffs_file_operations如下:
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22))
static const struct file_operations yaffs_file_operations = {
//.read = do_sync_read,
//.write = do_sync_write,
.read = new_sync_read,
.write = new_sync_write, //pan
//.aio_read = generic_file_aio_read,
//.aio_write = generic_file_aio_write,
.read_iter = generic_file_read_iter,
.write_iter = generic_file_write_iter, //pan
.mmap = generic_file_mmap,
.flush = yaffs_file_flush,
.fsync = yaffs_sync_object,
.splice_read = generic_file_splice_read,
//.splice_write = generic_file_splice_write,
.splice_write = iter_file_splice_write, //pan
.llseek = generic_file_llseek,
};
修改完重新编译烧写,启动内核,可以挂载上yaffs2文件系统了