又从新整理了下,可以参考
linux2.6.29.2在mini2440上的移植
经过几天的移植,终于将linux2.6.29编译通过了,现记载下来,以便后面的做参考;主要参考了
www.aiothome.com论坛中的相关文章,并感谢总版主的帮助。
http://aiothome.com/bbs/read.php?tid-1878-fpage-2.htmlhttp://lsw0136.blog.163.com/blog/移植linux2.6.29内核+yaffs2文件系统过程
另外还有天嵌公司论坛上发表的移植文档
资源:mini2440、linux2.6.29.2、arm-linux-gcc-4.3.2、bootloader用的是友善的supervivi
一、 将Linux2.6.29.2内核源码放到linux下,并解压
#tar xvjf linux2.6.29.2.tar.bz2 –C /opt/
一定要将linux放到linux目录下,不要方到mnt下,因为可能windows的FAT/NTFS分区会编译不过;比如我这样搞的错误,大家可以参照错误,以免走弯路
[root@localhost linux-2.6.29.2]# make zImage
scripts/kconfig/conf -s arch/arm/Kconfig
CHK include/linux/version.h
UPD include/linux/version.h
Generating include/asm-arm/mach-types.h
CHK include/linux/utsrelease.h
UPD include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-arm
ln: 创建符号链接 “include/asm”: 不支持的操作
make: *** [include/asm] 错误 1
二、 修改源码目录下的Makefile文件
#ARCH ?=arm
#CROSS_COMPILE ?=arm-linux-
有的文章说它们的后面不要有空格,以作借鉴。
三、 修改2440的晶振频率
在友善之臂提供的源代码中对应于mach-mini2440.c(它们自己加的)
arch/arm/mach-s3c2440/mach-smdk2440.c (这个文件是自带的,我们不自己加就改它了)
static void __init smdk2440_map_io(void)
{
s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
s3c24xx_init_clocks(12000000); //修改此处
s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
}
四、 修改MTD分区情况
arch/arm/plat-s3c24xx/common-smdk.c(友善的是common-friendly-arm.c)
修改为三个分区
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "vivi",
.size =0x00030000,
.offset =0,
},
[1] = {
.name = "kernel",
.offset =0x00050000,
.size = 0x00200000,
},
[2] = {
.name = "root",
.offset = 0x00250000,
.size =0x03dac000,
}
后面就可以删除掉了(这中间的地址看好多人自己设定也可以)
至于下面的三各参数有的说要改,但是官方给的是没该的,
static struct s3c2410_platform_nand smdk_nand_info = {
.tacls =2 0,
.twrph0 = 60,
.twrph1 = 20,
可以参考友善给的源码里面的linux2.6.29/arch/arm/plat-s3c24xx/common-friendly-arm.c文件
五、 增加yaffs2的代码
下载yaffs2.tar.gz包解压到一起
#cd yaffs2
打补丁到linux内核
#./patch-ker.sh c ./linux-2.6.29.2/
注意要下载新点的yaffs2包,要不然可能和内核版本不配搭
六、 配置内核
先拷贝默认的配置文件到源码目录下
# cp arch/arm/configs/s3c2410_defconfig .config
(或者#make s3c2410_defconfig)
#make menuconfig
1.General setup --->
[*] Configure standard kernel features (for small systems) --->
选上这项,否则文件系统中的一些选项不会出现
2. System Type ---->
[*] S3C2410 DMA support [*] Support ARM920T processor
S3C2440 Machines --->
[*] SMDK2440
[*] SMDK2440 with S3C2440 CPU module
3.Boot options --->
将 (root=/dev/hda1 ro init=/bin/bash console=ttySAC0) Default kernel command string
改成 (noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0)
其中mtdblock2表示MTD分区的第二个分区存文件系统;
Linuxrc为启动的首个脚本。
网上有很多是(noinitrd root=/dev/mtdblock2 console=ttySAC0,115200 init=/linuxrc )但是我的老是不行,到了…………done,booting the kernel就不动了,后来将115200去掉就可以了,我是看到了supervivi中输出的这些内容后改成一样的了
4.[*] Enable loadable module support --->
[*] Module unloading
5.Device Drivers --->
<*> Memory Technology Device (MTD) support --->
[*] MTD partitioning support
<*> NAND Device Support --->
<*> NAND Flash support for S3C2410/S3C2440 SoC
[ ] S3C2410 NAND Hardware ECC //这个要去掉
[*] Network device support --->
[*] Ethernet (10 or 100Mbit) --->
<*> DM9000 support
< > Real Time Clock --->
6.File systems----->
Miscellaneous filesystems --->
<*>YAFFS2 file system support
<>journalling flash file systemversion(jffs) support
<>journalling flash file systemversion2(jffs2) support
取消这两个,否则当你的root_fs是yaffs2时,由于jffs和yaffs2文件系统都没有超级块,即不能识别文件类型,jffs也能挂载yaffs2系统,只不过他读的数据都是错的,并将所有数据放在/lost+found文件夹中,故如果jffs也加载了,他可能先挂载yaffs系统,这样就会挂载失败。
7.kernel Features-----
[*]Use the ARM EABI to compile the Kernel
这一项我当初选上了出现了这个错误
CHK include /linux/utsreloase.h
SYMLINK include /asm->include /asm-arm
CC kernel /bounds.s
CC/:error: invalid option"abi=aapcs-linux"
make[1]: *** [kernel/bounds.s] Error 1
make: *** [prepare0] Error 2
因为我刚开始装的是arm-linux-gcc-3.4.1,后来换了个4.3.2
“你的内核配置为EABI的,但用的toolchian是OABI的,所以你有两个选择:
1. 去掉内核的EABI选项(Kernel Features->Use EABI), 但这样不能支持EABI的文件系统,比如20090405更新以后的root_qtopia;
2. 用一个支持EABI的toolchian编译,比如友善之臂提供的4.3.2的toolchain。”
七、 cpu的ID设定
mini2440的supervivi用到的是782
arch/arm/tools/mach-types
你可能会看到
PNX4008 MACH_PNX4008 PNX4008 782
mini2440 MACH_MINI2440 MINI2440 1999
但是其实id并不是这样的在arch/arm/mach-s3c2440/mach-mini2440.c中,你可以看到MACHINE-START(PNX4008,“friendly…..”),就是说它用PNX代替了,但是782是不能变的,总之PNX4008这个地方的值只能是782.
我改的就是smdk2440(因为下的源码中有这个,友善的mach-mini2440是它们加的),在arch/arm/mach-s3c2440/mach-smdk2440.c即MACHINE-START(smdk2440,”你想要输出的内容”),所以你在配置config的时候kernel TYPE时候要选上SMDK2440
在vivi源码中对应在include/platform/smdk2440.h中MACH_TYPE
最后#make zImage
就可以在/linux2.6.29.2/arch/arm/boot找到zImage文件了
主要改的文件有:
arch/arm/mach-s3c2440/mach-smdk2440.c
arch/arm/plat-s3c24xx/common-smdk2440.c
arch/arm/tools/mach-types (主要是看bootloader里面用到的ID,同步修改)
其中有些配置估计要细细了解,需要那些看实际的了
----2009.06.04