Linux26322内核在mini2440上的移植二.docx
《Linux26322内核在mini2440上的移植二.docx》由会员分享,可在线阅读,更多相关《Linux26322内核在mini2440上的移植二.docx(12页珍藏版)》请在冰豆网上搜索。
Linux26322内核在mini2440上的移植二
Linux-2.6.32.2内核在mini2440上的移植
(二)---yaffs2文件系统移植
移植环境(红色粗字体字为修改后内容,蓝色粗体字为特别注意内容)
1,主机环境:
VMare下CentOS5.5,1G内存。
2,集成开发环境:
ElipseIDE
3,编译编译环境:
arm-linux-gccv4.4.3,arm-none-linux-gnueabi-gccv4.5.1。
4,开发板:
mini2440,2Mnorflash,128Mnandflash。
5,u-boot版本:
u-boot-2009.08
6,linux版本:
linux-2.6.32.2
7,参考文章:
【1】嵌入式linux应用开发完全手册,韦东山,编著。
【2】
【3】Mini2440之Linux移植开发实战指南
2.1,yaffs2文件系统移植
【1】获取yaffs2源代码
现在大部分开发板都可以支持yaffs2文件系统,它是专门针对嵌入式设备,特别是使用nandflash作为存储器的嵌入式设备而创建的一种文件系统,早先的yaffs仅支持小页(512byte/page)的nandflash,现在的开发板大都配备了更大容量的nandflash,它们一般是大页模式的(2K/page),使用yaffs2就可以支持大页的nandflash,下面是yaffs2的移植详细步骤。
在可以下载到最新的yaffs2源代码,需要使用git工具(安装方法见Git版本控制软件安装与使用),在命令行输入:
[root@localhost~]#cd./linux-test
[root@localhostlinux-test]#gitclonegit:
//www.aleph1.co.uk/yaffs2
Cloningintoyaffs2...
remote:
Countingobjects:
6592,done.
remote:
Compressingobjects:
100%(3881/3881),done.
remote:
Total6592(delta5237),reused3396(delta2642)
Receivingobjects:
100%(6592/6592),3.34MiB|166KiB/s,done.
Resolvingdeltas:
100%(5237/5237),done.
[root@localhostlinux-test]#ls
linux-2.6.32.2linux-2.6.39yaffs2
[root@localhostlinux-test]#
片刻时间之后,可以看到下载的最新的yaffs2的源代码目录。
【2】为内核打上yaffs2补丁
(1)将yaffs2代码加入内核
这可以通过yaffs2目录下的脚本文件patch-ker.sh来给内核打补丁,用法如下:
usage:
./patch-ker.shc/lkernelpath
ifc/lisc,thencopy.iflthenlink.
这表明,如果c/l是c,则yaffs2的代码会被复制到内核目录下,如果是l,则在内核的目录下创建一些链接文件。
这里yaff2所在的目录/root/linux-test/,和linux-2.6.32.2在同一个目录下,执行如下命令打补丁:
[root@localhostyaffs2]#./patch-ker.shc/root/linux-test/linux-2.6.32.2
usage:
./patch-ker.shc/lm/skernelpath
ifc/lisc,thencopy.Iflthenlink
ifm/sism,thenusemultiversioncode.Ifsthenusesingleversioncode
[root@localhostyaffs2]#./patch-ker.shcs/root/linux-test/linux-2.6.32.2
***Warning***
YouhavechosentousethesinglekernelvariantoftheyaffsVFSgluecode
thatonlyworkswiththelatestLinuxkerneltree.Ifyouareusinganolder
versionofLinuxthenyouprobablywantedtousethemulti-versionvariantby
re-runningthepatch-ker.shscriptusingmasathesecondargument.
ie./patch-ker.shcm/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@localhostyaffs2]#
注意第二个参数m/s,如果不指定,有时会执行失败。
上述命令完成下面三件事:
<1>修改内核文件/fs/Kconfig,增加下面两行(在177行附近):
ifMISC_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"
#UBIFSFilesystemconfiguration
<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字节nandflash,需要选中这个选项。
<3>CONFIG_YAFFS_AUTO_YAFFS2:
自动选择yaffs2文件格式,如果不配置这个选项,必须使用yaffs2字样来表示yaffs2文件系统格式,如果配置这个选项,则可以使用yaffs字样来统一表示yaffs1和yaffs2文件系统格式,驱动程序会根据nandflash的页大小自动分辨是yaffs1还是yaffs2。
【3】配置和编译带YAFFS2支持的内核
在Linux内核源代码根目录运行:
[root@localhostlinux-test]#cdlinux-2.6.32.2
[root@localhostlinux-2.6.32.2]#makemenuconfig
移动上下按键找到FileSystems,如图
按回车进入该子菜单,再找到“Miscellaneousfilesystems”菜单项,如图
按回车进入该子菜单,找到“YAFFS2filesystemsupport”,如图
按空格选中它,这样我们就在内核中添加了yaffs2文件系统的支持,按“Exit”退出内核配置。
最好选中“Yes”保存。
2.2,编译测试
修改完成之后,因为内核中已经增加要编译的模块,所以要先执行:
[root@localhostlinux-2.6.32.2]#makeclean
不然可能编译出错,然后进行编译:
[root@localhostlinux-2.6.32.2]#makeuImage
编译完成后,生成zImage文件,然后给开发板上电,启动u-boot,操作如下:
[u-boot@MINI2440]#tftp31000000uImage
dm9000i/o:
0x20000300,id:
0x90000a46
DM9000:
runningin16bitmode
MAC:
08:
00:
3e:
26:
0a:
5b
operatingat100Mfullduplexmode
Usingdm9000device
TFTPfromserver10.1.0.128;ourIPaddressis10.1.0.129
Filename'uImage'.
Loadaddress:
0x31000000
Loading:
#################################################################
#################################################################
##############
done
Bytestransferred=2110688(2034e0hex)
[u-boot@MINI2440]#bootm
##BootingkernelfromLegacyImageat31000000...
ImageName:
Linux-2.6.32.2
Created:
2011-05-274:
56:
08UTC
ImageType:
ARMLinuxKernelImage(uncompressed)
DataSize:
2110624Bytes=2MB
LoadAddress:
30008000
EntryPoint:
30008000
VerifyingChecksum...OK
LoadingKernelImage...OK
OK
Startingkernel...
UncompressingLinux.............................................................
......................................................................done,boo
tingthekernel.
Linuxversion2.6.32.2(root@localhost.localdomain)(gccversion4.4.3(ctng-1.6
.1))#8FriMay2712:
55:
46CST2011
......
S3C24XXNANDDriver,(c)2004SimtecElectronics
s3c24xx-nands3c2440-nand:
Tacls=3,29nsTwrph0=769ns,Twrph1=329ns
s3c24xx-nands3c2440-nand:
NANDsoftECC
NANDdevice:
ManufacturerID:
0xec,ChipID:
0xf1(SamsungNAND128MiB3,3V8-bit)
Scanningdeviceforbadblocks
Creating5MTDpartitionson"NAND128MiB3,3V8-bit":
0x000000000000-0x000000040000:
"boot"
uncorrectableerror:
0x000000040000-0x000000060000:
"param"
ftl_cs:
FTLheadernotfound.
0x000000060000-0x000000560000:
"kernel"
ftl_cs:
FTLheadernotfound.
0x000000560000-0x000040560000:
"root"
mtd:
partition"root"extendsbeyondtheendofdevice"NAND128MiB3,3V8-bit"
--sizetruncatedto0x7aa0000
ftl_cs:
FTLheadernotfound.
0x000000000000-0x000040000000:
"nand"
mtd:
partition"nand"extendsbeyondtheendofdevice"NAND128MiB3,3V8-bit"
--sizetruncatedto0x8000000
uncorrectableerror:
dm9000EthernetDriver,V1.31
上面出现还出现“ftl_cs:
FTLheadernotfound.”原来应在配置菜单->DeviceDrivers->MemoryTechnologyDevices(MTD),如图
按空格键取消选择,然后选“Exit”退出,最后出现保存提示时选择“Yes”保存。
然后在终端中执行:
[root@localhostlinux-2.6.32.2]#makeclean
然后执行
[root@localhostlinux-2.6.32.2]#makeuImage
编译完成后在u-boot中下载、运行:
[u-boot@MINI2440]#tftp31000000uImage
dm9000i/o:
0x20000300,id:
0x90000a46
DM9000:
runningin16bitmode
MAC:
08:
00:
3e:
26:
0a:
5b
operatingat100Mfullduplexmode
Usingdm9000device
TFTPfromserver10.1.0.128;ourIPaddressis10.1.0.129
Filename'uImage'.
Loadaddress:
0x31000000
Loading:
#################################################################
#################################################################
##############
done
Bytestransferred=2110688(2034e0hex)
[u-boot@MINI2440]#bootm
......
S3C24XXNANDDriver,(c)2004SimtecElectronics
s3c24xx-nands3c2440-nand:
Tacls=3,29nsTwrph0=769ns,Twrph1=329ns
s3c24xx-nands3c2440-nand:
NANDsoftECC
NANDdevice:
ManufacturerID:
0xec,ChipID:
0xf1(SamsungNAND128MiB3,3V8-bit)
Scanningdeviceforbadblocks
Creating5MTDpartitionson"NAND128MiB3,3V8-bit":
0x000000000000-0x000000040000:
"boot"
0x000000040000-0x000000060000:
"param"
0x000000060000-0x000000560000:
"kernel"
0x000000560000-0x000008000000:
"rootfs"
0x000000000000-0x000008000000:
"nand"
dm9000EthernetDriver,V1.31
可以看到,前面的出现“ftl_cs:
FTLheadernotfound.”信息没有了。
但还是看到下面信息:
VFS:
UnabletomountrootfsviaNFS,tryingfloppy.
VFS:
Cannotopenrootdevice"nfs"orunknown-block(2,0)
Pleaseappendacorrect"root="bootoption;herearetheavailablepartitions:
1f00256mtdblock0(driver?
)
1f01128mtdblock1(driver?
)
1f025120mtdblock2(driver?
)
1f03125568mtdblock3(driver?
)
1f04131072mtdblock4(driver?
)
Kernelpanic-notsyncing:
VFS:
Unabletomountrootfsonunknown-block(2,0)
这是因为内核引导参数设置问题,在u-boot命令行执行
[u-boot@MINI2440]#printenv
bootargs=noinitrdconsole=ttySAC0,115200init=/linuxrcroot=/dev/mtdblock3rwr
ootfstype=yaffsip=10.1.0.129:
10.1.0.128:
10.1.0.1:
255.255.255.0:
:
eth0:
off
bootcmd=nandread0x300080000x800000x300000;bootm0x30008000
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
Environmentsize:
405/131068bytes
[u-boot@MINI2440]#
确认上面蓝色粗体字部分设置正确,再次执行
[u-boot@MINI2440]#tftp31000000uImage
[u-boot@MINI2440]#bootm
......
ALSAdevicelist:
Nosoundcardsfound.
TCPcubicregistered
NET:
Registeredprotocolfamily17
drivers/rtc/hctosys.c:
unabletoopenrtcdevice(rtc0)
IP-Config:
Device`eth0'notfound.
yaffs:
devis32505859nameis"mtdblock3"rw
yaffs:
passedflags""
VFS:
Mountedroot(yaffsfilesystem)ondevice31:
3.
Freeinginitmemory:
132K
Warning:
unabletoopenaninitialconsole.
Failedtoexecute/linuxrc.Attemptingdefaults...
可以看到yaffs文件系统加载成功。
但是又遇到“Warning:
unabletoopenaninitialconsole.”这个主要是因为现在还没有建立根问系统,内核找不到字符设备的挂载点。
不过为了减少对nandflash的写操作次数,需要在nfs文件系统上测试内核。
接下来,将为内核移植dm9000网卡驱动。