原文网址:http://blog.chinaunix.net/uid-29589379-id-4708911.html
一,内核移植步骤:
1, 修改顶层目录下的Makefile
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
修改为:
ARCH :=arm
CROSS_COMPILE :=/usr/local/arm/4.4.3/bin/arm-linux-
2, 拷贝配置文件
这里用的是FS2410开发板,拷贝相应的板文件到顶层目录下
cp arch/arm/configs/s3c2410_defconfig ./
编译配置文件,生成.config文件:
Make s3c2410_defconfig
内核配置的目的:
.config文件记录了哪些部分会被编译进内核,哪些部分会被编译成内核模块,内核在编译前,寻找.config文件,作为他编译的准则。即.config文件是给Makefile来读
3,1)选择板子
在arch/arm/mach-s3c2410/Kconfig中,修改相应的配置
[email protected]# vim Kconfig
[email protected]# pwd
/change/linux-3.1.4/arch/arm/mach-s3c2410
config ARCH_SMDK2410
bool "SMDK2410/A9M2410"
select CPU_S3C2410
select MACH_SMDK
help
Say Y here if you are using the SMDK2410 or the derived module A9M2410
http://www.fsforth.de
改成:
config ARCH_SMDK2410
bool "SMDK2410"
select CPU_S3C2410
select MACH_SMDK
select S3C_DEV_USB_HOST
select S3C_DEV_NAND
select S3C2410_SETUP_TS
help
Say Y here if you are using the SMDK2410 or the derived module A9M2410
2)选配资源,这里用的是fs2410开发板,可以在/arch/arm/kconfig中选配
if ARCH_S3C2410
#source "arch/arm/mach-s3c2400/Kconfig"
s3c2410目标板:
source "arch/arm/mach-s3c2410/Kconfig"
#A8目标板:
#source "arch/arm/mach-s5pc100/Kconfig"
#source "arch/arm/mach-s3c2412/Kconfig"
#source "arch/arm/mach-s3c2416/Kconfig"
#source "arch/arm/mach-s3c2440/Kconfig"
#source "arch/arm/mach-s3c2443/Kconfig"
endif
4, 内核配置
1) General setup --->
[*] Prompt for development and/or incomplete code/drivers(可选)
[*] Automatically append version information to the version string│
Kernel compression mode (Gzip) --->
2)[*] Enable loadable module support --->
[*] Forced module loading
[*] Module unloading
[*] Forced module unloading
[*] Module versioning support
3)System Type --->(选板子)
S3C2410 Machines --->
[*] SMDK2410/A9M2410(只选择此项)
[ ] IPAQ H1940(选择后下载地址会在31008000)
4)Kernel Features --->
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTAL
[*] Provide old way to pass kernel parameters
5)Userspace binary formats --->
[*] Kernel support for ELF binaries
[*] Write ELF core dumps with partial segments
< > Kernel support for a.out and ECOFF binaries(此项不选,选择后会报某些错)
6)Networking support
Networking options --->
[*] TCP/IP networking
……
7)Device Drivers ---> (设备驱动,根据需要添加修改,如网卡,led,lcd,beep等)
[*] Network device support --->(网卡设备支持)
Character devices ---> (字符设备支持,如:led,lcd)
<*> Multimedia support --->(多媒体支持,如:V4L2)
[*] USB support --->(USB支持)
8)File systems --->(文件系统,支持yaffs2,crmfs等)
[*] Network File Systems --->(网络文件系统)
<*> NFS client support
[*] Root file system on NFS
5, 内核编译并拷贝到tftpboot下
make zImage
cp arch/arm/boot/zImage /tftpboot
6, 查看内存映射表:
[email protected]# vim System.map
从内存映射表中可以知道下载地址
说明:以上的相关配置是针对arm平台的基本配置。如果想实现文件共享,led,lcd驱动等,则可以在此基础上修改和添加。
二,Nand flash驱动的添加
目的:nand flash 是默认配置的,只是他的分区可以根据我们的实际情况来配置
1, 修改分区信息表
在arch/arm/plat-s3c24xx/common-smdk.c中有nand flash的分区信息,根据我们实际生产中的需要,进行一些修改:
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "uBoot",
.size = 0x40000,
.offset = 0,
},
[1] = {
.name = "kernel",
.offset = 0x40000,
.size = 0x400000,
},
[2] = {
.name = "fs",
.offset = 0x440000,
.size = 0x800000,
},
[3] = {
.name = "extern fs",
.offset = 0xc40000,
.size = 0x33c0000,
},
}
name: 代表分区名字
size: 代表flash分区大小(单位:字节)
offset: 代表flash分区的起始地址(相对于0x0的偏移)
2,在此前的基础上配置内核:
Device Drivers --->
<*> Memory Technology Device (MTD) support --->
<*> NAND Device Support --->
<*> NAND Flash support for Samsung S3C SoCs
3,编译好,移植到开发板后可以看见这样的打印信息:
Creating 4 MTD partitions on "NAND":
0x000000000000-0x000000040000 : "uB00t"
0x000000040000-0x000000440000 : "kernel"
0x000000440000-0x000000c40000 : "fs"
0x000000c40000-0x000004000000 : "extern fs"
三,网卡驱动的添加:
目的:将网卡驱动移植到linux-3.1.4内核上,使其可以通过网络nfs的方式挂载主机环境上的文件系统,从而实现linux系统的启动
在此前的内核移植的步骤上面进行以下的修改和配置:
1, 我们这里用到的网卡是cs8900。将已经下载好的网卡驱动程序cs8900.c和cs8900.h两个文件拷贝到驱动下
[email protected]# cp ……/cs8900.* drivers/net/arm
2, 修改drivers/net/arm/Kconfig 添加cs8900的配置项:
[email protected]# cd drivers/net/arm/
[email protected]# vim Kconfig
进行以下的配置(添加):
config ARM_CS8900
tristate "cs8900 support"
depends on ARM
help
support cs8900
3, 修改drivers/net/arm/Makefile 添加内核编译配置:
[email protected]# vim Makefile
添加一下的内容:
obj-$(CONFIG_ARM_CS8900) +=cs8900.o
4, 添加地址映射:
在arch/arm/plat-s3c24xx/include/plat/map.h添加宏定义:
[email protected]# vim arch/arm/mach-s3c2410/include/mach/map.h
#define S3C24XX_VA_CS8900 0xE0000000
#define S3C24XX_PA_CS8900 0x19000000
#define S3C24XX_SZ_CS8900 SZ_1M
5, 添加平台代码
在arch/arm/mach-s3c2410/mach-smdk2410.c中添加:
[email protected]# vim arch/arm/mach-s3c2410/mach-smdk2410.c
static struct map_desc smdk2410_iodesc[] __initdata = {
IODESC_ENT(CS8900)}
6, 虚拟地址到物理地址的转换:
查看arch/arm/plat-samsang/include/plat/cpu.h
[email protected]# vim arch/arm/plat-samsung/include/plat/cpu.h
#define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x,
__phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE }
7, 一点说明:在linux-3.1.4内核的网卡驱动里面加入了中断处理机制
添加:
#include <linux/interrupt.h>
将set_irq_type(dev->irq, (1<<1)||(1<<0));修改为:
irq_set_irq_type(dev->irq, (1<<1)||(1<<0));
8, 内核配置,使之支持cs8900网卡:
Device Drivers --->
[*] Network device support --->
[*] Ethernet (10 or 100Mbit) --->
<*> cs8900 support
9, 重新编译内核
make zImage
10,网卡移植好了可以再板子上面看见以下信息:
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
eth0: CS8900A rev E at 0xe0000300 irq=53, addr: 00: 0:3E:26:0A: 0
说明:上一篇文章,直接粘贴了图片,但是基本上不能看清楚,因而此篇文章就直接写的哈。