Linux-2.6.32内核在mini2440上的移植 yaffs2文件系统移植
(2013-03-29 20:45:05)转载▼移植环境(红色粗字体字为修改后内容,蓝色粗体字为特别注意内容)
1.
【1】获取yaffs2 源代码
现在大部分开发板都可以支持 yaffs2 文件系统,它是专门针对嵌入式设备,特别是使用nandflash 作为存储器的嵌入式设备而创建的一种文件系统,早先的yaffs 仅支持小页(512byte/page)的nandflash,现在的开发板大都配备了更大容量的nandflash,它们一般是大页模式的(2K/page),使用yaffs2 就可以支持大页的nandflash,下面是yaffs2 的移植详细步骤。
在
[root@localhost ~]# cd ./linux-test
[root@localhost linux-test]#
Cloning intoyaffs2...
remote: Counting objects: 6592, done.
remote: Compressing objects: 100% (3881/3881), done.
remote: Total 6592 (delta 5237), reused 3396 (delta 2642)
Receiving objects: 100% (6592/6592), 3.34 MiB | 166 KiB/s,done.
Resolving deltas: 100% (5237/5237), done.
[root@localhost linux-test]# ls
linux-2.6.32.2
[root@localhostlinux-test]#
片刻时间之后,可以看到下载的最新的yaffs2 的源代码目录。
【2】为内核打上yaffs2 补丁
(1)将yaffs2代码加入内核
这可以通过yaffs2目录下的脚本文件patch-ker.sh来给内核打补丁,用法如下:
[root@localhost yaffs2]# ./patch-ker.sh c/root/linux-test/linux-2.6.32.2
usage:
注意第二个参数m/s,要特别注意如果不是最新的linux内核就要使用参数m而不是s,否则内核编译时就会发生错误。所以我在这里强烈建议用m。可能产生的YAFFS2文件错误如下:
fs/yaffs2/yaffs_vfs.c:66:26: error:yaffs_mtdif1.h: No such file or directory
fs/yaffs2/yaffs_vfs.c:67:26: error:yaffs_mtdif2.h: No such file or directory
fs/yaffs2/yaffs_vfs.c: In function'yaffs_link':
fs/yaffs2/yaffs_vfs.c:309: error: implicitdeclaration of function 'set_nlink'
fs/yaffs2/yaffs_vfs.c: In function'yaffs_setattr':
fs/yaffs2/yaffs_vfs.c:527: error: implicitdeclaration of function 'setattr_copy'
fs/yaffs2/yaffs_vfs.c:530: error: implicitdeclaration of function 'truncate_setsize'
fs/yaffs2/yaffs_vfs.c: At toplevel:
fs/yaffs2/yaffs_vfs.c:876: warning: initializationfrom incompatible pointer type
fs/yaffs2/yaffs_vfs.c:907: warning: initializationfrom incompatible pointer type
fs/yaffs2/yaffs_vfs.c: In function'yaffs_evict_inode':
fs/yaffs2/yaffs_vfs.c:1067: error: implicitdeclaration of function 'end_writeback'
fs/yaffs2/yaffs_vfs.c: In function'yaffs_put_super':
fs/yaffs2/yaffs_vfs.c:1929: error: 'structyaffs_linux_context' has no member named'put_super_fn'
fs/yaffs2/yaffs_vfs.c:1930: error: 'structyaffs_linux_context' has no member named'put_super_fn'
fs/yaffs2/yaffs_vfs.c: At toplevel:
fs/yaffs2/yaffs_vfs.c:1958: error: unknown field'evict_inode' specified in initializer
fs/yaffs2/yaffs_vfs.c:1958: warning:initialization from incompatible pointer type
fs/yaffs2/yaffs_vfs.c: In function'yaffs_internal_read_super':
fs/yaffs2/yaffs_vfs.c:2187: error: 'structyaffs_param' has no member named'write_chunk_tags_fn'
fs/yaffs2/yaffs_vfs.c:2187: error:'nandmtd2_write_chunk_tags' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c:2187: error: (Eachundeclared identifier is reported only once
fs/yaffs2/yaffs_vfs.c:2187: error: for eachfunction it appears in.)
fs/yaffs2/yaffs_vfs.c:2188: error: 'structyaffs_param' has no member named'read_chunk_tags_fn'
fs/yaffs2/yaffs_vfs.c:2188: error:'nandmtd2_read_chunk_tags' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c:2189: error: 'structyaffs_param' has no member named 'bad_block_fn'
fs/yaffs2/yaffs_vfs.c:2189: error:'nandmtd2_mark_block_bad' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c:2190: error: 'structyaffs_param' has no member named 'query_block_fn'
fs/yaffs2/yaffs_vfs.c:2190: error:'nandmtd2_query_block' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c:2202: error: 'structyaffs_param' has no member named'write_chunk_tags_fn'
fs/yaffs2/yaffs_vfs.c:2202: error:'nandmtd1_write_chunk_tags' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c:2203: error: 'structyaffs_param' has no member named'read_chunk_tags_fn'
fs/yaffs2/yaffs_vfs.c:2203: error:'nandmtd1_read_chunk_tags' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c:2204: error: 'structyaffs_param' has no member named 'bad_block_fn'
fs/yaffs2/yaffs_vfs.c:2204: error:'nandmtd1_mark_block_bad' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c:2205: error: 'structyaffs_param' has no member named 'query_block_fn'
fs/yaffs2/yaffs_vfs.c:2205: error:'nandmtd1_query_block' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c:2209: error: 'structyaffs_param' has no member named 'erase_fn'
fs/yaffs2/yaffs_vfs.c:2209: error:'nandmtd_erase_block' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c:2210: error: 'structyaffs_param' has no member named'initialise_flash_fn'
fs/yaffs2/yaffs_vfs.c:2210: error:'nandmtd_initialise' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c:2212: error: 'structyaffs_linux_context' has no member named'put_super_fn'
fs/yaffs2/yaffs_vfs.c:2212: error:'yaffs_mtd_put_super' undeclared (first use in thisfunction)
fs/yaffs2/yaffs_vfs.c: In function'yaffs_mount':
fs/yaffs2/yaffs_vfs.c:2307: error: implicitdeclaration of function 'mount_bdev'
fs/yaffs2/yaffs_vfs.c:2308: warning: return makespointer from integer without a cast
fs/yaffs2/yaffs_vfs.c: At toplevel:
fs/yaffs2/yaffs_vfs.c:2314: error: unknown field'mount' specified in initializer
fs/yaffs2/yaffs_vfs.c:2314: warning:initialization makes integer from pointer without acast
fs/yaffs2/yaffs_vfs.c: In function'yaffs2_mount':
fs/yaffs2/yaffs_vfs.c:2329: warning: return makespointer from integer without a cast
fs/yaffs2/yaffs_vfs.c: At toplevel:
fs/yaffs2/yaffs_vfs.c:2335: error: unknown field'mount' specified in initializer
fs/yaffs2/yaffs_vfs.c:2335: warning:initialization makes integer from pointer without acast
make[2]: *** [fs/yaffs2/yaffs_vfs.o]错误 1
make[1]: *** [fs/yaffs2]错误 2
make: *** [fs] 错误 2
Updating/root/linux-test/linux-2.6.32.2/fs/Kconfig
Updating /root/linux-test/linux-2.6.32.2/fs/Makefile
上述命令完成下面三件事:
<1>修改内核文件/fs/Kconfig,增加下面两行(在177行附近):
if MISC_FILESYSTEMS
source "fs/adfs/Kconfig"
source "fs/affs/Kconfig"
source "fs/ecryptfs/Kconfig"
source "fs/hfs/Kconfig"
source "fs/hfsplus/Kconfig"
source "fs/befs/Kconfig"
source "fs/bfs/Kconfig"
source "fs/efs/Kconfig"
source"fs/yaffs2/Kconfig"
source "fs/jffs2/Kconfig"
# UBIFS File system configuration
<2>修改内核文件/fs/Makefile,增加下面两行(在129行附近):
obj-$(CONFIG_GFS2_FS)
obj-$(CONFIG_EXOFS_FS)
obj-$(CONFIG_YAFFS_FS)
<3>在内核文件的fs目录下创建yaffs2子目录,然后复制如下文件:
将yaffs2源码目录下的Makefile.kernel文件复制为内核fs/yaffs2/Makefile文件。
将yaffs2源码目录下的Kconfig文件复制为内核fs/yaffs2/目录下。
将yaffs2源码目录下的*.c、*.h文件(不包括子目录下的文件)复制为内核fs/yaffs2/目录下。
(2)配置内核选项
阅读内核fs/Kconfig文件可以了解各配置选项的作用。
以下是用到的几个选项:
<1>CONFIG_YAFFS_FS:支持yaffs文件系统。
<2>CONFIG_YAFFS_YAFFS2:支持yaffs2文件系统,对于每页大小为2k字节nandflash,需要选中这个选项。
<3>CONFIG_YAFFS_AUTO_YAFFS2:自动选择yaffs2文件格式,如果不配置这个选项,必须使用yaffs2字样来表示yaffs2文件系统格式,如果配置这个选项,则可以使用yaffs字样来统一表示yaffs1和yaffs2文件系统格式,驱动程序会根据nandflash的页大小自动分辨是yaffs1还是yaffs2。
2.修改内核
(1)修改顶层Makefile
[root@localhost linux-2.6.32]# viMakefile
加上我们的编译环境
(2)在arch/arm/mach-s3c2440/mach-smdk2440.c中做如下修改:
修改前 s3c24xx_init_clocks(16934400);
修改后s3c24xx_init_clocks(12000000);
3.修改分区
本实验将NANDflash划分为三个分区,前2MB用于存放内核,接下来8MB用来存放JFFS2文件系统,剩下来的用来存放YAFFS2文件系统。
[root@localhost linux-2.6.32]# viarch/arm/plat-s3c24xx/common-smdk.c
static struct mtd_partitionsmdk_default_nand_part[] = {
};
4.机器码的确定