新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > linux-2.6.14移植到S3C2440

linux-2.6.14移植到S3C2440

作者:时间:2016-11-22来源:网络收藏
现在应该很少使用2.6.14的内核了,但由于项目需要,最近移植了2.6.版本的内核到S3C2440上,并移植了CS8900网卡驱动(网卡驱动移植参考http://blog.csdn.net/ce123/article/details/8424399)。之所以移植网卡驱动,是因为yaffs2格式的文件系统一直挂载不成功,启动后的错误信息如下:
Mounted devfs on /dev
Freeing init memory: 92K
Failed to execute /linuxrc. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
这个问题只能先放一下,最后成功挂载nfs。yaffs2格式文件系统的问题以后再深入研究。整理一下最近做过的东西,怕遗忘了。

1.顶层Makefile的修改

[plain]view plaincopy
print?
  1. ARCH?=arm
  2. CROSS_COMPILE?=arm-linux-
交叉编译器的使用请参考http://blog.csdn.net/ce123/article/details/8333421

2.修改时钟频率

linux/arch/arm/mach-s3c2410/mach-smdk2440.c
[plain]view plaincopy
print?
  1. staticvoid__initsmdk2440_map_io(void)
  2. {
  3. s3c24xx_init_io(smdk2440_iodesc,ARRAY_SIZE(smdk2440_iodesc));
  4. s3c24xx_init_clocks(12000000);//12M
  5. s3c24xx_init_uarts(smdk2440_uartcfgs,ARRAY_SIZE(smdk2440_uartcfgs));
  6. s3c24xx_set_board(&smdk2440_board);
  7. }

3.修改机器ID

linux/arch/arm/tools/mach-types
s3c2440 ARCH_S3C2440 S3C2440 168
这个值要和uboot中的值对应起来,在uboot的arch/arm/tools/mach-types中有如下定义:
#define MACH_TYPE_S3C2440 168
这两个值一样即可。

4.设置Nand Flash分区

4.1建立Nand Flash分区表

在linux/arch/arm/mach-s3c2410/devs.c中增加
[plain]view plaincopy
print?
  1. #include
  2. #include
  3. #include
  4. /*NANDparititon*/
  5. staticstructmtd_partitionsmdk_default_nand_part[]={
  6. [0]={
  7. .name="Board_uboot",
  8. .offset=0x00000000,
  9. .size=0x00080000,
  10. },
  11. [1]={
  12. .name="Board_kernel",
  13. .offset=0x00240000,
  14. .size=0x00200000,
  15. },
  16. [2]={
  17. .name="Board_yaffs2",
  18. .offset=0x00440000,
  19. .size=0x0FB40000,
  20. }
  21. };
name:代表分区名字
size:代表flash分区大小(单位:字节)
offset:代表flash分区的起始地址(相对于0x0的偏移)
划分3个区,分别存放uboot, kernel和文件系统。

4.2.加入Nand Flash分区

[plain]view plaincopy
print?
  1. staticstructs3c2410_nand_setsmdk_nand_sets[]={
  2. [0]={
  3. .name="NAND",
  4. .nr_chips=1,
  5. .nr_partitions=ARRAY_SIZE(smdk_default_nand_part),
  6. .partitions=smdk_default_nand_part,
  7. },
  8. };
nr_partitions: 指明partition_info中定义的分区数目
partitions:分区信息表

4.3.建立Nand Flash芯片支持

[plain]view plaincopy
print?
  1. staticstructs3c2410_platform_nandsmdk_nand_info={
  2. .tacls=20,
  3. .twrph0=60,
  4. .twrph1=20,
  5. .nr_sets=ARRAY_SIZE(smdk_nand_sets),
  6. .sets=smdk_nand_sets,
  7. };
tacls,twrph0,twrph1的意思见S3C2440的数据手册,这3个值最后会被设置到NFCONF中。
sets:支持的分区集
nr_set:分区集的个数

4.4.加入Nand Flash芯片支持到Nand Flash驱动

[plain]view plaincopy
print?
  1. structplatform_devices3c_device_nand={
  2. .name="s3c2410-nand",
  3. .id=-1,
  4. .num_resources=ARRAY_SIZE(s3c_nand_resource),
  5. .resource=s3c_nand_resource,
  6. .dev={
  7. .platform_data=&smdk_nand_info
  8. }
  9. };
name:设备名称
id:有效设备编号,如果只有唯一的一个设备为-1,有多个设备从0开始计数.
num_resource:有几个寄存器区
resource:寄存器区数组首地址
dev:支持的Nand Flash设备

4.5指定启动时初始化

linux/arch/arm/mach-s3c2410/mach-smdk2440.c
[plain]view plaincopy
print?
  1. staticstructplatform_device*smdk2440_devices[]__initdata={
  2. &s3c_device_usb,
  3. &s3c_device_lcd,
  4. &s3c_device_wdt,
  5. &s3c_device_i2c,
  6. &s3c_device_iis,
  7. &s3c_device_nand,//增加
  8. };

5.禁止Flash ECC校验

修改drivers/mtd/nand/s3c2410.c 文件s3c2410_nand_init_chip()函数,在该函数体最后加上一条语句:
[plain]view plaincopy
print?
  1. chip->eccmode=NAND_ECC_NONE;

6.支持devfs

在2.6.14中已经不支持devfs了,内核配置文件中已经没有了相关的配置选择,但其代码还保留了。修改fs/Kconfig文件找到menu "Pseudo filesystems"添加如下语句:
[plain]view plaincopy
print?
  1. configDEVFS_FS
  2. bool"/devfilesystemsupport(OBSOLETE)"
  3. dependsonEXPERIMENTAL
  4. help
  5. Thisissupportfordevfs,avirtualfilesystem(like/proc)which
  6. providesthefilesysteminterfacetodevicedrivers,normallyfound
  7. in/dev.Devfsdoesnotdependonmajorandminornumber
  8. allocations.Devicedriversregisterentriesin/devwhichthen
  9. appearautomatically,whichmeansthatthesystemadministratordoes
  10. nothavetocreatecharacterandblockspecialdevicefilesinthe
  11. /devdirectoryusingthemknodcommand(orMAKEDEVscript)anymore.
  12. Thisisworkinprogress.Ifyouwanttousethis,you*must*read
  13. thematerialin,especially
  14. thefileREADMEthere.
  15. Notethatdevfsnolongermanages/dev/pts!IfyouareusingUNIX98
  16. ptys,youwillalsoneedtomountthe/dev/ptsfilesystem(devpts).
  17. Notethatdevfshasbeenobsoletedbyudev,
  18. .
  19. Ithasbeenstrippeddowntoabareminimumandisonlyprovidedfor
  20. legacyinstallationsthatuseitsnamingschemewhichis
  21. unfortunatelydifferentfromthenamesnormalLinuxinstallations
  22. use.
  23. Ifunsure,sayN.
  24. configDEVFS_MOUNT
  25. bool"Automaticallymountatboot"
  26. dependsonDEVFS_FS
  27. help
  28. ThisoptionappearsifyouhaveCONFIG_DEVFS_FSenabled.Setting
  29. thistoYwillmakethekernelautomaticallymountdevfsonto/dev
  30. whenthesystemisbooted,beforetheinitthreadisstarted.
  31. Youcanoverridethiswiththe"devfs=nomount"bootoption.
  32. Ifunsure,sayN.
  33. configDEVFS_DEBUG
  34. bool"Debugdevfs"
  35. dependsonDEVFS_FS
  36. help
  37. IfyousayYhere,thenthe/devfilesystemcodewillgenerate
  38. debuggingmessages.Seethefile
  39. formore
  40. details.
  41. Ifunsure,sayN.
  42. configDEVPTS_FS_XATTR
  43. bool"/dev/ptsExtendedAttributes"
  44. dependsonUNIX98_PTYS
  45. help
  46. Extendedattributesarename:valuepairsassociatedwithinodesby
  47. thekernelorbyusers(seetheattr(5)manualpage,orvisit
  48. fordetails).
  49. Ifunsure,sayN.
  50. configDEVPTS_FS_SECURITY
  51. bool"/dev/ptsSecurityLabels"
  52. dependsonDEVPTS_FS_XATTR
  53. help
  54. Securitylabelssupportalternativeaccesscontrolmodels
  55. implementedbysecuritymoduleslikeSELinux.Thisoption
  56. enablesanextendedattributehandlerforfilesecurity
  57. labelsinthe/dev/ptsfilesystem.
  58. Ifyouarenotusingasecuritymodulethatrequiresusing
  59. extendedattributesforfilesecuritylabels,sayN.
  60. configTMPFS
  61. bool"Virtualmemoryfilesystemsupport(formershmfs)"
  62. help
  63. Tmpfsisafilesystemwhichkeepsallfilesinvirtualmemory.
  64. Everythingintmpfsistemporaryinthesensethatnofileswillbe
  65. createdonyourharddrive.Thefilesliveinmemoryandswap
  66. space.Ifyouunmountatmpfsinstance,everythingstoredthereinis
  67. lost.
  68. Seefordetails.

7.内核裁剪

7.1内核配置文件

将arch/arm/configs/s3c2410_defconfig .config拷到内核目录树根下:
cp arch/arm/configs/s3c2410_defconfig .config
make menuconfig 将s3c2410_defconfig 导入,在s3c2410_defconfig基础上,裁剪内核。

7.2内核选项

Loadable module support >
[*] Enable loadable module support
[*] Automatic kernel module loading

System Type >
[*] S3C2410 DMA support

Floating point emulation >
[*] NWFPE math emulation

接下来要做的是对内核MTD子系统的设置

Device Drivers >
Memory Technology Devices (MTD) >
[*] MTD partitioning support /*支持MTD分区,这样我们在前面设置的分区才有意义*/
[*] Command line partition table parsing /*支持从命令行设置flash分区信息,灵活*/
RAM/ROM/Flash chip drivers >
<*> Detect flash chips by Common Flash Interface (CFI) probe
<*> Detect nonCFI AMD/JEDECcompatible flash chips
<*> Support for Intel/Sharp flash chips
<*> Support for AMD/Fujitsu flash chips
<*> Support for ROM chips in bus mapping
NAND Flash Device Drivers >
<*> NAND Device Support
<*> NAND Flash support for S3C2410/S3C2440 SoC
Character devices >
[*] Nonstandard serial port support
[*] S3C2410 RTC Driver

接下来做的是针对文件系统的设置

File systems >
<> Second extended fs support #去除对ext2的支持
Pseudo filesystems >
[*] /proc file system support
[*] Virtual memory file system support (former shm fs)
[*] /dev file system support (OBSOLETE)
[*] Automatically mount at boot (NEW)
这里会看到我们前先修改fs/Kconfig的成果,devfs已经被支持上了
Miscellaneous filesystems >
Network File Systems >
<*> NFS file system support

7.3编译

make即可。

8.总结

以前将linux-2.6.30.4移植S3C2440(http://blog.csdn.net/ce123/article/details/6581248),基本过程很相似。照着这个过程一般都能移植好一个内核,但明白这个过程背后的东西才是王道。


评论


相关推荐

技术专区

关闭