二,移植linux内核源码 ------ 内核镜像:zimage/uImage
1,获取linux内核源码
从官网下载
www.kernel.org 》内核版本linux-3.0.8.tar.bz2
2,在ubuntu中创建相应的目录
$ mkdir s5pv210
$ mkdir s5pv210/kernel
$ mkdir s5pv210/driver
3,将内核源码拷贝到 ~/s5pv210/kernel ,并解压:
~/s5pv210/kernel$ tar -xvf linux-3.0.8.tar.bz2
4,配置交叉编译器:
cd linux-3.0.8/
vim Makefile
修改下面两行:
195 ARCH ?= arm
196 CROSS_COMPILE ?= arm-none-linux-gnueabi-
5,选择平台:-----soc:s5pv210
方法一:
cp arch/arm/configs/s5pv210_defconfig .config
方法二:
make s5pv210_defconfig
6,平台(开发板)通用的配置
make menuconfig
1》选择串口:COM1
System Type —>
(0) S3C UART to use for low-level messages
2》选择网络协议支持:
[*] Networking support --->
Networking options --->
<*> Packet socket
<*> Unix domain sockets
[*] TCP/IP networking
[*] IP: kernel level autoconfiguration
3》选择支持网络文件系统
File systems --->
[*] Network File Systems (NEW) --->
<*> NFS client support
[*] NFS client support for NFS version 3
[*] NFS client support for the NFSv3 ACL protocol extension
[*] Root file system on NFS
注意:有时候执行make menuconfig,不能进入图形界面,这时有两种情况:
第一种:没有安装libncurses5-dev
sudo apt-get install libncurses5-dev
第二种:窗口太小
将窗口调整为最大
7,编译内核:
make -j2
LD [M] crypto/rng.ko
LD [M] drivers/scsi/scsi_wait_scan.ko
LD [M] net/ipv4/tunnel4.ko
LD [M] net/ipv6/ipv6.ko
LD [M] net/ipv6/sit.ko
LD [M] net/ipv6/xfrm6_mode_beet.ko
LD [M] net/ipv6/xfrm6_mode_transport.ko
LD [M] net/ipv6/xfrm6_mode_tunnel.ko
SHIPPED arch/arm/boot/compressed/lib1funcs.S
AS arch/arm/boot/compressed/piggy.gzip.o
AS arch/arm/boot/compressed/lib1funcs.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
8,将编译好的内核镜像zImage 拷贝到 /tftpboot
cp arch/arm/boot/zImage /tftpboot
9,重新配置uboot参数
FS210 # set bootcmd tftp 0x40008000 zImage ; bootm 0x40008000
FS210 # sa
10,重启开发板,结果如下:
mousedev: PS/2 mouse device common for all mice
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2
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:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
[<80032564>] (unwind_backtrace+0x0/0xf0) from [<8024c978>] (panic+0x70/0x19c)
[<8024c978>] (panic+0x70/0x19c) from [<80008de4>] (mount_block_root+0x15c/0x210)
[<80008de4>] (mount_block_root+0x15c/0x210) from [<80009030>] (mount_root+0xa8/0xc4)
[<80009030>] (mount_root+0xa8/0xc4) from [<800091b0>] (prepare_namespace+0x164/0x1bc)
[<800091b0>] (prepare_namespace+0x164/0x1bc) from [<80008aa0>] (kernel_init+0xe4/0x118)
[<80008aa0>] (kernel_init+0xe4/0x118) from [<8002dee0>] (kernel_thread_exit+0x0/0x8)
根文件系统挂载失败,原因是在内核中没有网卡驱动,所以在编译内核源码时需要将网卡驱动一起编译进去
11,重新编译内核源码,将网卡驱动编译进去--------与平台(开发板)相关的配置
1》修改内核源码—修改网卡驱动
vim arch/arm/mach-s5pv210/mach-smdkv210.c
修改下面两个数据:
static struct resource smdkv210_dm9000_resources[] = {
[0] = {
.start = 0x88000000,
.end = 0x88000000 + 0x3,
.flags = IORESOURCE_MEM, //地址端口
},
[1] = {
.start = 0x88000000 + 0x4,
.end = 0x88000000 + 0x4 + 0x3,
.flags = IORESOURCE_MEM, //数据端口
},
[2] = {
.start = IRQ_EINT(10),
.end = IRQ_EINT(10),
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
},
};
static struct dm9000_plat_data smdkv210_dm9000_platdata = {
.flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
.dev_addr = { 0x00, 0x09, 0xc0, 0xff, 0xec, 0xYY}, /* YY为座位号,如果座位号小于10, 则在前面添加0, 比如座位号为6,则可以填06 */
};
修改初始化函数:
static void __init smdkv210_dm9000_init(void)
{
unsigned int tmp;
gpio_request(S5PV210_MP01(1), "nCS1");
s3c_gpio_cfgpin(S5PV210_MP01(1), S3C_GPIO_SFN(2));
gpio_free(S5PV210_MP01(1));
tmp = (5 << S5P_SROM_BCX__TACC__SHIFT);
__raw_writel(tmp, S5P_SROM_BC1);
tmp = __raw_readl(S5P_SROM_BW);
tmp &= (S5P_SROM_BW__CS_MASK << S5P_SROM_BW__NCS1__SHIFT);
tmp |= (1 << S5P_SROM_BW__NCS1__SHIFT);
__raw_writel(tmp, S5P_SROM_BW);
}
2》在 make menuconfig 中添加网卡驱动选项
Device Drivers --->
[*] Network device support --->
[*] Ethernet (10 or 100Mbit) --->
<*> DM9000 support
(4) DM9000 maximum debug level (NEW)
3》重新编译内核源码
make -j2
LD [M] net/ipv6/sit.ko
Kernel: arch/arm/boot/Image is ready
LD [M] net/ipv6/xfrm6_mode_beet.ko
LD [M] net/ipv6/xfrm6_mode_transport.ko
GZIP arch/arm/boot/compressed/piggy.gzip
LD [M] net/ipv6/xfrm6_mode_tunnel.ko
SHIPPED arch/arm/boot/compressed/lib1funcs.S
AS arch/arm/boot/compressed/lib1funcs.o
AS arch/arm/boot/compressed/piggy.gzip.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
4》重新将内核镜像拷贝到/tftpboot
cp arch/arm/boot/zImage /tftpboot/
12,重启开发板,观察结果:
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2
dm9000 dm9000: eth0: link down
dm9000 dm9000: eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
IP-Config: Guessing netmask 255.255.255.0
IP-Config: Complete:
device=eth0, addr=192.168.7.7, mask=255.255.255.0, gw=255.255.255.255,
host=192.168.7.7, domain=, nis-domain=(none),
bootserver=255.255.255.255, rootserver=192.168.7.5, rootpath=
VFS: Mounted root (nfs filesystem) on device 0:10.
Freeing init memory: 124K
===========^_^ fs start==========
===========@_@ fs end==========
Please press Enter to activate this console.
[root@farsight /]# ls
bin etc lib opt sbin usr
dev hello_arm linuxrc proc sys
drv_module home mnt root tmp
[root@farsight /]#
============================内核移植成功!==================================