linux-2.6.30.4移植至2440开发板
一、下载linux-2.6.30.4源码,并解压
ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.4.tar.gz
tar zxvf linux-2.6.30.4.tar.gz
二、在系统中添加对ARM的支持
$vim Makefile
193#ARCH ?= $(SUBARCH)
194#CROSS_COMPILE ?=
195 ARCH=arm
196 CROSS_COMPILE=arm-linux-
三、修改系统时钟
$vim arch/arm/mach-s3c2440/mach-smdk2440.c
系统的外部时钟为12MHz
160static void __init smdk2440_map_io(void)
161{
162s3c24xx_init_io(smdk2440_iodesc,ARRAY_SIZE(smdk2440_iodesc));
163//s3c24xx_init_clocks(16934400);
164//edit by
165 s3c24xx_init_clocks(12000000);
166s3c24xx_init_uarts(smdk2440_uartcfgs,ARRAY_SIZE(smdk2440_uartcfgs));
167}
说明:如果系统时钟不匹配,则出现乱码。
四、制作或者获取内核配置单.config
$make menuconfig
说明:一个比较好的做法是先调用自带的配置清单,该配置清单在arch/arm/configs目录,文件名为:s3c2410_defconfig,该配置文件几乎S3C24XX系列CPU的配置项,可以在此基础上修改配置项。x86的配置项在arch/x86/configs目录下,文件名为:i386_defconfig(32为cpu)。
cp arch/arm/configs/s3c2410_defconfig .config
五、修改机器码
$vim arch/arm/mach-s3c2440/mach-smdk2440.c
178 MACHINE_START(S3C2440 , "SMDK2440")
179/* Maintainer: Ben Dooks
180.phys_io = S3C2410_PA_UART,
181.io_pg_offst = (((u32)S3C24XX_VA_UART)>> 18) & 0xfffc,
182.boot_params = S3C2410_SDRAM_PA+ 0x100,
183
184 .init_irq = s3c24xx_init_irq,
185.map_io = smdk2440_map_io,
186.init_machine = smdk2440_machine_init,
187.timer = &s3c24xx_timer,
188MACHINE_END
修改机器码,使之与bootloader的机器码相同,这里使用的是u-boot,机器码为168
$vim arch/arm/tools/mach-types
379 s3c2440 ARCH_S3C2440 S3C2440168
$vim arch/arm/tools/Makefile
7 include/asm-arm/mach-types.h :$(src)/gen-mach-types $(src)/mach-types
8@echo Generating $@
9@mkdir -p $(dir $@)
10$(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
$vim include/asm/mach-types.h
375 #define MACH_TYPE_S3C2440168 //这个没有找见
$vim include/asm-arm/mach-types.h
377 #define MACH_TYPE_S3C2440 168
总结:首先从linux内核源码中找出机器类型(如S3C2440 ),其次,根据u-boot中给出的对应机器类型的机器码(如377 #define MACH_TYPE_S3C2440 168 )修改内核机器码。流程如下:
内核:
$vimarch/arm/mach-s3c2440/mach-smdk2440.c
U-boot:
$viminclude/asm-arm/mach-types.h
内核:
$vimarch/arm/tools/mach-types
说明:如果机器码错误,则系统提示选取平台,死机。
六、编译镜像
$make zImage
七、板子烧写
使用DNW工具将内核镜像烧写至开发板中
八、遇到的问题
问题:
Kernel panic - not syncing: Attempted to kill init!
解决办法:
$make menuconfig
选择以下两项:
Kernel Features --->
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTAL)
九、NandFlash驱动移植
linux里面已经包含NandFlash驱动,只需对源码进行修改即可。
1、$vim arch/arm/plat-s3c24xx/common-smdk.c
107 /* NAND parititon from 2.4.18-swl5*/
108
109 static struct mtd_partitionsmdk_default_nand_part[] = {
110#if defined(CONFIG_64MB_NAND )
111 [0] = {
112.name = "Board_uboot",
113.size = 0x00040000,
114.offset = 0x00000000,
115},
116[1] = {
117.name = "Board_kernel",
118.size = 0x00200000,
119.offset= 0x00200000,
120},
121[2] = {
122.name = "Board_yaffs2",
123.size = 0x03BF8000,
124.offset = 0x00400000,
125}
126#elif defined(CONFIG_128MB_NAND)
127 [0]={
128.name ="Board_uboot",
129.offset =0x00000000,
130.size =0x00040000,
131},
132[1]={
133.name ="Board_kernel",
134.offset =0x00200000,
135.size =0x00200000,
136},
137[2]={
138.name ="Board_yaffs2"
139.offset =0x00400000,
140.size =0x07BA0000,
141}
142 #elif defined(CONFIG_more_than_256MB_NAND)
143 [0]={
144.name ="Board_uboot",
145.offset =0x00000000,
146.size =0x00040000,
147},
148[1]={
149.name ="Board_kernel",
150.offset =0x00200000,
151.size =0x00200000,
152},
153[2]={
154.name ="Board_yaffs2",
155.offset =0x00400000,
156.size =0x0FB80000,
157}
158#endif
159};
2、$vim
- 基于飞凌2440开发板的linux-2.6.28移植过程(11-25)
- linux-2.6.14移植到S3C2440(11-22)
- linux-2.6.14移植:NET: Registered protocol family 1卡住(11-22)
- linux-2.6.14挂载NFS文件系统(11-22)
- linux-2.6.35.3内核移植(s3c2440)(11-20)
- TE2410移植linux-2.6.14及调试过程总结(1)(11-10)