一.按部就班
1.安装arm-linux-gcc 4.3.2
2.修改顶层makefile指定交叉编译变量:
原
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
改为
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-
3.将 linux-2.6.32.2/arch/arm/mach-s3c2440/目录下的 mach-smdk2440.c 复制一份。命名为
mach-mini2440.c ,找到 MACHINE_START(S3C2440, "SMDK2440") ,修改为
MACHINE_START(MINI2440, "Cody’s mini2440 DevBoard")。
4. 修改时钟源频率为12MHz(12000000)
5. 替换所有mach-mini2440.c中的smdk2440为mini2440,在 mini2440_machine_init(void)函数中,把
smdk_machine_init()函数调用注释掉.
6. make mini2440_defconfig然后make zImage,成功!
7. 把生成的zImage文件烧到板上运行,出现如下错误:
Copy linux kernel from 0x00060000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySA
C0"
MACH_TYPE = 1999
NOW, Booting Linux......
Uncompressing Linux.............................................................
.................................................................... done, booti
ng the kernel.
到这里就不动了,把开关拨到从Nand启动,还是出现上面几行字就不动了.
二.先不管它,按照实战手册后面的说明继续做下去.在mach-mini2440.c中加入如下代码:
/* add flash partion BY Cody */
static struct mtd_partition mini2440_default_nand_part[] = {
[0] = {
.name = "supervivi", /*这里是 bootloader 所在的分区,可以放置 u-boot, supervivi 等内容,对应/dev/mtdblock0*/
.size = 0x00040000,
.offset = 0,
},
[1] = {
.name = "param", /*这里是supervivi的参数区,其实也属于bootloader的一部分,如果u-boot 比较大,可以把此区域覆盖掉,不会影响系统启动,对应/dev/mtdblock1 */
.offset = 0x00040000,
.size = 0x00020000,
},
[2] = {
.name = "Kernel",// ;内核所在的分区,大小为 5M,足够放下大部分自己定制的巨型内核了,比如内核使用了更大的Linux Logo图片等,对应/dev/mtdblock2
.offset = 0x00060000,
.size = 0x00500000,
},
[3] = {
.name = "root", //;文件系统分区,友善之臂主要用来存放yaffs2 文件系统内容,对应/dev/mtdblock3
.offset = 0x00560000,
.size = 1024 * 1024 * 1024, //
},
[4] = {
.name = "nand", //;此区域代表了整片的nand flash,主要是预留使用,比如以后可以通过应用程序访问读取/dev/mtdblock4就能实现备份整片nand flash了。
.offset = 0x00000000,
.size = 1024 * 1024 * 1024, //
}
};
//;这里是开发板的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,
},
};
//;这里是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,
};
/* End flash Partion*/
再修改如下信息,加入红色那一行
static struct platform_device *mini2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&s3c_device_nand, //;把nand flash设备添加到开发板的设备列表结构
};
重新make zImage,这次出现很多错误,看不懂
arch/arm/mach-s3c2440/mach-mini2440.c:178: error: array type has incomplete element type
arch/arm/mach-s3c2440/mach-mini2440.c:179: error: array index in non-array initializer
arch/arm/mach-s3c2440/mach-mini2440.c:179: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:180: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:180: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:181: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:181: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:182: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:182: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:184: error: array index in non-array initializer
arch/arm/mach-s3c2440/mach-mini2440.c:184: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:185: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:185: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:186: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:186: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:187: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:187: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:189: error: array index in non-array initializer
arch/arm/mach-s3c2440/mach-mini2440.c:189: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:190: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:190: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:191: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:191: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:192: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:192: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:194: error: array index in non-array initializer
arch/arm/mach-s3c2440/mach-mini2440.c:194: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:195: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:195: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:196: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:196: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:197: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:197: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:199: error: array index in non-array initializer
arch/arm/mach-s3c2440/mach-mini2440.c:199: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:200: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:200: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:201: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:201: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:202: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:202: error: (near initialization for 'mini2440_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:206: error: array type has incomplete element type
arch/arm/mach-s3c2440/mach-mini2440.c:207: error: array index in non-array initializer
arch/arm/mach-s3c2440/mach-mini2440.c:207: error: (near initialization for 'mini2440_nand_sets')
arch/arm/mach-s3c2440/mach-mini2440.c:208: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:208: error: (near initialization for 'mini2440_nand_sets')
arch/arm/mach-s3c2440/mach-mini2440.c:209: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:209: error: (near initialization for 'mini2440_nand_sets')
arch/arm/mach-s3c2440/mach-mini2440.c:210: error: field name not in record or union initializer