Linux-2.6.32.2内核在mini2440上的移植(二)---yaffs2文件系统移植

来源:互联网 发布:flash player修复软件 编辑:程序博客网 时间:2024/04/26 00:13

移植环境(红色粗字体字修改后内容,蓝色粗体字为特别注意内容)

1,主机环境:VMare下CentOS 5.5 ,1G内存。

2,集成开发环境:Elipse IDE

3,编译编译环境:arm-linux-gcc v4.4.3,arm-none-linux-gnueabi-gcc v4.5.1。

4,开发板:mini2440,2M nor flash,128M nand flash。

5,u-boot版本:u-boot-2009.08

6,linux 版本:linux-2.6.32.2

7,参考文章:

【1】嵌入式linux应用开发完全手册,韦东山,编著。

【2】http://blogold.chinaunix.net/u3/101649/showart_2276906.html

 【3】Mini2440 之Linux 移植开发实战指南

2.1, yaffs2文件系统移植

【1】获取yaffs2 源代码

现在大部分开发板都可以支持 yaffs2 文件系统,它是专门针对嵌入式设备,特别是使用nand flash 作为存储器的嵌入式设备而创建的一种文件系统,早先的yaffs 仅支持小页(512byte/page)的nand flash,现在的开发板大都配备了更大容量的nand flash,它们一般是大页模式的(2K/page),使用yaffs2 就可以支持大页的nand flash,下面是yaffs2 的移植详细步骤。
http://www.yaffs.net/node/346 可以下载到最新的yaffs2 源代码,需要使用git工具( 安装方法见Git版本控制软件安装与使用),在命令行输入:
[root@localhost ~]# cd ./linux-test
[root@localhost linux-test]# git clone git://www.aleph1.co.uk/yaffs2
Cloning 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, done.
Resolving deltas: 100% (5237/5237), done.
[root@localhost linux-test]# ls
linux-2.6.32.2  linux-2.6.39  yaffs2
[root@localhost linux-test]#
片刻时间之后,可以看到下载的最新的yaffs2 的源代码目录。

【2】为内核打上yaffs2 补丁

(1)将yaffs2代码加入内核

这可以通过yaffs2目录下的脚本文件patch-ker.sh来给内核打补丁,用法如下:

usage: ./patch-ker.sh c/l kernelpath

if c/l is c, then copy. if l then link.

这表明,如果c/l是c,则yaffs2的代码会被复制到内核目录下,如果是l,则在内核的目录下创建一些链接文件。这里yaff2所在的目录/root/linux-test/,和linux-2.6.32.2在同一个目录下,执行如下命令打补丁:

[root@localhost yaffs2]# ./patch-ker.sh c /root/linux-test/linux-2.6.32.2
usage:  ./patch-ker.sh  c/l m/s kernelpath
 if c/l is c, then copy. If l then link
 if m/s is m, then use multi version code. If s then use single version code
[root@localhost yaffs2]# ./patch-ker.sh c s /root/linux-test/linux-2.6.32.2

*** Warning ***
You have chosen to use the single kernel variant of the yaffs VFS glue code
that only works with the latest Linux kernel tree. If you are using an older
version of Linux then you probably wanted to use the multi-version variant by
re-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.2

Updating /root/linux-test/linux-2.6.32.2/fs/Kconfig
Updating /root/linux-test/linux-2.6.32.2/fs/Makefile
[root@localhost yaffs2]#

注意第二个参数m/s,如果不指定,有时会执行失败。

上述命令完成下面三件事:

<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)           += gfs2/
obj-$(CONFIG_EXOFS_FS)          += exofs/
obj-$(CONFIG_YAFFS_FS)  += yaffs2/

<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字节nand flash,需要选中这个选项。

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

Linux-2.6.32.2内核在mini2440上的移植(二)---yaffs2文件系统移植 - singleboy - singleboy的博客

 按回车进入该子菜单,再找到“Miscellaneous filesystems”菜单项,如图

Linux-2.6.32.2内核在mini2440上的移植(二)---yaffs2文件系统移植 - singleboy - singleboy的博客

 按回车进入该子菜单,找到“YAFFS2 file system support”,如图

Linux-2.6.32.2内核在mini2440上的移植(二)---yaffs2文件系统移植 - singleboy - singleboy的博客

 按空格选中它,这样我们就在内核中添加了yaffs2 文件系统的支持,按“Exit”退出内核配置。最好选中“Yes”保存。

2.2,编译测试

修改完成之后,因为内核中已经增加要编译的模块,所以要先执行:

[root@localhost linux-2.6.32.2]# make clean

不然可能编译出错,然后进行编译:

[root@localhost linux-2.6.32.2]# make uImage
编译完成后,生成zImage文件,然后给开发板上电,启动u-boot,操作如下:

[u-boot@MINI2440]# tftp 31000000 uImage
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 10.1.0.128; our IP address is 10.1.0.129
Filename 'uImage'.
Load address: 0x31000000
Loading: #################################################################
         #################################################################
         ##############
done
Bytes transferred = 2110688 (2034e0 hex)
[u-boot@MINI2440]# bootm
## Booting kernel from Legacy Image at 31000000 ...
   Image Name:   Linux-2.6.32.2
   Created:      2011-05-27   4:56:08 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2110624 Bytes =  2 MB
   Load Address: 30008000
   Entry Point:  30008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux.............................................................
...................................................................... done, boo
ting the kernel.
Linux version 2.6.32.2 (root@localhost.localdomain) (gcc version 4.4.3 (ctng-1.6
.1) ) #8 Fri May 27 12:55:46 CST 2011

... ...

S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-bit)
Scanning device for bad blocks
Creating 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 "NAND 128MiB 3,3V 8-bit"
-- size truncated to 0x7aa0000
ftl_cs: FTL header not found.
0x000000000000-0x000040000000 : "nand"
mtd: partition "nand" extends beyond the end of device "NAND 128MiB 3,3V 8-bit"
-- size truncated to 0x8000000
uncorrectable error :
dm9000 Ethernet Driver, V1.31

上面出现还出现“ftl_cs: FTL header not found.”原来应在配置菜单->Device Drivers ->Memory Technology Devices (MTD),如图

Linux-2.6.32.2内核在mini2440上的移植(二)---yaffs2文件系统移植 - singleboy - singleboy的博客

按空格键取消选择,然后选“Exit”退出,最后出现保存提示时选择“Yes”保存。然后在终端中执行:

[root@localhost linux-2.6.32.2]# make clean

然后执行

[root@localhost linux-2.6.32.2]# make uImage

编译完成后在u-boot中下载、运行:

[u-boot@MINI2440]# tftp 31000000 uImage
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 10.1.0.128; our IP address is 10.1.0.129
Filename 'uImage'.
Load address: 0x31000000
Loading: #################################################################
         #################################################################
         ##############
done
Bytes transferred = 2110688 (2034e0 hex)
[u-boot@MINI2440]# bootm
 ... ...

S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-bit)
Scanning device for bad blocks
Creating 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.”信息没有了。但还是看到下面信息:

VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "nfs" or unknown-block(2,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00             256 mtdblock0 (driver?)
1f01             128 mtdblock1 (driver?)
1f02            5120 mtdblock2 (driver?)
1f03          125568 mtdblock3 (driver?)
1f04          131072 mtdblock4 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
这是因为内核引导参数设置问题,在u-boot命令行执行

[u-boot@MINI2440]# printenv
bootargs=noinitrd console=ttySAC0,115200  init=/linuxrc root=/dev/mtdblock3 rw r
ootfstype=yaffs ip=10.1.0.129:10.1.0.128:10.1.0.1:255.255.255.0::eth0:off
bootcmd=nand read 0x30008000 0x80000 0x300000;bootm 0x30008000
bootdelay=3
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
ipaddr=10.1.0.129
serverip=10.1.0.128
gatewayip=10.1.0.1
netmask=255.255.255.0
stdin=serial
stdout=serial
stderr=serial
ethact=dm9000

Environment size: 405/131068 bytes
[u-boot@MINI2440]#

确认上面蓝色粗体字部分设置正确,再次执行

[u-boot@MINI2440]# tftp 31000000 uImage

[u-boot@MINI2440]# bootm
... ...

ALSA device list:
  No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
IP-Config: Device `eth0' not found.
yaffs: dev is 32505859 name is "mtdblock3" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 132K
Warning: unable to open an initial console.
Failed to execute /linuxrc.  Attempting defaults...

可以看到yaffs文件系统加载成功。但是又遇到“Warning: unable to open an initial console.”这个主要是因为现在还没有建立根问系统,内核找不到字符设备的挂载点。不过为了减少对nand flash的写操作次数,需要在nfs文件系统上测试内核。

接下来,将为内核移植dm9000网卡驱动。

原创粉丝点击