主题 : 移植Linux2.6.32到mini2440,启动失败,请高手进来帮忙分析分析 复制链接 | 浏览器收藏 | 打印
在各种放弃与追求中前进
级别: 新手上路
UID: 28745
精华: 0
发帖: 12
金钱: 60 两
威望: 12 点
综合积分: 24 分
注册时间: 2010-09-16
最后登录: 2012-11-16
楼主  发表于: 2010-10-03 19:38

 移植Linux2.6.32到mini2440,启动失败,请高手进来帮忙分析分析

按照友善的Linux移植开发指南移植,具体步骤如下:一、指定交叉编译变量修改总目录下的Makefile原export KBUILD_BUILDHOST := $(SUBARCH)ARCH ?= $(SUBARCH)CROSS_COMPILE ?=改为export KBUILD_BUILDHOST := $(SUBARCH)ARCH ?= armCROSS_COMPILE ?= arm-linux-执行:#make s3c2410_defconfig ;使用缺省内核配置文件,s3c2410_defconfig 是SMDK2440 的缺省配置文件#make ;编译时间较长编译通过二、将linux-2.6.32.2/arch/arm/mach-s3c2440/目录下的mach-smdk2440.c 复制一份。命名为mach-mini2440.c , 找到MACHINE_START(S3C2440, "SMDK2440") , 修改为MACHINE_START(MINI2440, "FriendlyARM Mini2440 development board")。三、修改时钟源频率行static void __init smdk2440_map_io(void)函数中把其中的16934400改为12000000四、从SMDK2440 到MINI2440,因此把mach-mini2440.c 中所有的smdk2440 字样改为mini2440,可以使用批处理命令修改,在vim 的命令模式下输入:%s/smdk2440/mini2440/g在mini2440_machine_init(void)函数中,把smdk_machine_init()函数调用注释掉五、编译测试#make mini2440_defconfig ;使用Linux 官方自带的mini2440 配置#make zImage ;编译居然出现 invalid option `abi=aapcs-linux'错误 cc1: error: invalid option `abi=aapcs-linux' make[1]: *** [arch/arm/kernel/asm-offsets.s] Error 1 make: *** [prepare0] Error
换编译器Sourcery G++ Lite 2010q1-202(支持EABI)
修改Makefile
CROSS_COMPILE ?= arm-none-linux-gnueabi-
重新编译#make zImage;编译成功
六、在Linux-2.6.32.2/arch/arm/mach-s3c2440/Makefile中添加
obj-$(CONFIG_MACH_MINI2440) += mach-mini2440.o
七、移植Nand 驱动并更改分区信息
1、修改Nand Flash 分区表
参考/arch/arm/plat-24xx/common-smdk.c
在mach-mini2440.c添加友善的nand分区表
static struct mtd_partition mini2440_default_nand_part[] = {
[0] = {
.name = "vivi",  
.size = 0x00040000,
.offset = 0,
},
[1] = {
.name = "param",
.offset = 0x00040000,
.size = 0x00020000,  
},
[2] = {
.name = "Kernel",
.offset = 0x00060000,
.size = 0x00500000,
},
[3] = {
.name = "root",
.offset = 0x00560000,
.size = 1024 * 1024 * 1024,
},
[font=]

[4] = {
.name = "nand",
.offset = 0x00000000,
.size = 1024 * 1024 * 1024,
}
};
[font=]
2、NandFlash的设置表。
//这里是开发板的nand flash 设置表,因为板子上只有一片,因此也就只有一个表
static struct s3c2410_nand_set mini2440_nand_sets[] = {
[0] = {
.name = "NAND",
.nr_chips = 1,
.nr_partitions = ARRAY_SIZE(mini2440_default_nand_part),
.partitions = mini2440_default_nand_part,
},
};
3、//这里是nand flash本身的一些特性,一般需要对照datasheet填写,大部分情况下按照以下参数填写即可
static struct s3c2410_platform_nand mini2440_nand_info = {
.tacls = 20,
.twrph0 = 60,
.twrph1 = 20,
.nr_sets = ARRAY_SIZE(mini2440_nand_sets),
.sets = mini2440_nand_sets,
.ignore_unset_ecc = 1,
};
mini2440_machine_init函数中添加平台的数据信息。
 
static void __init mini2440_machine_init(void){
s3c24xx_fb_set_platdata(&mini2440_fb_info);
s3c_i2c0_set_platdata(NULL);
s3c_device_nand.dev.platform_data = &mini2440_nand_info;  //添加
platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices));
}
编译失败,按照/arch/arm/plat-24xx/common-smdk.c
在该文件中添加几个头文件才能编译成功:
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/nand_ecc.h>
#include <linux/mtd/partitions.h>

#include <plat/s3c2410.h>
#include <plat/s3c2440.h>
#include <plat/clock.h>
#include <plat/devs.h>
#include <plat/cpu.h>
#include <plat/nand.h>  //
添加

八、移植yaffs21、#git clone git://www.aleph1.co.uk/yaffs22、为内核打上yaffs2 补丁#cd yaffs2#./patch-ker.sh c m /opt/FriendlyARM/mini2440/linux-2.6.32.23、配置和编译带YAFFS2 支持的内核根目录运行:make menuconfigFile Systems->Miscellaneous filesystems->YAFFS2 file system support按空格选中#make zImage;编译成功九、下载,启动失败启动时,终端输出信息如下:load Image of Linux...Uncompressing Linux.......................................
................................................................................
........... done, booting the kernel.
Linux version 2.6.32.2 ([url=mailto:root@root]root@root[/url]) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-
202) ) #5 Thu Sep 30 14:04:44 CST 2010
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: FriendlyARM Mini2440 development board
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60548KB available (3644K code, 418K data, 128K init, 0K highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:85
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
JFFS2 version 2.2. (NAND) B) 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 118
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 60x53
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=4, 39ns Twrph0=8 79ns, Twrph1=8 79ns
Unable to handle kernel NULL pointer dereference at virtual address 00000018
pgd = c0004000
[00000018] *pgd=00000000
Internal error: Oops: 5 [#1]
last sysfs file:
Modules linked in:
CPU: 0 Not tainted (2.6.32.2 #5)
PC is at s3c24xx_nand_probe+0x2d8/0x504
LR is at s3c24xx_nand_probe+0x1a4/0x504
pc : [<c01e3ed4>] lr : [<c01e3da0>] psr: 60000013
sp : c3823f08 ip : 00000000 fp : 00000002
r10: 00000001 r9 : 000002b8 r8 : 00000000
r7 : 00000000 r6 : c388f800 r5 : 00000000 r4 : c39ae900
r3 : 00000001 r2 : 00000002 r1 : c4c00010 r0 : c388fab8
Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: c000717f Table: 30004000 DAC: 00000017
Process swapper (pid: 1, stack limit = 0xc3822270)
Stack: (0xc3823f08 to 0xc3824000)
3f00: 00000000 c00d23e0 c385a2d0 00000000 00000000 c03db400
3f20: c03db400 c03f1bb4 c03f1bb4 00000000 00000000 00000000 00000000 c01bf674
3f40: c01bf660 c01be884 00000000 c03db400 c03db434 c03f1bb4 00000000 c01be98c
3f60: c03f1bb4 c01be930 00000000 c01be16c c3804938 c38474b0 c03f1bb4 c39a9960
3f80: c03f0668 c01bdad4 c0388791 c0388791 00000034 c03f1bb4 00000000 00000000
3fa0: 00000000 00000000 00000000 c01bec5c c001a420 00000000 00000000 00000000
3fc0: 00000000 c002837c 00000000 00000000 00000000 00000054 00000000 c0021b2c
3fe0: 00000000 00000000 00000000 c00083f0 00000000 c0029e6c 61405130 45540620
[<c01e3ed4>] (s3c24xx_nand_probe+0x2d8/0x504) from [<c01bf674>] (platform_drv_pr
obe+0x14/0x18)
[<c01bf674>] (platform_drv_probe+0x14/0x18) from [<c01be884>] (driver_probe_devi
ce+0xa8/0x154)
[<c01be884>] (driver_probe_device+0xa8/0x154) from [<c01be98c>] (__driver_attach
+0x5c/0x7c)
[<c01be98c>] (__driver_attach+0x5c/0x7c) from [<c01be16c>] (bus_for_each_dev+0x4
c/0x78)
[<c01be16c>] (bus_for_each_dev+0x4c/0x78) from [<c01bdad4>] (bus_add_driver+0x98
/0x214)
[<c01bdad4>] (bus_add_driver+0x98/0x214) from [<c01bec5c>] (driver_register+0xa4
/0x134)
[<c01bec5c>] (driver_register+0xa4/0x134) from [<c002837c>] (do_one_initcall+0x5
c/0x1b4)
[<c002837c>] (do_one_initcall+0x5c/0x1b4) from [<c00083f0>] (kernel_init+0x94/0x
10c)
[<c00083f0>] (kernel_init+0x94/0x10c) from [<c0029e6c>] (kernel_thread_exit+0x0/
0x8)
Code: e58630c8 e2833001 e586321c e58652a8 (e5953018)
---[ end trace 45253ef64ed420be ]---
Kernel panic - not syncing: Attempted to kill init!
[<c002ec38>] (unwind_backtrace+0x0/0xd0) from [<c02d76c4>] (panic+0x3c/0x118)
[<c02d76c4>] (panic+0x3c/0x118) from [<c003e940>] (do_exit+0x64/0x590)
[<c003e940>] (do_exit+0x64/0x590) from [<c002cef0>] (die+0x158/0x17c)
[<c002cef0>] (die+0x158/0x17c) from [<c002f9a8>] (__do_kernel_fault+0x64/0x74)
[<c002f9a8>] (__do_kernel_fault+0x64/0x74) from [<c002fb6c>] (do_page_fault+0x1b
4/0x1c8)
[<c002fb6c>] (do_page_fault+0x1b4/0x1c8) from [<c00282b8>] (do_DataAbort+0x34/0x
98)
[<c00282b8>] (do_DataAbort+0x34/0x98) from [<c0028a20>] (__dabt_svc+0x40/0x60)
Exception stack(0xc3823ec0 to 0xc3823f08)
3ec0: c388fab8 c4c00010 00000002 00000001 c39ae900 00000000 c388f800 00000000
3ee0: 00000000 000002b8 00000001 00000002 00000000 c3823f08 c01e3da0 c01e3ed4
3f00: 60000013 ffffffff
[<c0028a20>] (__dabt_svc+0x40/0x60) from [<c01e3ed4>] (s3c24xx_nand_probe+0x2d8/
0x504)
[<c01e3ed4>] (s3c24xx_nand_probe+0x2d8/0x504) from [<c01bf674>] (platform_drv_pr
obe+0x14/0x18)
[<c01bf674>] (platform_drv_probe+0x14/0x18) from [<c01be884>] (driver_probe_devi
ce+0xa8/0x154)
[<c01be884>] (driver_probe_device+0xa8/0x154) from [<c01be98c>] (__driver_attach
+0x5c/0x7c)
[<c01be98c>] (__driver_attach+0x5c/0x7c) from [<c01be16c>] (bus_for_each_dev+0x4
c/0x78)
[<c01be16c>] (bus_for_each_dev+0x4c/0x78) from [<c01bdad4>] (bus_add_driver+0x98
/0x214)
[<c01bdad4>] (bus_add_driver+0x98/0x214) from [<c01bec5c>] (driver_register+0xa4
/0x134)
[<c01bec5c>] (driver_register+0xa4/0x134) from [<c002837c>] (do_one_initcall+0x5
c/0x1b4)
[<c002837c>] (do_one_initcall+0x5c/0x1b4) from [<c00083f0>] (kernel_init+0x94/0x
10c)
[<c00083f0>] (kernel_init+0x94/0x10c) from [<c0029e6c>] (kernel_thread_exit+0x0/
0x8)





级别: 骑士
UID: 11942
精华: 1
发帖: 144
金钱: 775 两
威望: 155 点
综合积分: 308 分
注册时间: 2009-12-25
最后登录: 2022-01-16
1楼  发表于: 2010-10-03 20:11
在各种放弃与追求中前进
级别: 新手上路
UID: 28745
精华: 0
发帖: 12
金钱: 60 两
威望: 12 点
综合积分: 24 分
注册时间: 2010-09-16
最后登录: 2012-11-16
2楼  发表于: 2010-10-05 15:12

 回 1楼(cole3) 的帖子

在网上看了几个版本,发现漏了
在mini2440_machine_init函数中添加平台的数据信息!!!

static void __init mini2440_machine_init(void){
s3c24xx_fb_set_platdata(&mini2440_fb_info);
s3c_i2c0_set_platdata(NULL);
s3c_device_nand.dev.platform_data = &mini2440_nand_info;  //添加后,编译下载,启动成功
platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices));
}
我的移植指南可能太旧了 !!!
级别: 新手上路
UID: 71998
精华: 0
发帖: 23
金钱: 115 两
威望: 23 点
综合积分: 46 分
注册时间: 2012-06-14
最后登录: 2013-04-10
3楼  发表于: 2012-08-07 17:14
   谢谢分享
级别: 新手上路
UID: 75157
精华: 0
发帖: 5
金钱: 25 两
威望: 5 点
综合积分: 10 分
注册时间: 2012-08-03
最后登录: 2012-08-09
4楼  发表于: 2012-08-08 15:47
新手,想问下lz移植内核是不是用jlink仿真器直接把bin文件烧进去就好。。求详解,纠结了好久