一. 准备必要的文件
我们首先去官方网站下载最新的 llinux 内核
http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.14.tar.bz2
因为 linux 2.6.14 内核需要更新版本的编译器,所以我们需要下载交叉编译器
ftp://ftp.handhelds.org/projects/toolchain/arm-linux-gcc-3.4.1.tar.bz2
注:这个编译器已经包含在光盘的 /DISK4/linux 相关 /linuxtool 目录下面。
二. 安装文件
我们把 gcc 安装在 /usr/local/arm/ 3.4.1 目录下,安装方法和安装 gcc2.95.3 和 gcc3.3.2 是相同的,(
cd /
tar jxvf arm-linux-gcc-3.4.1.tar.bz2
vi ~/.bash_profile
把arm-linux-gcc的路径/usr/local/arm/3.4.1/bin添加到PATH中)
接下来需要解压 linux 内核,输入命令:
[root · localhost hfrk]# tar jxvf linux- 2.6.14 .tar.bz2
内核被解压到 linux- 2.6.14 目录下。
三. 修改 makefile 文件
内核的编译是根据 makefile 文件的指示进行的, Makefile 文件来组织内核的各模块之间的关系,记录了各个模块之间的相互联系和依赖关系。
我们首先修改 linux- 2.6.14 的根目录下的 makfile 文件,我们须改的主要内容是目标代码的类型和为编译内核指定一个编译器。
我们注释掉以下内容:
#ARCH ?= $(SUBARCH)
#CROSS_COMPILE ?=
增加如下内容:
ARCH : = arm
CROSS_COMPILE =/usr/local/arm/ 3.4.1 /bin/arm-linux-
四. 修改相关的文件。
1. 修改 arch/arm/mach-s 3c 2410/devs.c 文件
增加头文件定义
/***********add here***********/
#include <linux/mtd/partitions.h>
#include <asm/arch/nand.h>
#include <linux/mtd/nand.h>
/**************end add********/
增加 nand flash 分区信息
/***********add here***********/
static struct mtd_partition partition_info[] ={
{
name: "loader",
size: 0x00020000,
offset: 0,
}, {
name: "param",
size: 0x00010000,
offset: 0x00020000,
}, {
name: "kernel",
size: 0x 001c 0000,
offset: 0x00030000,
}, {
name: "root",
size: 0x00200000,
offset: 0x00200000,
mask_flags: MTD_WRITEABLE,
}, {
name: "user",
size: 0x03af8000,
offset: 0x00400000,
}
};
struct s 3c 2410_nand_set nandset ={
nr_partitions: 5 ,
partitions: partition_info ,
};
struct s 3c 2410_platform_nand superlpplatform={
tacls:0,
twrph0:30,
twrph1:0,
sets: &nandset,
nr_sets: 1,
};
/**************end add********/
struct platform_device s 3c _device_nand = {
.name = "s 3c 2410-nand",
.id = -1,
.num_resources = ARRAY_SIZE(s 3c _nand_resource),
.resource = s 3c _nand_resource,
/***********add here****************/
.dev = {
.platform_data = &superlpplatform
}
/**************end here************/
};
2. 修改 arch/arm/mach-s 3c 2410/mach-smdk2410.c 文件
Startic struct platform_device *smdk2410_devices[] __initdata={
&s 3c _device_usb,
&s 3c _device_lcd;
&s 3c _device_wdt,
&s 3c _device_i 2c ;
&s 3c _device_iis,
&s 3c _device_nand, /*add here*/
};
五. 我们做完以上修改以后,内核编译以后就可以在 hfrk2410 开发板上运行了。
打开终端窗口,切换到 linux- 2.6.14 目录下,输入命令:
# make smdk2410_defconfig
#make menuconfig /*选择nand flash模块*/
# make
等编译完成以后,会生成镜像文件 arch/arm/boot/zImage ,把这个文件下载到开发板上,就会看到 linux2.6 的内核启动信息,我们迈出了 linux2.6 内核移植的第一步!
如果出现field `list' has incomplete type
那是因为partitions.h中没有定义head_list,在partitions.h的头加上#include <linux/list.h>
就ok了,哈哈