分类: 嵌入式
2009-12-25 20:54:09
一、开发平台
主 机:VMware--Fedora 8
开发板:utu2440--64MB Nand
编译器:arm-linux-gcc-
软件资源:linux-
yaffs2 内核补丁cvs-root.tar.gz
二、移植步骤
解压内核源码
# tar jxf linux-
# cd linux-
1. 修改根目录Makefile
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-
2. 修改平台输入时钟
修改arch/arm/mach-s3c2440/mach-smdk2440.c
找到smdk2440_map_io函数中s3c24xx_init_clocks(16934400);
改为s3c24xx_init_clocks(12000000);
3. 修改s3c2440的机器码
由于Bootloader传递给Linux内核的机器号为5244,为与Bootloader传递参数一致,修改 arch/arm/tools/math-types文件。
s3c2440 ARCH_S3C2440 S3C2440 362
修改为:
s3c2440 ARCH_S3C2440 S3C2440 5244
4. 修改Nand flash分区信息
修改arch/arm/plat-s3c24xx/common-smdk.c
修改mtd分区信息
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "bootloader",
.size = 0x00040000,
.offset = 0x00000000,
},
[1] = {
.name = "kernel",
.offset = 0x00060000,
.size = 0x00200000,
},
[2] = {
.name = "root",
.offset = 0x00260000,
.size = 0x03dac000,
}
};
然后修改struct s3c2410_platform_nand smdk_nand_info = {
.tacls = 0,
.twrph0 = 30,
.twrph1 = 0,
…
};
5. LCD参数修改
这里用的是NEC3.5英寸屏液晶屏,大小为240x320,需要修改文件arch/arm/mach-s3c2440/mach-smdk2440.c
static struct s3c2410fb_display smdk2440_lcd_cfg __initdata = {
…
.width = 240,
.height = 320,
…
.right_margin = 37,
.hsync_len = 6,
.upper_margin = 2,
.lower_margin = 6,
.vsync_len = 2,
};
static struct s3c2410fb_mach_info smdk2440_fb_info __initdata = {
…
.gpccon = 0xaa955699,
.gpccon_mask = 0xffc003cc,
.gpcup = 0x0000ffff,
.gpcup_mask = 0xffffffff,
.gpdcon = 0xaa95aaa1,
.gpdcon_mask = 0xffc0fff0,
.gpdup = 0x0000faff,
.gpdup_mask = 0xffffffff,
.lpcsel = 0xf82,
};
6. 给内核打yaffs2文件系统的补丁
进入,点击“Download GNU tarball”,下载后出现cvs-root.tar.gz压缩包
# tar –zxf cvs-root.tar.gz –C /home/work_dir
# cd /home/work_dir/cvs/yaffs2
# ./patch-ker.sh c /home/work_dir/linux-
上面命令完成下面三件事情:
(1) 修改内核fs/Kconfig
增加一行:source "fs/yaffs2/Kconfig"
(2) 修改内核fs/Makefile
增加一行:ojb-$(CONFIG_YAFFS_FS) +=yaffs2/
(3) 在内核fs/目录下创建yaffs2目录
将yaffs2源码目录下面的Makefile.kernel文件复制为内核fs/yaffs2/Makefie;
将yaffs2 源码目录的Kconfig文件复制到内核fs/yaffs2目录下;
将yaffs2源码目录下的*.c *.h文件复制到内核fs/yaffs2目录下
7. 配置内核
通过以下命令将2410的默认配置文件写到当前目录下的.config。S3C2410的配置和S3C2440差不多,在这基础上进行修改
# make s3c2410_defconfig
# make menuconfig
System Type --->
S3C2410 Machines --->
[*] SMDK2410/A9M2410
S3C2440 Machines --->
[*] SMDK2440
[*] SMDK2440 with S3C2440 CPU module
Kernel Features --->
[*] Use the ARM EABI to compile the kernel
注:由于所使用的的交叉编译arm-linux-gcc-
Userspace binary formats --->
[*] Kernel support for ELF binaries
File systems --->
[*] Miscellaneous filesystems --->
<*> YAFFS2 file system support
[*] Lets Yaffs do its own ECC
<*> Journalling Flash File System v2 (JFFS2) support
[*] JFFS2 write-buffering support
[*] JFFS2 summary support (EXPERIMENTAL)
<*> Compressed ROM file system support (cramfs)
<*> ROM file system support
[*] Network File Systems --->
<*> NFS client support
[*] Root file system on NFS
-*- Native language support --->
<*> Codepage 437 (United States,
<*> Simplified Chinese charset (CP936, GB2312)
<*> Traditional Chinese charset (Big5)
<*> ASCII (
<*> NLS ISO 8859-1 (Latin 1; Western European Languages)
<*> NLS UTF-8
Device Drivers --->
<*> Memory Technology Device (MTD) support --->
[*] MTD partitioning support
<*> Direct char device access to MTD devices
<*> Caching block device access to MTD devices
<*> NAND Device Support --->
<*> NAND Flash support for S3C2410/S3C2440 SoC
Graphics support --->
<*> Support for frame buffer devices --->
[*] Enable firmware EDID
[*] Enable Video Mode Handling Helpers
<*> S3C2410 LCD framebuffer support
Console display driver support --->
<*> Framebuffer Console support
[*] Select compiled-in fonts
[*] VGA 8x8 font
[*] VGA 8x16 font
8. 编译内核
编写一个shell脚本make_uImage.sh用于编译内核
#!/bin/sh
make clean
make all
cp arch/arm/boot/zImage zImage -f
mkimage -A arm -O linux -n $(date --iso-8601=seconds) -C NONE -a 0x30008000 -e 0x30008000 -d zImage uImage
# chmod +x make_uImage.sh
# ./make_uImage.sh
参考资料:
[1]