1.获取源码从
http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.2.tar.gz #tar xvzf linux-2.6.32.2.tar.gz
2.
指定交叉编译变量( 我用4.4.3版本的交叉编译器)
修改总目录下的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, "FriendlyARM Mini2440 development board")
4.
修 改 系 统 时 钟 源 , 在 mach-mini2440.c( 就是我们刚刚通过复制
mach-smdk2440.c 得到的)的第160 行static void __init smdk2440_map_io(void)函数中,
把其中的16934400(代表原SMDK2440 目标板上的晶振是16.9344MHz)改为mini2440 开发板上
实际使用的12000000
5.
把mach-mini2440.c 中所有的
smdk2440 字样改为mini2440,可以使用批处理命令修改,在vim 的命令模式下输入:
%s/smdk2440/mini2440/g
在mini2440_machine_init(void)函数中,把smdk_machine_init()函数调用注释掉.
6.移植Nand 驱动并更改分区信息
在mach-mini2440.c 中加入以下代码:
static struct mtd_partition mini2440_default_nand_part[] = {
[0] = {
.name = "supervivi",
.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,
},
[4] = {
.name = "nand",
.offset = 0x00000000,
.size = 1024 * 1024 * 1024,
}
};
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,
},
};
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,
};
//把nand flash 设备注册到系统中,添加&s3c_device_nand,
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,
};
//添加s3c_device_nand.dev.platform_data = &mini2440_nand_info;
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));
//smdk_machine_init();
}
再在mach-mini2440.c中加入
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/nand_ecc.h>
#include <linux/mtd/partitions.h>
#include <plat/nand.h>
7.移植yaffs2
#cd yaffs2
#./patch-ker.sh c ../linux-2.6.32.2
8.配置和编译带YAFFS2 支持的内核
在 Linux 内核源代码根目录运行:make mini2440_defconfig ; make menuconfig
找到File Systems ,再找到“Miscellaneous filesystems”菜单项,按回车进入该子菜单,
找到“YAFFS2 file system support”,并按空格选中它,这样我们就在内核中添加了
yaffs2 文件系统的支持,按“Exit”退出保存内核配置。
8.
执行:
#make zImage
最后会生成 linux-2.6.32.2/arch/arm/boot/zImage,使用supervivi 的“k“功能把它烧写
到nand flash,按“b“启动系统,这时,如果nand flash 已经存在文件系统(可以使用supervivi
的“y“功能烧写友善之臂提供的现成的yaffs2 文件系统映像root_qtopia-128M.img 用以测试),
发现挂载不上文件系统,下面截取的最后一部分:
No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
s3c2410-rtc s3c2410-rtc: setting system clock to 2009-04-16 17:13:33 UTC (1239902013)
yaffs: dev is 32505859 name is "mtdblock3"
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 132K
Failed to execute /linuxrc. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
[<c002e9c0>] (unwind_backtrace+0x0/0xd8) from [<c02e55ac>] (panic+0x40/0x118)
[<c02e55ac>] (panic+0x40/0x118) from [<c00295bc>] (init_post+0xcc/0xf4)
[<c00295bc>] (init_post+0xcc/0xf4) from [<c0008438>] (kernel_init+0xdc/0x10c)
[<c0008438>] (kernel_init+0xdc/0x10c) from [<c002a868>] (kernel_thread_exit+0x0/0x8)