linux-2.6.14移植到S3C2440

linux-2.6.14移植到S3C2440

嵌入式开发交流群2:289195589,欢迎加入!

现在应该很少使用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的修改

ARCH		?= arm
CROSS_COMPILE	?= arm-linux-
交叉编译器的使用请参考 http://blog.csdn.net/ce123/article/details/8333421

2.修改时钟频率

linux/arch/arm/mach-s3c2410/mach-smdk2440.c
static void __init smdk2440_map_io(void)
{
	s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
	s3c24xx_init_clocks(12000000);//12M
	s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
	s3c24xx_set_board(&smdk2440_board);
}

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中增加
#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
#include <asm/arch/nand.h>

/* NAND parititon */

static struct mtd_partition smdk_default_nand_part[] = {
	[0]= {
              .name      = "Board_uboot",
              .offset     = 0x00000000,
              .size = 0x00080000,
       },
	[1]= {
              .name      = "Board_kernel",
              .offset= 0x00240000,
              .size = 0x00200000,
       },
	[2]= {
             .name      = "Board_yaffs2",
             .offset= 0x00440000,
             .size =  0x0FB40000,
       }
};
name:代表分区名字
size:代表flash分区大小(单位:字节)
offset:代表flash分区的起始地址(相对于0x0的偏移)
划分3个区,分别存放uboot, kernel和文件系统。

4.2.加入Nand Flash分区

static struct s3c2410_nand_set smdk_nand_sets[] = {
	[0] = {
		.name		= "NAND",
		.nr_chips	= 1,
		.nr_partitions	= ARRAY_SIZE(smdk_default_nand_part),
		.partitions	= smdk_default_nand_part,
	},
};
nr_partitions: 指明partition_info中定义的分区数目
partitions:分区信息表

4.3.建立Nand Flash芯片支持

static struct s3c2410_platform_nand smdk_nand_info = {
	.tacls		= 20,
	.twrph0		= 60,
	.twrph1		= 20,
	.nr_sets	= ARRAY_SIZE(smdk_nand_sets),
	.sets		= smdk_nand_sets,
};
tacls,twrph0,twrph1的意思见S3C2440的数据手册,这3个值最后会被设置到NFCONF中。
sets:支持的分区集
nr_set:分区集的个数

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

struct platform_device s3c_device_nand = {
	.name		  = "s3c2410-nand",
	.id		  = -1,
	.num_resources	  = ARRAY_SIZE(s3c_nand_resource),
	.resource	  = s3c_nand_resource,
	.dev = {
		.platform_data = &smdk_nand_info
	}
};
name:设备名称
id:有效设备编号,如果只有唯一的一个设备为-1,有多个设备从0开始计数.
num_resource:有几个寄存器区
resource:寄存器区数组首地址
dev:支持的Nand Flash设备

4.5指定启动时初始化

linux/arch/arm/mach-s3c2410/mach-smdk2440.c
static struct platform_device *smdk2440_devices[] __initdata = {
	&s3c_device_usb,
	&s3c_device_lcd,
	&s3c_device_wdt,
	&s3c_device_i2c,
	&s3c_device_iis,
	&s3c_device_nand,//增加
};

5.禁止Flash ECC校验

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

6.支持devfs

在2.6.14中已经不支持devfs了,内核配置文件中已经没有了相关的配置选择,但其代码还保留了。修改fs/Kconfig文件找到menu "Pseudo filesystems"添加如下语句:
config DEVFS_FS
	bool "/dev file system support (OBSOLETE)"
	depends on EXPERIMENTAL
	help
	  This is support for devfs, a virtual file system (like /proc) which
	  provides the file system interface to device drivers, normally found
	  in /dev. Devfs does not depend on major and minor number
	  allocations. Device drivers register entries in /dev which then
	  appear automatically, which means that the system administrator does
	  not have to create character and block special device files in the
	  /dev directory using the mknod command (or MAKEDEV script) anymore.

	  This is work in progress. If you want to use this, you *must* read
	  the material in <file:Documentation/filesystems/devfs/>, especially
	  the file README there.

	  Note that devfs no longer manages /dev/pts!  If you are using UNIX98
	  ptys, you will also need to mount the /dev/pts filesystem (devpts).

	  Note that devfs has been obsoleted by udev,
	  <http://www.kernel.org/pub/linux/utils/kernel/hotplug/>.
	  It has been stripped down to a bare minimum and is only provided for
	  legacy installations that use its naming scheme which is
	  unfortunately different from the names normal Linux installations
	  use.

	  If unsure, say N.

config DEVFS_MOUNT
	bool "Automatically mount at boot"
	depends on DEVFS_FS
	help
	  This option appears if you have CONFIG_DEVFS_FS enabled. Setting
	  this to 'Y' will make the kernel automatically mount devfs onto /dev
	  when the system is booted, before the init thread is started.
	  You can override this with the "devfs=nomount" boot option.

	  If unsure, say N.

config DEVFS_DEBUG
	bool "Debug devfs"
	depends on DEVFS_FS
	help
	  If you say Y here, then the /dev file system code will generate
	  debugging messages. See the file
	  <file:Documentation/filesystems/devfs/boot-options> for more
	  details.

	  If unsure, say N.

config DEVPTS_FS_XATTR
	bool "/dev/pts Extended Attributes"
	depends on UNIX98_PTYS
	help
	  Extended attributes are name:value pairs associated with inodes by
	  the kernel or by users (see the attr(5) manual page, or visit
	  <http://acl.bestbits.at/> for details).

	  If unsure, say N.

config DEVPTS_FS_SECURITY
	bool "/dev/pts Security Labels"
	depends on DEVPTS_FS_XATTR
	help
	  Security labels support alternative access control models
	  implemented by security modules like SELinux.  This option
	  enables an extended attribute handler for file security
	  labels in the /dev/pts filesystem.

	  If you are not using a security module that requires using
	  extended attributes for file security labels, say N.

config TMPFS
	bool "Virtual memory file system support (former shm fs)"
	help
	  Tmpfs is a file system which keeps all files in virtual memory.

	  Everything in tmpfs is temporary in the sense that no files will be
	  created on your hard drive. The files live in memory and swap
	  space. If you unmount a tmpfs instance, everything stored therein is
	  lost.

	  See <file:Documentation/filesystems/tmpfs.txt> for details.

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),基本过程很相似。照着这个过程一般都能移植好一个内核,但明白这个过程背后的东西才是王道。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值