S3C6410嵌入式应用平台构建(六)——linux-3.14.4移植到OK6410-(Yaffs2文件系统移植)
我个人觉得nandflash上用yaffs2文件系统是很好的方案,但是最新的Linux并不支持yaffs2文件系统,需要你自己给内核打补丁,不过话说在前面,由于内核间差异及兼容问题,在编译时肯定会出现各种编译问题,需要你一一的去解决。
一、准备工作
1. 下载源码
使用git工具下载:$ git clone git://www.aleph1.co.uk/yaffs2
2. 给内核打补丁
下载完成后,在该执行目录下会有yaffs2文件夹,进入该文件夹。
$ ./patch-ker.sh c m ../../kernel/test/linux-3.14.4
Updating ../../kernel/test/linux-3.14.4/fs/Kconfig
Updating ../../kernel/test/linux-3.14.4/fs/Makefile
有以上两个信息,说明已经打好补丁,并且在fs/目录下,多了yaffs2文件夹,其实这是从yaffs2文件夹中复制过来的。
二、内核配置
下面配置内核,在linux目录下make menuconfig
我们发现在File system—>Miscellaneous filesystems—>下面并找不到yaffs2选项。原来是这样的
查看YAFFS2的Kconfig文件,需要先选择MTD_BLOCK才会有显示YAFFS2
# # yaffs file system configurations # config YAFFS_FS tristate "yaffs2 file system support" default n depends on MTD_BLOCK select YAFFS_YAFFS1 select YAFFS_YAFFS2 help
也就说需要先选择Device Drivers-->MTD-->Caching block device access to MTD devices,然后才能够在File Systems--->Miscellaneous filesystem下面找到YAFFS2。
好的 ,配置完后,这下要执行make clean;make uImage了。剩下的工作就是解决一大堆编译错误了!!!!
下面看看编译的错误:
CC fs/yaffs2/yaffs_vfs.o fs/yaffs2/yaffs_vfs.c: In function 'yaffs_mknod': fs/yaffs2/yaffs_vfs.c:1228: error: incompatible types when initializing type 'uid_t' using type 'kuid_t' fs/yaffs2/yaffs_vfs.c:1230: error: incompatible types when initializing type 'gid_t' using type 'const struct <anonymous>' fs/yaffs2/yaffs_vfs.c: In function 'yaffs_symlink': fs/yaffs2/yaffs_vfs.c:1427: error: incompatible types when initializing type 'uid_t' using type 'kuid_t' fs/yaffs2/yaffs_vfs.c:1429: error: incompatible types when initializing type 'gid_t' using type 'const struct <anonymous>' fs/yaffs2/yaffs_vfs.c: At top level: fs/yaffs2/yaffs_vfs.c:1786: error: unknown field 'readdir' specified in initializer fs/yaffs2/yaffs_vfs.c:1786: warning: initialization from incompatible pointer type fs/yaffs2/yaffs_vfs.c: In function 'yaffs_fill_inode_from_obj': fs/yaffs2/yaffs_vfs.c:1832: error: incompatible types when assigning to type 'kuid_t' from type 'u32' fs/yaffs2/yaffs_vfs.c:1833: error: incompatible types when assigning to type 'kgid_t' from type 'u32' fs/yaffs2/yaffs_vfs.c:1857: warning: format '%d' expects type 'int', but argument 3 has type 'kuid_t' fs/yaffs2/yaffs_vfs.c:1857: warning: format '%d' expects type 'int', but argument 4 has type 'kgid_t' fs/yaffs2/yaffs_vfs.c: In function 'yaffs_proc_debug_write': fs/yaffs2/yaffs_vfs.c:3300: warning: comparison of distinct pointer types lacks a cast fs/yaffs2/yaffs_vfs.c: In function 'init_yaffs_fs': fs/yaffs2/yaffs_vfs.c:3394: error: implicit declaration of function 'create_proc_entry' fs/yaffs2/yaffs_vfs.c:3395: warning: assignment makes pointer from integer without a cast fs/yaffs2/yaffs_vfs.c:3398: error: dereferencing pointer to incomplete type fs/yaffs2/yaffs_vfs.c:3399: error: dereferencing pointer to incomplete type fs/yaffs2/yaffs_vfs.c:3400: error: dereferencing pointer to incomplete type make[2]: *** [fs/yaffs2/yaffs_vfs.o] Error 1 make[1]: *** [fs/yaffs2] Error 2 make: *** [fs] Error 2
1. 出现error: incompatible types when initializing type 'uid_t' using type 'kuid_t' ,应该是不兼容问题导致,修改:
uid_t改为kuid_t和gid_t 改为kgid_t
剩下的关于这个变量的问题很多,但是都是关于兼容性的,大家在修改时只需要知道只要不兼容,那我们就把所有用到的改到兼容的kuid_t为止。
这里修改的地方和文件有点多,我就不一一列出来了
2. error: implicit declaration of function 'create_proc_entry'
由于最新的内核不支持这个函数,需要注释掉并改为my_proc_entry = proc_create("yaffs",S_IRUGO | S_IFREG, YPROC_ROOT, &yaffs_fops);
最终修改如下:
mutex_init(&yaffs_context_lock); my_proc_entry = proc_create("yaffs", S_IRUGO | S_IFREG, YPROC_ROOT, &yaffs_fops); #if 0 /* Install the proc_fs entries */ my_proc_entry = create_proc_entry("yaffs", S_IRUGO | S_IFREG, YPROC_ROOT); if (my_proc_entry) { my_proc_entry->write_proc = yaffs_proc_write; my_proc_entry->read_proc = yaffs_proc_read; my_proc_entry->data = NULL; } else { return -ENOMEM; } #endif
3. error: unknown field 'readdir' specified in initializer
在init_yaffs_fs函数前添加以下代码
struct file_operations yaffs_fops = { .owner = THIS_MODULE, .read = yaffs_proc_read, .write = yaffs_proc_write, }; static int __init init_yaffs_fs(void)
修改了以上,我们就能编译通过了。目前,内核就支持yaffs2文件系统了。
下一篇文件我们来用busybox制作yaffs2文件系统。