最近在学习内核移植,,用的mini210的板子,试着移植下3.7.4的内核,希望能有所获,希望搞出一套比较通用的移植步骤
1,下载内核,然后解压tar xzvf 命令,在内核目录arch/arm/configs下 ,找到s5pv210的默认配置文件,,然后拷到内核根目录下,执行cp s5pv210_defconfig .config
然后执行make menuconfig,,,,然后修改makefile中的内容,,,ARCH =arm CROSS_COMPILE=arm-linux-
2编译内核,,发现是可以通过的,,,但是下的开发板中没有打印信息,更不能启动
3,修改make menuconfig,,,修改串口配置,,在SYSTEM TYPE下配置硬件信息,比如ARM system type的选项,选择所要的处理器,在device drivers->character device->serial drivers下添加处理里的片上串口驱动支持
4,修改机器码,,在arch/arm/tools/mach-types下修改s5pv210的机器码为3466
编译后启动
Load Kernel...
Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0
Linux version 3.7.4 (root@gzz-To-be-filled-by-O-E-M) (gcc version 4.5.1 (ctng-1.8.1-FA) ) #5 PREEMPT Tue Feb 25 12:47:03 CST 2014
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S5PV210: PLL settings, A=1000000000, M=667000000, E=80000000 V=54000000
S5PV210: ARMCLK=1000000000, HCLKM=200000000, HCLKD=166750000
HCLKP=133400000, PCLKM=100000000, PCLKD=83375000, PCLKP=66700000
sclk_dmc: source is sclk_a2m (0), rate is 200000000
sclk_onenand: source is hclk_dsys (1), rate is 166750000
sclk_fimc: source is ext_xtal (0), rate is 24000000
sclk_fimc: source is ext_xtal (0), rate is 24000000
sclk_fimc: source is ext_xtal (0), rate is 24000000
sclk_cam0: source is ext_xtal (0), rate is 24000000
sclk_cam1: source is ext_xtal (0), rate is 24000000
sclk_fimd: source is ext_xtal (0), rate is 24000000
sclk_mfc: source is sclk_a2m (0), rate is 200000000
sclk_g2d: source is sclk_a2m (0), rate is 200000000
sclk_g3d: source is sclk_a2m (0), rate is 200000000
sclk_csis: source is ext_xtal (0), rate is 24000000
sclk_pwi: source is ext_xtal (0), rate is 24000000
sclk_pwm: source is ext_xtal (0), rate is 24000000
Kernel command line: root=/dev/mtdblock4 rootfstype=yaffs2 console=ttySAC0,115200 init=/linuxrc lcd=H43
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 512MB = 512MB total
Memory: 516908k/516908k available, 7380k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
vmalloc : 0xe0800000 - 0xff000000 ( 488 MB)
lowmem : 0xc0000000 - 0xe0000000 ( 512 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.text : 0xc0008000 - 0xc0243000 (2284 kB)
.init : 0xc0243000 - 0xc0260e2c ( 120 kB)
.data : 0xc0262000 - 0xc0289ae0 ( 159 kB)
.bss : 0xc0289b04 - 0xc02ba828 ( 196 kB)
SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:208
VIC @f6000000: id 0x00041192, vendor 0x41
VIC @f6010000: id 0x00041192, vendor 0x41
VIC @f6020000: id 0x00041192, vendor 0x41
VIC @f6030000: id 0x00041192, vendor 0x41
sched_clock: 32 bits at 33MHz, resolution 29ns, wraps every 128784ms
Console: colour dummy device 80x30
Calibrating delay loop... 663.55 BogoMIPS (lpj=1658880)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x201bce70 - 0x201bcec8
DMA: preallocated 256 KiB pool for atomic coherent allocations
hw-breakpoint: debug architecture 0x4 unsupported.
S5PV210: Initializing architecture
bio: create slab at 0
SCSI subsystem initialized
Switching to clocksource s5p_clocksource_timer
CPU PMU: probing PMU on CPU 0
hw perfevents: enabled with ARMv7 Cortex-A8 PMU driver, 5 counters available
ROMFS MTD (C) 2007 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
dma-pl330 dma-pl330.0: PERIPH_ID 0x0, PCELL_ID 0x0 !
dma-pl330: probe of dma-pl330.0 failed with error -22
dma-pl330 dma-pl330.1: PERIPH_ID 0x0, PCELL_ID 0x0 !
dma-pl330: probe of dma-pl330.1 failed with error -22
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
s5pv210-uart.0: ttySAC0 at MMIO 0xe2900000 (irq = 74) is a S3C6400/10
console [ttySAC0] enabled
s5pv210-uart.1: ttySAC1 at MMIO 0xe2900400 (irq = 75) is a S3C6400/10
s5pv210-uart.2: ttySAC2 at MMIO 0xe2900800 (irq = 76) is a S3C6400/10
s5pv210-uart.3: ttySAC3 at MMIO 0xe2900c00 (irq = 77) is a S3C6400/10
brd: module loaded
loop: module loaded
mousedev: PS/2 mouse device common for all mice
cpuidle: using governor ladder
cpuidle: using governor menu
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
Backtrace:
[] (dump_backtrace+0x0/0x10c) from [] (dump_stack+0x18/0x1c)
r6:c025c14c r5:dfa38000 r4:df83fef4
[] (dump_stack+0x0/0x1c) from [] (panic+0x94/0x1f0)
[] (panic+0x0/0x1f0) from [] (mount_block_root+0x220/0x2e0)
r3:00000000 r2:00000000 r1:df83fef4 r0:c0212fec
r7:00008000
[] (mount_block_root+0x0/0x2e0) from [] (mount_root+0x58/0x68)
[] (mount_root+0x0/0x68) from [] (prepare_namespace+0x168/0x1bc)
r5:c025c15d r4:c0289ba0
[] (prepare_namespace+0x0/0x1bc) from [] (kernel_init+0x164/0x29c)
r5:00000008 r4:c025c148
[] (kernel_init+0x0/0x29c) from [] (ret_from_fork+0x14/0x3c)
以上为启动信息,,有助于以后对启动过程做出分析,,待续
根据以上启动信息发现,,系统缺少一些驱动,,比如网卡驱动dm9000以及nand flash的驱动,,所以我接下来先移植dm9000
插曲(内核里一般都有一种处理器类型的公共的板级配置文件,210的板级文件在arch/arm/mach-s5pv210目录下的mach-smdkv210.c,,,我不想移植时在这个文件里改动,所以我复制这个文件为mach-mini210.c,修改文件中的MACHINE_START(MINI210, "MINI210"),,为这个,,,然后对应的要修改linux/arch/arm/tools/mach-types文件中的机器参数为mini210 MACH_MINI210 MINI210 3466,,然后修改arch/arm/mach-s5pv210/目录下的Kconfig文件和Makefile文件,添加新增加的板级文件mach-mini210.c到编译目录中)
5,移植网卡dm9000
在make menuconfig中加入支持dm9000的驱动程序,以及一些关于网络的选项,比如tcp/ip之类的选项,
然后进行编译,,发现不行,显示
dm9000 Ethernet Driver, V1.31
dm9000 dm9000: read wrong id 0x2b2a2928
dm9000 dm9000: read wrong id 0x2b2a2928
dm9000 dm9000: read wrong id 0x2b2a2928
dm9000 dm9000: read wrong id 0x2b2a2928
dm9000 dm9000: read wrong id 0x2b2a2928
dm9000 dm9000: read wrong id 0x2b2a2928
dm9000 dm9000: read wrong id 0x2b2a2928
dm9000 dm9000: read wrong id 0x2b2a2928
dm9000 dm9000: wrong id: 0x2b2a2928
dm9000 dm9000: not found (-19).
PPP generic driver version 2.4.2
然后,,回到源码修改,,在arch/arm/mach-s5pv210/mach-mini210.c中修改,dm9000的平台设备信息,
#include
#define S5PV210_PA_DM9000_A (0x88001000)
#define S5PV210_PA_DM9000_F (S5PV210_PA_DM9000_A + 0x300C)
static struct resource mini210_dm9000_resources[] = {
[0] = {
.start = S5PV210_PA_DM9000_A,
.end = S5PV210_PA_DM9000_A + SZ_1K*4 - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = S5PV210_PA_DM9000_F,
.end = S5PV210_PA_DM9000_F + SZ_1K*4 - 1,
.flags = IORESOURCE_MEM,
},
[2] = {
.start = IRQ_EINT(7),
.end = IRQ_EINT(7),
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
},
};
static struct dm9000_plat_data mini210_dm9000_platdata = {
.flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
.dev_addr = { 0x08, 0x90, 0x00, 0xa0, 0x02, 0x10 },
};
struct platform_device mini210_dm9000 = {
.name = "dm9000",
.id = -1,
.num_resources = ARRAY_SIZE(mini210_dm9000_resources),
.resource = mini210_dm9000_resources,
.dev = {
.platform_data = &mini210_dm9000_platdata,
},
};
这里面关键的是DM9000的地址问题,,根据原理图,
决定dm9000地址的是两个引脚Xm0CSn1和Xm0ADDR2,然后根据210的数据手册可知要使Xm0CSn1低电平选中,需要地址为0x88000000,要使ADDR2有效,则第3个地址位为1即可,,即让dm9000工作的地址可为0x88000000 和0x88000004,只要满足这两个条件的地址都能用,,友善的板子里的地址为0x88001000,和0x8800400c,所以地址配置如上面代码所示
然后再编译,这下就可以了,打印为
dm9000 Ethernet Driver, V1.31
eth0: dm9000a at e0856000,e0858004 IRQ 39 MAC: 00:09:c0:ff:ec:48 (platform data)
PPP generic driver version 2.4.2
接下来进行nand flash的驱动移植,,,待续