主题 : 个人整理的linux2.6.29的移植 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 5970
精华: 0
发帖: 37
金钱: 380 两
威望: 375 点
综合积分: 74 分
注册时间: 2009-05-15
最后登录: 2009-09-14
楼主  发表于: 2009-05-26 18:44

 个人整理的linux2.6.29的移植

linux2.6.29.2在mini2440上的移植

    经过几天的移植,终于将linux2.6.29编译通过了,现记载下来,以便后面的做参考;主要参考了
www.aiothome.com论坛中的相关文章,并感谢总版主的帮助。
    http://aiothome.com/bbs/read.php?tid-1878-fpage-2.html
    http://www.aiothome.com/bbs/read.php?tid-1342.html
http://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的晶振频率
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
修改为三个分区
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
       S3C2410 Machines --->
              [*] SMDK2410/A9M2410
       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  console=ttySAC0,115200 init=/linuxrc )
其中mtdblock2表示MTD分区的第二个分区存文件系统;
Linuxrc为启动的首个脚本。

4.[*] Enable loadable module support --->
[*]   Forced module loading
       [*]   Module unloading
            [*]   Forced 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设定
arch/arm/tools/mach-types  
mini2440        MACH_MINI2440        MINI2440        1999
可能老点的里面没有mini2440和qq2440的ID,但是现在的好像都有了,所以不需要自己添加
    
最后#make zImage
就可以在/linux2.6.29.2/arch/arm/boot找到zImage文件了
级别: 新手上路
UID: 5970
精华: 0
发帖: 37
金钱: 380 两
威望: 375 点
综合积分: 74 分
注册时间: 2009-05-15
最后登录: 2009-09-14
1楼  发表于: 2009-05-26 18:46
内核是编译过了,但是下到扳子上去后,出现了下面的错误,cpu的ID问题,是不是要下子新的supervivi,因为我看友善新版的内核中MACH_TYPE是1999,我也试着改过这个号码,但是启动后还是一样的、?
Copy linux kernel from 0x00050000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock2 init=/linuxrc

console=ttySAC0"
MACH_TYPE = 782
NOW, Booting Linux......
Uncompressing

Linux.................................................................................................................

done, booting the kernel.


Error: unrecognized/unsupported machine ID (r1 = 0x0000030e).


Available machine support:


ID (hex) NAME

000000c1 SMDK2410

0000015b IPAQ-H1940

0000039f Acer-N35

00000290 Acer-N30

0000014b Simtec-BAST

000002a8 Nex Vision - Otom 1.1

00000400 AML_M5900

000001db Thorcom-VR1000

00000454 QT2410

000003fe SMDK2413

000003f1 SMDK2412

00000377 S3C2413

00000474 VSTMS

0000016a SMDK2440

0000043c SMDK2443


Please check your kernel config and/or bootloader.
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
2楼  发表于: 2009-05-26 21:48
Machine ID不匹配的问题我已经在帖子http://www.aiothome.com/bbs/read.php?tid-1342.html里的39楼里解释了
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 5970
精华: 0
发帖: 37
金钱: 380 两
威望: 375 点
综合积分: 74 分
注册时间: 2009-05-15
最后登录: 2009-09-14
3楼  发表于: 2009-05-27 10:24
ID的问题不改也是那样了,但是具体的问题出在哪?
需不需要用新的supervivi
级别: 新手上路
UID: 5970
精华: 0
发帖: 37
金钱: 380 两
威望: 375 点
综合积分: 74 分
注册时间: 2009-05-15
最后登录: 2009-09-14
4楼  发表于: 2009-06-03 15:02
引用第2楼kasim于2009-05-26 21:48发表的  :
Machine ID不匹配的问题我已经在帖子http://www.aiothome.com/bbs/read.php?tid-1342.html里的39楼里解释了


总斑竹帮帮忙
1。我按照你的方法选择PNX4009后,重新编译出现这个问题,一直不动
其他的步骤都和上面讲的一样
Copy linux kernel from 0x00050000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySA
C0"
MACH_TYPE = 782
NOW, Booting Linux......


2。如果ID不对 的话就是二楼的现象
3。在http://www.aiothome.com/bbs/read.php?tid-1342-fpage-1-toread--page-4.html里面,你回答的
我的内核里面没有arch\arm\mach-s3c2440\mach-mini2440文件,更别说MACHINE_START(PNX4008, "FriendlyARM Mini2440 development board")了
4。我在配置内核的时候选择了USB设备的话出现了这个问题
In file included from drivers/usb/host/ohci-hcd.c:1046:

drivers/usb/host/ohci-pnx4008.c: In function 'usb_hcd_pnx4008_probe':

drivers/usb/host/ohci-pnx4008.c:330: error: 'struct i2c_board_info' has no member named 'name'

drivers/usb/host/ohci-pnx4008.c:414: error: implicit declaration of function 'i2c_unregister_client'

make[3]: *** [drivers/usb/host/ohci-hcd.o] 错误 1

make[2]: *** [drivers/usb/host] 错误 2

make[1]: *** [drivers/usb] 错误 2

make: *** [drivers] 错误 2

希望斑竹帮我看一下,谢谢了
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
5楼  发表于: 2009-06-03 15:36
3。在http://www.aiothome.com/bbs/read.php?tid-1342-fpage-1-toread--page-4.html里面,你回答的
我的内核里面没有arch\arm\mach-s3c2440\mach-mini2440文件,更别说MACHINE_START(PNX4008, "FriendlyARM Mini2440 development board")了

兄弟,依葫芦画瓢总会吧。我说的是友善之臂提供的2.6.29里的源代码,目的是告诉你如果想要你的内核和supervivi匹配,内核所用的Machine ID必须是782,友善之臂用PNX4008只是其中一个办法。你甚至可以自己在arch/arm/tools/mach-types里定义你所用的Machine ID为782.
如果你自己都搞不清你的内核目前用的Machine ID是多少,就先搞清楚这个再说
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 5970
精华: 0
发帖: 37
金钱: 380 两
威望: 375 点
综合积分: 74 分
注册时间: 2009-05-15
最后登录: 2009-09-14
6楼  发表于: 2009-06-03 15:47
ID的问题我用到的就是782,可出现了2楼中的第一个问题,
我就是不清楚它为撒不动了,谢谢帮忙看一下
级别: 新手上路
UID: 5970
精华: 0
发帖: 37
金钱: 380 两
威望: 375 点
综合积分: 74 分
注册时间: 2009-05-15
最后登录: 2009-09-14
7楼  发表于: 2009-06-04 14:12
又从新整理了下,可以参考
linux2.6.29.2在mini2440上的移植

    经过几天的移植,终于将linux2.6.29编译通过了,现记载下来,以便后面的做参考;主要参考了
www.aiothome.com论坛中的相关文章,并感谢总版主的帮助。
    http://aiothome.com/bbs/read.php?tid-1878-fpage-2.html
http://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