主题 : 内核移植问题(求助) 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 18721
精华: 0
发帖: 2
金钱: 10 两
威望: 2 点
综合积分: 4 分
注册时间: 2010-04-12
最后登录: 2010-05-25
楼主  发表于: 2010-05-13 16:10

 内核移植问题(求助)

                        2.6内核移植笔记移植

移植2.6.21.1内核到at91rm9200
1.下载、安装(准备工作)
   下载:linux-2.6.21.1内核源码,其中把linux-2.6.21.1内核源码放到了home目录下。
    #cd  home
   #tar -jxvf  linux-2.6.21.1.tar.bz2
  
   下载:2.6.21-at91.patch.gz  9200内核补丁
    #cd  home
    #cp 2.6.21-at91.patch.gz linux-2.6.21.1
   #cd linux-2.6.21.1
    #zcat 2.6.21-at91.patch.gz |patch -p1
   下载:yaffs2.tar.gz
   #cd home
   #cd yaffs2
   #sh patch-ker.sh l /home/linux-2.6.21.1

2.对内核进行修改:
   1.修改根目录的Makefile
      #cd  linux-2.6.21.1
      #gedit Makefile
      找到如下两行:
      ARCH ?=$(SUBARCH)
      CROSS_COMPILE ?=
      修改为:
      ARCH ?=arm
      CROSS_COMPILE ?=/home/usr/local/arm/3.4.1/bin/arm-linux-
   2.修改arch/arm/tools/mach-types
      #cd linux-2.6.21.1
      #gedit arch/arm/tools/mach-types
     更改:
     at91rm9200dk  ARCH_AT91RM9200DK AT91RM9200DK     262
     为:
     at91rm9200dk  ARCH_AT91RM9200DK AT91RM9200DK     251
  
                    
    3.添加devfs文件系统
      #cd  linux-2.6.21.1
      #gedit  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
     注释:让内核在编译时加入devfs文件系统支持,在后面的
              make menuconfig   中可以看到,加入这些内容之后就出现了
             与devfs相关的配置选项。默认设置为:defaulty,即默认被选中。
    
   4.修改arch/arm/mach-at91目录下的相关文件NAND的分区表
      #cd  linux-2.6.21.1
      #gedit arch/arm/mach-at91/board-dk.c
     修改串口设置:
     static struct at91_uart_config __initdata dk_uart_config = {
    
                              .console_tty= 0,         /* ttyS0 */
    
                              .nr_tty = 5,            
                              .tty_map    = { 4, 1, 2, 3, 0 }    /* ttyS0, ..., ttyS4 */        
                  };
    
static struct mtd_partition __initdata dk_nand_partition[] = {

/*    {                                
.name    = "NAND Partition 1",
        
.offset    = 0,
        
.size    = 64 * SZ_1M,
    },

*/
      
{ name: "AT91 NAND partition 1",
          
offset:  0,
          
size:   16 * SZ_1M },
        
{ name: "AT91 NAND partition 2",
          
offset:  16 * SZ_1M,
        
size:   16 * SZ_1M },
        
{ name: "AT91 NAND partition 3",
          
offset: (16 * SZ_1M) + (16 * SZ_1M),
        
size:   32 * SZ_1M },


};


   5.修改NOR的分区表
      #cd  linux-2.6.21.1
      # gedit drivers/mtd/maps/physmap.c
  #ifdef CONFIG_MTD_PARTITIONS
static struct mtd_partition mtd_parts[3] =
{
        
        {
          
     name: " bootloader  ",
            
    offset: 0x00000,
            
    size: 0x20000,
            
    mask_flags: MTD_WRITEABLE,
        
       },
        
      {
            
    name: " uImage  ",
            
    offset: 0x020000,
          
     size: 0x180000,
      
       },
        
      {
            
    name: " ramdisk  ",
            
    offset: 0x1a0000,
            
    size: 0x660000,
        
       },

};

配置内核:
#cd linux-2.6.21.1
#make at91rm9200dk_defconfig
#make xconfig(配置所需选项)
#make
生成zImage。

生成zImage后,通过tftp下载开发版。
(loader.bin 、u-boot.bin、boot.bin、u-boot.gz、ramdisk.gz、rootfs_cs.tar.gz、zImage,zImageR)
其中:loader.bin 、u-boot.bin、boot.bin、u-boot.gz、ramdisk.gz、rootfs_cs.tar.gz是版子配套提供的文件
zImage和zImageR是同一文件名字不同而已
烧入过程打印信息:
**************************************************
**            Welcome to HYESCO                 **
**           http://www.hyesco.com              **
**            Tel:86-10-51906927/28/30           **
**************************************************

Copy data from flash to sdram,waiting....
Done
Decompress image success!


U-Boot 1.0.0 (Sep 19 2007 - 16:57:06)

U-Boot code: 21F00000 -> 21F1A96C  BSS: -> 21F264D4
DRAM Configuration:
Bank #0: 20000000 32 MB
Fujitsu: 29LV320BE(32Mbit)
Flash:  8 MB
NAND:Flash chip found:
         Manufacturer ID: 0xEC, Chip ID: 0x76 (Samsung K9F1208UOA)
1 flash chips found. Total nand_chip size: 64 MB
  64 MB
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
TFTP from server 192.168.0.6; our IP address is 192.168.0.2
Filename 'zImageR'.
Load address: 0x21000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         ################################
done
Bytes transferred = 1490812 (16bf7c hex)
TFTP from server 192.168.0.6; our IP address is 192.168.0.2
Filename 'ramdisk.gz'.
Load address: 0x20410000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #############
done
Bytes transferred = 4058114 (3dec02 hex)
## Starting application at 0x21000000 ...
Uncompressing Linux................................................................................................ done, booting the kernel.
Linux version 2.6.21.1 (root@liuzhuang) (gcc version 3.4.1) #2 PREEMPT Thu May 13 15:47:24 CST 2010
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
Machine: Atmel AT91RM9200-DK
Warning: bad configuration page, trying to continue
Memory policy: ECC disabled, Data cache writeback
Clocks: CPU 179 MHz, master 59 MHz, main 18.432 MHz
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 byte lines, 8 sets
Built 1 zonelists.  Total pages: 8128
Kernel command line: root=/dev/ram rw initrd=0x20410000,6000000 ramdisk_size=15360 console=ttyS0,115200 mem=32M
AT91: 128 gpio irqs in 4 banks
PID hash table entries: 128 (order: 7, 512 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 32MB = 32MB total
Memory: 23556KB available (2732K code, 187K data, 108K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd
Freeing initrd memory: 5859K
NetWinder Floating Point Emulator V0.97 (extended precision)
JFFS2 version 2.2. (NAND) (C) 2001-2006 Red Hat, Inc.
yaffs May 13 2010 15:22:32 Installing.
io scheduler noop registered
io scheduler anticipatory registered (default)
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xfffc4000 (irq = 7) is a ATMEL_SERIAL
atmel_usart.2: ttyS2 at MMIO 0xfffc8000 (irq = 8) is a ATMEL_SERIAL
atmel_usart.3: ttyS3 at MMIO 0xfffcc000 (irq = 9) is a ATMEL_SERIAL
atmel_usart.4: ttyS4 at MMIO 0xfffc0000 (irq = 6) is a ATMEL_SERIAL
RAMDISK driver initialized: 16 RAM disks of 15360K size 1024 blocksize
loop: loaded (max 8 devices)
PPP generic driver version 2.4.2
eth0: Link now 100-FullDuplex
eth0: AT91 ethernet at 0xfefbc000 int=24 100-FullDuplex (00:12:34:56:78:9a)
eth0: Davicom 9161 PHY (Copper)
physmap platform flash device: 00800000 at 10000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
Amd/Fujitsu Extended Query Table at 0x0040
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
Creating 3 MTD partitions on "physmap-flash.0":
0x00000000-0x00020000 : " bootloader  "
0x00020000-0x001a0000 : " uImage  "
0x001a0000-0x00800000 : " ramdisk  "
No SmartMedia card inserted.
at91_nand: probe of at91_nand failed with error 6
at91_cf: irqs det #64, io #0
usbmon: debugfs is not available
at91_ohci at91_ohci: AT91 OHCI
at91_ohci at91_ohci: new USB bus registered, assigned bus number 1
at91_ohci at91_ohci: irq 23, io mem 0x00300000
usb usb1: Product: AT91 OHCI
usb usb1: Manufacturer: Linux 2.6.21.1 ohci_hcd
usb usb1: SerialNumber: at91
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usb 1-2: new low speed USB device using at91_ohci and address 2
usb 1-2: device descriptor read/64, error -62
usb 1-2: device descriptor read/64, error -62
usb 1-2: new low speed USB device using at91_ohci and address 3
usb 1-2: device descriptor read/64, error -62
usb 1-2: device descriptor read/64, error -62
usb 1-2: new low speed USB device using at91_ohci and address 4
usb 1-2: device not accepting address 4, error -62
usb 1-2: new low speed USB device using at91_ohci and address 5
usb 1-2: device not accepting address 5, error -62
usbcore: registered new interface driver usblp
drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver
usbcore: registered new interface driver usbhid
drivers/usb/input/hid-core.c: v2.6:USB HID core driver
udc: at91_udc version 3 May 2006
mice: PS/2 mouse device common for all mice
i2c /dev entries driver
at91_i2c at91_i2c: AT91 i2c bus driver.
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
RAMDISK: Compressed image found at block 0
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem).
Freeing init memory: 108K
eth0: Setting MAC address to 00:3c:b1:6d:ec:07
eth0: Link now 100-FullDuplex


BusyBox v1.1.3 (2008.02.28-03:45+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

[root@(none) /]$
之后是挂载根文件:
$ cd /root
    $ rm -rf *ls      
    开启虚拟机linux的nfs 服务端,rootfs_cs.tar.gz解压缩,将mnt文件拷贝到linux下的/home/work文件夹通过nfs挂载。
    开启nfs: 输入/etc/rc.d/init.d/portmap start  和/etc/rc.d/init.d/nfs start 命令
    $ mount -t nfs -o nolock 192.168.0.22:/home/work /mnt/nfs
    $ cp -af /mnt/nfs/rootfs_cs/* /root
拷贝完成后,复位系统,进入u-boot,修改环境变量,断电从新启动开发版,进入内核的打印信息:

**************************************************
**            Welcome to HYESCO                 **
**           http://www.hyesco.com              **
**            Tel:86-10-51906927/28/30           **
**************************************************

Copy data from flash to sdram,waiting....
Done
Decompress image success!


U-Boot 1.0.0 (Sep 19 2007 - 16:57:06)

U-Boot code: 21F00000 -> 21F1A96C  BSS: -> 21F264D4
DRAM Configuration:
Bank #0: 20000000 32 MB
Fujitsu: 29LV320BE(32Mbit)
Flash:  8 MB
NAND:Flash chip found:
         Manufacturer ID: 0xEC, Chip ID: 0x76 (Samsung K9F1208UOA)
1 flash chips found. Total nand_chip size: 64 MB
  64 MB
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
## Starting application at 0x21000000 ...
Uncompressing Linux................................................................................................ done, booting the kernel.
Linux version 2.6.21.1 (root@liuzhuang) (gcc version 3.4.1) #2 PREEMPT Thu May 13 15:47:24 CST 2010
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
Machine: Atmel AT91RM9200-DK
Warning: bad configuration page, trying to continue
Memory policy: ECC disabled, Data cache writeback
Clocks: CPU 179 MHz, master 59 MHz, main 18.432 MHz
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 byte lines, 8 sets
Built 1 zonelists.  Total pages: 8128
Kernel command line: root=/dev/ram rw initrd=0x20410000,6000000 ramdisk_size=15360 console=ttyS0,115200 mem=32M
AT91: 128 gpio irqs in 4 banks
PID hash table entries: 128 (order: 7, 512 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 32MB = 32MB total
Memory: 23556KB available (2732K code, 187K data, 108K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
checking if image is initramfs...it isn't (bad gzip magic numbers); looks like an initrd
Freeing initrd memory: 5859K
NetWinder Floating Point Emulator V0.97 (extended precision)
JFFS2 version 2.2. (NAND) (C) 2001-2006 Red Hat, Inc.
yaffs May 13 2010 15:22:32 Installing.
io scheduler noop registered
io scheduler anticipatory registered (default)
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xfffc4000 (irq = 7) is a ATMEL_SERIAL
atmel_usart.2: ttyS2 at MMIO 0xfffc8000 (irq = 8) is a ATMEL_SERIAL
atmel_usart.3: ttyS3 at MMIO 0xfffcc000 (irq = 9) is a ATMEL_SERIAL
atmel_usart.4: ttyS4 at MMIO 0xfffc0000 (irq = 6) is a ATMEL_SERIAL
RAMDISK driver initialized: 16 RAM disks of 15360K size 1024 blocksize
loop: loaded (max 8 devices)
PPP generic driver version 2.4.2
at91_ether: Your bootloader did not configure a MAC address.
eth0: Link now 100-FullDuplex
eth0: AT91 ethernet at 0xfefbc000 int=24 100-FullDuplex (00:00:00:00:00:00)
eth0: Davicom 9161 PHY (Copper)
physmap platform flash device: 00800000 at 10000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
Amd/Fujitsu Extended Query Table at 0x0040
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
Creating 3 MTD partitions on "physmap-flash.0":
0x00000000-0x00020000 : " bootloader  "
0x00020000-0x001a0000 : " uImage  "
0x001a0000-0x00800000 : " ramdisk  "
No SmartMedia card inserted.
at91_nand: probe of at91_nand failed with error 6
at91_cf: irqs det #64, io #0
usbmon: debugfs is not available
at91_ohci at91_ohci: AT91 OHCI
at91_ohci at91_ohci: new USB bus registered, assigned bus number 1
at91_ohci at91_ohci: irq 23, io mem 0x00300000
usb usb1: Product: AT91 OHCI
usb usb1: Manufacturer: Linux 2.6.21.1 ohci_hcd
usb usb1: SerialNumber: at91
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver usblp
drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver
usbcore: registered new interface driver usbhid
drivers/usb/input/hid-core.c: v2.6:USB HID core driver
udc: at91_udc version 3 May 2006
mice: PS/2 mouse device common for all mice
i2c /dev entries driver
at91_i2c at91_i2c: AT91 i2c bus driver.
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
RAMDISK: Couldn't find valid RAM disk image starting at 0.
yaffs: dev is 1048576 name is "ram0"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 1.0, "ram0"
yaffs: dev is 1048576 name is "ram0"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 1.0, "ram0"
No filesystem could mount root, tried:  ext2 msdos vfat yaffs yaffs2
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)


问题多多 ,欢迎大家指证,给出意见。
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2010-05-13 16:33
$ cp -af /mnt/nfs/rootfs_cs/* /root

这里的/root是从哪里挂载的?应该是某个NAND Flash的partition吧
不过从
at91_nand: probe of at91_nand failed with error 6

看,你板子上的NAND Flash似乎没有被Linux正确识别,也就是说,文件系统是没有被正确写入NAND Flash

第二次启动,用
Kernel command line: root=/dev/ram rw initrd=0x20410000,6000000 ramdisk_size=15360 console=ttyS0,115200 mem=32M

如果你想从NAND Flash挂载根文件系统,应该写成root=/dev/mtdblockX, 其中X是包含文件系统的NAND Flash分区对应的序号
"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."
Linux@ARM
级别: 新手上路
UID: 2478
精华: 0
发帖: 48
金钱: 410 两
威望: 354 点
综合积分: 96 分
注册时间: 2008-11-19
最后登录: 2018-02-08
2楼  发表于: 2010-05-17 10:14
0x00000000-0x00020000 : " bootloader  "
0x00020000-0x001a0000 : " uImage  "
0x001a0000-0x00800000 : " ramdisk  "

看看你的分区和你挂载的分区对不对。。。
欢迎访问Linux@ARM博客:
http://l0p0c.cublog.cn