当前位置:文档之家› 2-Linux

2-Linux

Linux-2.6.32.2内核在mini2440上的移植(二)---yaffs2文件系统移植移植环境(红色粗字体字为修改后内容,蓝色粗体字为特别注意内容) 2.1, yaffs2文件系统移植【1】获取yaffs2 源代码现在大部分开发板都可以支持yaffs2 文件系统,它是专门针对嵌入式设备,特别是使用nand flash 作为存储器的嵌入式设备而创建的一种文件系统,早先的yaffs 仅支持小页(512byte/page)的nand flash,现在的开发板大都配备了更大容量的nand flash,它们一般是大页模式的(2K/page),使用yaffs2 就可以支持大页的nand flash,下面是yaffs2 的移植详细步骤。

在/node/346可以下载到最新的yaffs2 源代码,需要使用git工具( 安装方法见Git版本控制软件安装与使用),在命令行输入:[root@localhost ~]# cd ./linux-test[root@localhost linux-test]# git clone git:///ya ffs2Cloning into yaffs2...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, d one.Resolving deltas: 100% (5237/5237), done.[root@localhost linux-test]# lslinux-2.6.32.2 linux-2.6.39 yaffs2[root@localhost linux-test]#片刻时间之后,可以看到下载的最新的yaffs2 的源代码目录。

【2】为内核打上yaffs2 补丁(1)将yaffs2代码加入内核这可以通过yaffs2目录下的脚本文件patch-ker.sh来给内核打补丁,用法如下:[root@localhost yaffs2]# ./patch-ker.sh c /root/linux-test/linux-2.6.32.2usage: ./patch-ker.sh c/l m/s kernelpathif c/l is c, then copy. If l then linkif m/s is m, then use multi version code. If s then use sing le version code[root@localhost yaffs2]# ./patch-ker.sh c s /root/linux-test/linu x-2.6.32.2*** Warning ***You have chosen to use the single kernel variant of the yaff s VFS glue codethat only works with the latest Linux kernel tree. If you are using an olderversion of Linux then you probably wanted to use the multi-version variant byre-running the patch-ker.sh script using m as a the second argument.ie ./patch-ker.sh c m /root/linux-test/linux-2.6.32.2Updating /root/linux-test/linux-2.6.32.2/fs/KconfigUpdating /root/linux-test/linux-2.6.32.2/fs/Makefile[root@localhost yaffs2]#注意第二个参数m/s,如果不指定,有时会执行失败。

上述命令完成下面三件事:<1>修改内核文件/fs/Kconfig,增加下面两行(在177行附近):if MISC_FILESYSTEMSsource "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) += gfs2/obj-$(CONFIG_EXOFS_FS) += exofs/obj-$(CONFIG_YAFFS_FS) += yaffs2/<3>在内核文件的fs目录下创建yaffs2子目录,然后复制如下文件:将yaffs2源码目录下的Makefile.kernel文件复制为内核fs/yaffs2/Ma kefile文件。

将yaffs2源码目录下的Kconfig文件复制为内核fs/yaffs2/目录下。

将yaffs2源码目录下的*.c、*.h文件(不包括子目录下的文件)复制为内核fs/yaffs2/目录下。

(2)配置内核选项阅读内核fs/Kconfig文件可以了解各配置选项的作用。

以下是用到的几个选项:<1>CONFIG_YAFFS_FS:支持yaffs文件系统。

<2>CONFIG_YAFFS_YAFFS2:支持yaffs2文件系统,对于每页大小为2k字节nand flash,需要选中这个选项。

<3>CONFIG_YAFFS_AUTO_YAFFS2:自动选择yaffs2文件格式,如果不配置这个选项,必须使用yaffs2字样来表示yaffs2文件系统格式,如果配置这个选项,则可以使用yaffs字样来统一表示yaffs1和yaffs 2文件系统格式,驱动程序会根据nand flash的页大小自动分辨是ya ffs1还是yaffs2。

【3】配置和编译带YAFFS2 支持的内核在Linux 内核源代码根目录运行:[root@localhost linux-test]# cd linux-2.6.32.2[root@localhost linux-2.6.32.2]# make menuconfig移动上下按键找到File Systems,如图按回车进入该子菜单,再找到“Miscellaneous filesystems”菜单项,如图按回车进入该子菜单,找到“YAFFS2 file system support”,如图按空格选中它,这样我们就在内核中添加了yaffs2 文件系统的支持,按“Exit”退出内核配置。

最好选中“Yes”保存。

2.2,编译测试修改完成之后,因为内核中已经增加要编译的模块,所以要先执行:[root@localhost linux-2.6.32.2]# make clean不然可能编译出错,然后进行编译:[root@localhost linux-2.6.32.2]# make zImage编译完成后,生成zImage文件,然后给开发板上电,把zImage 烧写到开发板上,显示如下:NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsun g NAND 128MiB 3,3V 8-bit)Scanning device for bad blocksCreating 5 MTD partitions on "NAND 128MiB 3,3V 8-bit":0x000000000000-0x000000040000 : "boot"uncorrectable error :0x000000040000-0x000000060000 : "param"ftl_cs: FTL header not found.0x000000060000-0x000000560000 : "kernel"ftl_cs: FTL header not found.0x000000560000-0x000040560000 : "root"mtd: partition "root" extends beyond the end of device "NA ND 128MiB 3,3V 8-bit"-- size truncated to 0x7aa0000ftl_cs: FTL header not found.0x000000000000-0x000040000000 : "nand"mtd: partition "nand" extends beyond the end of device "NA ND 128MiB 3,3V 8-bit"-- size truncated to 0x8000000uncorrectable error :dm9000 Ethernet Driver, V1.31上面出现还出现“ftl_cs: FTL header not found.”原来应在配置菜单->Device Drivers ->Memory Technology Devices (MTD),如图按空格键取消选择,然后选“Exit”退出,最后出现保存提示时选择“Ye s”保存。

然后在终端中执行:[root@localhost linux-2.6.32.2]# make clean注意:每次执行完make clean 时,在编译内核是就要花费很长时间,所以不要每次都make clean,我就背害的很苦,每次都等很长时间,以后大家可以避免了然后执行[root@localhost linux-2.6.32.2]# make zImageS3C24XX NAND Driver, (c) 2004 Simtec Electronicss3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, T wrph1=3 29nss3c24xx-nand s3c2440-nand: NAND soft ECCNAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsun g NAND 128MiB 3,3V 8-bit)Scanning device for bad blocksCreating 5 MTD partitions on "NAND 128MiB 3,3V 8-bit":0x000000000000-0x000000040000 : "boot"0x000000040000-0x000000060000 : "param"0x000000060000-0x000000560000 : "kernel"0x000000560000-0x000008000000 : "rootfs"0x000000000000-0x000008000000 : "nand"dm9000 Ethernet Driver, V1.31可以看到,前面的出现“ftl_cs: FTL header not found.”信息没有了。

相关主题