基于TE2410移植2.6.14

内核移植是一个非常繁琐的工作,本人总结了一些经验希望能给大家提供一些帮助.
大体工作步骤如下:
一. 准备必要的文件
      首先去官方网站下载最新的 llinux 内核
     [url]http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.14.tar.bz2[/url]
因为 linux 2.6.14 内核需要更新版本的编译器,所以需要下载交叉编译器
  [url]ftp://ftp.handhelds.org/projects/toolchain/arm-linux-gcc-3.4.1.tar.bz2[/url]
二. 安装文件
      gcc 安装在 /usr/local/arm/ 3.4.1 目录下,安装方法和安装 gcc2.95.3 gcc3.3.2 是相同的!
接下来需要解压 linux 内核,输入命令:
[root localhost hfrk]# tar jxvf linux- 2.6.14 .tar.bz2
内核被解压到 linux- 2.6.14 目录下。
三. 修改 makefile 文件
      内核的编译是根据 makefile 文件的指示进行的, Makefile 文件来组织内核的各模块之间的关系,记录了各个模块之间的相互联系和依赖关系。
      我们首先修改 linux- 2.6.14 的根目录下的 makfile 文件,须改的主要内容是目标代码的类型和为编译内核指定一个编译器。注释掉以下内容:
    #ARCH   ?= $(SUBARCH)
    #CROSS_COMPILE      ?=
  增加如下内容:
       ARCH     : = arm
       CROSS_COMPILE =/usr/local/arm/ 3.4.1 /bin/arm-linux-
四. 修改相关的文件。
1. 修改 arch\arm\mach-s 3c 2410\devs.c 文件
   增加头文件定义
              /***********add here***********/
              #include  <linux/mtd/partitions.h>
              #include  <asm/arch/nand.h>
              #include  <linux/mtd/nand.h>
               /**************end add********/
  增加 nand flash 分区信息
              /***********add here***********/
              static struct mtd_partition partition_info[] ={
              {
              name: "vivi",
              size: 0x00020000,
              offset: 0,
              }, {
              name: "param",
              size: 0x00010000,
              offset: 0x00020000,
              }, {
              name: "kernel",
              size: 0x 001c 0000,
              offset: 0x00030000,
              }, {
              name: "root",
              size: 0x00400000,
              offset: 0x00200000,
              mask_flags: MTD_WRITEABLE,
              }, {
              name: "usr",
              size: 0x 03a 00000,
              offset: 0x00600000,
              }
              }; /* 这部分很重要,千万要跟vivi里的分区信息相同*/
 /* 加入NAND FLASH 分区*/
              struct s 3c 2410_nand_set nandset ={
              nr_partitions: 5 ,
              partitions: partition_info ,
              };
          /* 建立芯片支持*/
              struct s 3c 2410_platform_nand superlpplatform={
              tacls:0,
              twrph0:30,
              twrph1:0,
              sets: &nandset,
              nr_sets: 1,
              };
              /**************end add********/
              struct platform_device s 3c _device_nand = {
              .name               = "s 3c 2410-nand",
              .id             = -1,
              .num_resources       = ARRAY_SIZE(s 3c _nand_resource),
              .resource  = s 3c _nand_resource,
              /***********add here****************/
              .dev = {
              .platform_data = &superlpplatform
              }
              /**************end here************/
              };
2. 修改 arch\arm\mach-s 3c 2410\mach-smdk2410.c 文件
              Startic struct platform_device *smdk2410_devices[] __initdata={
                     &s 3c _device_usb,
                     &s 3c _device_lcd;
                     &s 3c _device_wdt,
                     &s 3c _device_i 2c ;
                     &s 3c _device_iis,
                     &s 3c _device_nand, /*add here*/
              };
    3. 修改 drivers/mtd/nand/s 3c 2410.c 禁止 flash ECC 校验
找到 s 3c 2410_nand_init_chip() 函数,在该函数体最后加上:
chip->ecc.mode = NAND_ECC_NONE;
    4. 支持启动时挂载 devfs
 
为了我们的内核支持 devfs 以及在启动时并在 /sbin/init 运行之前能自动挂载 /dev devfs 文件系统。
修改fs/kconfig文件
找到menu "Pseudo filesystems" 添加如下语句:
 config DEVFS_FS
  bool "/dev file system support (OBSOLETE)"
  default y
 config DEVFS_MOUNT
  bool "Automatically mount at boot"
  default y
  depends on DEVFS_FS
五. 做完以上修改以后,内核编译以后就可以在te2410 开发板上运行了。
       打开终端窗口,切换到 linux- 2.6.14 目录下,输入命令:
[root localhost linux- 2.6.14 ]# make smdk2410_defconfig
[root localhost linux- 2.6.14 ]#make menuconfig
增删的内核配置选项如下:
Loadable module suport--->
  • Enable loadable module suport
  • Automatic kernel module loading
  • System Type--->
  • S 3C 2410 DMA suport
  • Boot options --->Default kernel command string:
    noinitrd root=/dev/mtdblock3 init=/linuxrc console ttySAC0,115200
    mtdblock3 代表第四个flash分区,为root分区
    Floating point emulation---->
  • NWFPE math emulation
  • #MTD 子系统的配置
    Device Drivers--->
    Memory Technology Devices(MTD)--->
    ............................................
  • MTD partitioning support
  • Command line partition table parsing
  • ............................................
    NAND  Flash Device Drivers--->
    ................................
    <*>NAND Device Support
    <*>NAND Flash support foe S 3C 2410/S 3C 2440 Soc
    Character devices--->
    .............................
  • S3C2410 RTC Driver
  • File systems--->
    <>Second extended fs support # 去除ext2支持
    Pseudo filesystems--->
  • Virtual memory file system support(former shm fs)
  • /dev file system support(OBSOLETE)
  • Automatically mount at boot(NEW)
  • Miscellaneous filesystems--->
    ............................
    <*>cramfs
    .............................
    Network File Systems---->
    <*>NFS file system support
    [root localhost linux- 2.6.14 ]# make zImage
    编译完成以后,会生成镜像文件 arch/arm/boot/zImage ,把这个文件下载到开发板上!
    六 .修改vivi串口参数
    2.6 内核中, 2410 的串口由原来的 ttyS0 变为 ttySAC0 启动te2410目标板,进入vivi,在vivi提示符下输入:
    vivi>param set linux_cmd_line "noinitrd root=/dev/mtdblock/3  init=/linuxrc console=ttySAC0 115200"
    vivi>param save
     
    七.启动信息
        welcome           
    S 3C 2410 DEVELOP KIT                  
    VIVI version 0.1.4 ([email protected]) (gcc version 2.95.2 20000516 (re                                                                             
    lease) [Rebel.com]) # 0.1.4 12 24 13:09:55 CST 2006                 
    MMU table base address = 0x33DFC000                                  
    Succeed memory mapping.                      
    NAND device: Manufacture ID: 0xec, Chip ID: 0x76 (Samsung K9D1208V 0M )  
    Found saved vivi parameters.                            
    CS8900 - type: 630e, rev: a00                            
    CS8900 - status: ad6 (EEPROM present)                                    
    Setting MAC address...                     
    Display format changed to VGA 640X480 mode                                  
    Press Return to start the LINUX now, any other key for                     
    Copy linux kernel from 0x00030000 to 0x30008000, size = 0x 001c 0000 ... done 
    zImage magic = 0x 016f 2818                        
    Setup linux parameters at 0x30000100                                    
    linux command line is: "noinitrd root=/dev/mtdblock/3  init=/linuxrc console=ttySAC0 115200"            
    MACH_TYPE = 193              
    NOW, Booting Linux......                       
    Uncompressing Linux...........................................................
    ....... done, booting the kernel.                                
    Linux version 2.6.14 ([email protected]) (gcc version 3.4.1) #10 Mon Aug 27 08:43:35 CST 2007                     
    CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)                            
    Machine: SMDK2410                
    ATAG_INITRD is deprecated; please update your bootloader.                
    Memory policy: ECC disabled, Data cache writeback   
    CPU S 3C 2410A (id 0x32410002)                           
    S 3C 2410: core 200.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz 
    S 3C 2410 Clocks, (c) 2004 Simtec Electronics                              
    CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on                        
    CPU0: D VIVT write-back cache                            
    CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets           
    CPU0: D cache: 16384 bytes, associativity 64, 32                     
    Built 1 zonelists                
    Kernel command line: noinitrd root=/dev/mtdblock/3  init=/linuxrc console=ttySAC0 115200        
    irq: clearing subpending status 00000003                                       
    irq: clearing subpending status 00000002                                       
    PID hash table entries: 512 (order: 9, 8192 bytes)                      
    timer tcon=00000000, tcnt a 2c 1, tcfg 00000200,00000000, usec 00001eb8         
    Console: colour dummy device 80x30                                 
    Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)     
    Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)                                                           
    Memory: 64MB = 64MB total                        
    Memory: 62592KB available (1700K code, 379K data, 88K init)            
    Mount-cache hash table entries: 512                                   
    CPU: Testing write buffer coherency: ok                                      
    softlockup thread 0 started up.                              
    NET: Registered protocol family 16                                 
    S 3C 2410: Initialising architecture                                 
    S 3C 2410 DMA Driver, (c) 2003-2004 Simtec Electronics                   
    DMA channel 0 at c4800000, irq 33                                
    DMA channel 1 at c4800040, irq 34                                
    DMA channel 2 at c4800080, irq 35                                
    DMA channel 3 at c 48000c 0, irq 36                                
    NetWinder Floating Point Emulator V0.97 (double precision)             
    devfs: 2004-01-31 Richard Gooch                                
    devfs: boot_options: 0x1                       
    Console: switching to colour frame buffer device 80x25                  
    fb0: Virtual frame buffer device, using 1024K of video memory               
    S 3C 2410 RTC, (c) 2004 Simtec Electronics                                       
    s 3c 2410_serial0 at MMIO 0x50000000 (irq = 70) is a S 3C 2410                
    s 3c 2410_serial1 at MMIO 0x50004000 (irq = 73) is a S 3C 2410                
    s 3c 2410_serial2 at MMIO 0x50008000 (irq = 76) is a S 3C 2410                  
    io scheduler noop registered                           
    io scheduler anticipatory registered                                   
    io scheduler deadline registered                               
    io scheduler cfq registered                          
    RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize        
    S 3C 24XX NAND Driver, (c) 2004 Simtec Electronics                    
    s 3c 2410-nand: mapped registers at c4980000                             
    s 3c 2410-nand: timing: Tacls 10ns, Twrph0 40ns, Twrph1 10ns                                                         
    NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
    NAND_ECC_NONE selected by board driver. This is not recommended !! 
    Scanning device for bad blocks                             
    Creating 5 MTD partitions on "NAND 64MiB 3,3V 8-bit":                    
    0x00000000-0x00020000 : "vivi"                             
    0x00020000-0x00030000 : "param                            
    0x00030000-0x 001f 0000 : "kernel"                               
    0x00200000-0x00600000 : "root"                             
    0x00600000-0x04000000 : "usr"                            
    mice: PS/2 mouse device common for all mice      
    NET: Registered protocol family 2                                 
    IP route cache hash table entries: 1024 (order: 0, 4096 bytes)       
    TCP established hash table entries: 4096 (order: 2, 16384 bytes)      
    TCP bind hash table entries: 4096 (order: 2, 16384 bytes)          
    TCP: Hash tables configured (established 4096 bind 4096)                
    TCP reno registered                  
    TCP bic registered                 
    NET: Registered protocol family 1                                
    Reading data from NAND FLASH w                            
    VFS: Mounted root (cramfs filesystem) readonly.        
    Mounted devfs on /dev                    
    Freeing init memory: 88K                       
    mount /etc as ramfs                  
    re-create the /etc/mtab entries                              
    insmod: QM_MODULES: Function not implemented        
    Reading data from NAND FLASH without ECC is not recommended
    mount: Mounting /dev/mtdblock/4 on /usr failed: No such device
    insmod: QM_MODULES: Function not implemented
    insmod: QM_MODULES: Function not implemented
    insmod: QM_MODULES: Function not implemented
    insmod: QM_MODULES: Function not implemented
    console=/dev/console
    init started:  BusyBox v0.60.3 (2002.05.13-08:36+0000) multi-call binary
    Starting pid 28, console /dev/console: '/etc/init.d/rcS'
    exec: /usr/etc/rc.local: No such file or directory
    Waiting for enter to start '/bin/sh' (pid 31, terminal /dev/console)
    Please press Enter to activate this console.
    Starting pid 31, console /dev/console: '/bin/sh'
    BusyBox v0.60.3 (2002.05.13-08:36+0000) Built-in shell (ash)
    Enter 'help' for a list of built-in commands.
    #

    你可能感兴趣的:(职场,系统,移植,休闲)