成功移植linux2.6.38内核到TQ2440(转)



    经过一个星期的不停修改错误,看代码,每天都忙到2点才睡,今天终于解决了所有问题,成功移植linux2.6.38内核到TQ2440。

移植步骤:

1.修改根目录的Makefile中的ARCH=arm,CROSS-COMPILE=arm-linux-

2.在arch/arm/mach-s3c2440/mach-smdk2440.c中,将163行的s3c24xx_init_clocks(16934400)改为s3c24xx_init_clocks(12000000)。

3.修改arch/arm/tools/mach-types中379行的362改为168,因为uboot中定义的机器码是168.

4.修改arch/arm/boot/中的Makefile文件,在58行添加@cp -f arch/arm/boot/zImage zImage.bin,实现把生成的zImage文件复制到内核源码根目录下。

5.在根目录的Makefile的1164行添加rm -f zImage.bin,使得在执行make distclean在清除产生的文件的同时,把内核根目录下的zImage也清除。

6.修改arch/arm/plat-s3c24xx/common-smdk.c中111行的static struct mtd_partition smdk_default_nand_part[]的nandflash分区为:
 [0] = {
  .name  = "Andy_uboot",
  .offset = 0x00000000,
  .size  = 0x00040000,
 },
 [1] = {
  .name  = "Andy_kernel",
  .offset = 0x00200000,
  .size  = 0x00200000,
 },
 [2] = {
  .name  = "Andy_yaffs2",
  .offset = 0x00400000,
  .size  = 0x0FB80000,
 }

7.修改drivers/mtd/nand/s3c2410.c中的839行为chip->ecc.mode=NAND_ECC_NONE;

8.修改arch/arm/mach-s3c2440/mach-smdk2440.c中100行为.ulcon = 0x03。

9.在drivers/serial/samsung.c的51行添加
   #include <mach/regs-gpio.h>
   #include <linux/gpio.h>
  在433行添加:
 if (port->line == 2) {
     s3c2410_gpio_cfgpin(S3C2410_GPH(6), S3C2410_GPH6_TXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(6), 1);
     s3c2410_gpio_cfgpin(S3C2410_GPH(7), S3C2410_GPH7_RXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(7), 1);
 }

10.用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
./patch-kernel.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

11.用make menuconfig配置linux内核。

12.执行make zImage,将生成的zImage.bin下载到TQ2440。

13.制作文件系统。

解压busybox-1.18.4.tar.bz2,修改busybox-1.18.4中的Makefile,在164行和190行分别修改为CROSS-COMPILE=arm-linux-和ARCH=arm。执行make,然后在执行make install。将生成_install复制到根目录,添加文件系统文件,用天嵌提供的mkyaffs2image生成root.bin的可执行文件,下载到开发板。

14.启动开发板,打印信息如下:

Start Linux ...
Copy linux kernel from 0x00200000 to 0x30008000, size = 0x00200000 ... Copy Kernel to SDRAM done,NOW, Booting Linux......
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.38-Andy (root@Andy) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-176) ) #15 Fri Apr 8 20:21:42 CST 2011
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: Andy's TQ2440 development board!
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60896k/60896k available, 4640k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0025000   ( 116 kB)
      .text : 0xc0025000 - 0xc0399000   (3536 kB)
      .data : 0xc039a000 - 0xc03bac40   ( 132 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 97 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.23.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
msgmni has been set to 118
io scheduler noop registered (default)
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
loop: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=2, 20ns Twrph0=6 60ns, Twrph1=2 20ns
s3c24xx-nand s3c2440-nand: NAND ECC disabled
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
NAND_ECC_NONE selected by board driver. This is not recommended !!
Scanning device for bad blocks
Bad eraseblock 62 at 0x0000007c0000
Bad eraseblock 1435 at 0x00000b360000
cmdlinepart partition parsing not available
Creating 3 MTD partitions on "NAND":
0x000000000000-0x000000040000 : "Andy_uboot"
0x000000200000-0x000000400000 : "Andy_kernel"
0x000000400000-0x00000ff80000 : "Andy_yaffs2"
dm9000 Ethernet Driver, V1.31
Now use the default MAC address: 10:23:45:67:89:ab
eth0: dm9000e at c4810000,c4814004 IRQ 51 MAC: 10:23:45:67:89:ab (EmbedSky)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 2.6.38-Andy ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
s3c2410_udc: debugfs dir creation failed -19
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
ALSA device list:
  No soundcards found.
TCP cubic registered
lib80211: common routines for IEEE802.11 drivers
s3c-rtc s3c2410-rtc: setting system clock to 2000-01-02 00:47:19 UTC (946774039)
yaffs: dev is 32505858 name is "mtdblock2" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 116K

Please press Enter to activate this console.

    移植过程中产生的问题及其解决方法将在下一节说明。还有一些驱动没有移植。继续努力!

 

 

 

 

 

在移植linux2.6.38过程中,遇见了很多的问题,通过在网上查阅相关信息和在图书馆不停的查阅资料,终于成功了。下面将移植过程中产生的问题及其解放方法与大家共享一下。

1、编译内核时yaffs2出现unknown field 'clear_inode' specified in initializer的

错误,原因是所下载的yaffs2不支持linux2.6.38.
   解决方法:最新的yaffs2采用git发布,所以采用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
 ./patch-ker.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

 

2、移植linux内核到开发板后,出现data abort的错误,错误原因为内核大小超过了2M,

天嵌的Uboot只分配给内核2M的空间,所以报错。
   解决方法:精简内核,使其小于2M。或者修改Uboot,是内核大小大于2M。
所以个人认为天嵌的Uboot值得改进,下一步我将移植Uboot,用自己的Uboot就不存在这个问题了。嘿嘿

 

3.移植内核时,出现Uncompressing Linux... done, booting the kernel后,系统不能启动,网上好多人说是因为在menuconfig选项中的Boot options中的Default kernel command string中没有设置noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0 rootfs=yaffs2 rw。其实不用设置这个参数也可以,我采用在内核配置文件中将Kernel Feature/Provide old way to pass kernel parameters选上就行了,因为天嵌用的bootloader太老了,从打印的内核信息中就可以看出。(ATAG_INITRD is deprecated; please update your bootloader.)

 

4.内核启动时,出现Failed to execute /linuxrc的错误,原因是:
(1)文件系统中没有包含linuxrc的可执行文件。在文件系统中添加linuxrc就可完成linux的启动。
(2)在/driver/mtd/nand/s3c2410.c中将chip->ecc.mode = NAND_ECC_SOFT;改为chip->ecc.mode = NAND_ECC_NONE;并在配置内核中将Samsung S3C NAND Hardware ECC选项删掉。

    这个问题纠结了我好久,我遇见这个问题后,先尝试用nfs挂载,能够挂载上,所以我确定肯定是nandflash出了问题了,以为nandflash坏了(因为被我不停的擦写,嘿嘿),后来用天嵌自带的镜像试了是好的,我就明白了,估计是我的nand驱动有问题了,仔细检查驱动,发现内核配置中的Samsung S3C NAND Hardware ECC没有去掉,移植linux2.6.38产生的问题及其解决方法,一个小小的问题折磨了我这么久。所以一定一定要仔细啊。

 

5.编译串口驱动是出现error: implicit declaration of function 's3c2410_gpio_cfgpin'的错误,是因为内核版本2.6.38的内核定义s3c2410_gpio_cfgpin是在linux/gpio.h中,所以添加#include <linux/gpio.h>后即可。

 

6.编译串口驱动是出现error: 'S3C2410_GPH6' undeclared (first use in this function)是因为在内核版本2.6.38的内核定义s3c2410_gpio_cfgpin的函数变量采用的是S3C2410_GPH(6),而非S3C2410_GPH6,将其改为S3C2410_GPH(6)即可解决问题。

 

7.linux内核2.6.38的串口程序samsung.c在/driver/tty/serial中。这里与原来的内核版本不一致。这个要注意,内核版本改了,接口也改了,我当时找不到samsung.c,然后通过find命令一看,晕,原来在这里面。

 

8.在添加yaffs2内核支持时,找不到Kconfig,复制Yaffs2文件夹中的Kconfig_muti到linux内核的fs/yaffs2中,并将Kconfig_muti修改为Kconfig。

 

    还有一下细小的问题就不在这说了,有其他问题的朋友我们可以一起探讨,我们一起进步!最后,小小祝贺自己一下,今天终于可以睡个好觉了!哈哈!

    经过一个星期的不停修改错误,看代码,每天都忙到2点才睡,今天终于解决了所有问题,成功移植linux2.6.38内核到TQ2440。

移植步骤:

1.修改根目录的Makefile中的ARCH=arm,CROSS-COMPILE=arm-linux-

2.在arch/arm/mach-s3c2440/mach-smdk2440.c中,将163行的s3c24xx_init_clocks(16934400)改为s3c24xx_init_clocks(12000000)。

3.修改arch/arm/tools/mach-types中379行的362改为168,因为uboot中定义的机器码是168.

4.修改arch/arm/boot/中的Makefile文件,在58行添加@cp -f arch/arm/boot/zImage zImage.bin,实现把生成的zImage文件复制到内核源码根目录下。

5.在根目录的Makefile的1164行添加rm -f zImage.bin,使得在执行make distclean在清除产生的文件的同时,把内核根目录下的zImage也清除。

6.修改arch/arm/plat-s3c24xx/common-smdk.c中111行的static struct mtd_partition smdk_default_nand_part[]的nandflash分区为:
 [0] = {
  .name  = "Andy_uboot",
  .offset = 0x00000000,
  .size  = 0x00040000,
 },
 [1] = {
  .name  = "Andy_kernel",
  .offset = 0x00200000,
  .size  = 0x00200000,
 },
 [2] = {
  .name  = "Andy_yaffs2",
  .offset = 0x00400000,
  .size  = 0x0FB80000,
 }

7.修改drivers/mtd/nand/s3c2410.c中的839行为chip->ecc.mode=NAND_ECC_NONE;

8.修改arch/arm/mach-s3c2440/mach-smdk2440.c中100行为.ulcon = 0x03。

9.在drivers/serial/samsung.c的51行添加
   #include <mach/regs-gpio.h>
   #include <linux/gpio.h>
  在433行添加:
 if (port->line == 2) {
     s3c2410_gpio_cfgpin(S3C2410_GPH(6), S3C2410_GPH6_TXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(6), 1);
     s3c2410_gpio_cfgpin(S3C2410_GPH(7), S3C2410_GPH7_RXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(7), 1);
 }

10.用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
./patch-kernel.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

11.用make menuconfig配置linux内核。

12.执行make zImage,将生成的zImage.bin下载到TQ2440。

13.制作文件系统。

解压busybox-1.18.4.tar.bz2,修改busybox-1.18.4中的Makefile,在164行和190行分别修改为CROSS-COMPILE=arm-linux-和ARCH=arm。执行make,然后在执行make install。将生成_install复制到根目录,添加文件系统文件,用天嵌提供的mkyaffs2image生成root.bin的可执行文件,下载到开发板。

14.启动开发板,打印信息如下:

Start Linux ...
Copy linux kernel from 0x00200000 to 0x30008000, size = 0x00200000 ... Copy Kernel to SDRAM done,NOW, Booting Linux......
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.38-Andy (root@Andy) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-176) ) #15 Fri Apr 8 20:21:42 CST 2011
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: Andy's TQ2440 development board!
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60896k/60896k available, 4640k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0025000   ( 116 kB)
      .text : 0xc0025000 - 0xc0399000   (3536 kB)
      .data : 0xc039a000 - 0xc03bac40   ( 132 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 97 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.23.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
msgmni has been set to 118
io scheduler noop registered (default)
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
loop: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=2, 20ns Twrph0=6 60ns, Twrph1=2 20ns
s3c24xx-nand s3c2440-nand: NAND ECC disabled
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
NAND_ECC_NONE selected by board driver. This is not recommended !!
Scanning device for bad blocks
Bad eraseblock 62 at 0x0000007c0000
Bad eraseblock 1435 at 0x00000b360000
cmdlinepart partition parsing not available
Creating 3 MTD partitions on "NAND":
0x000000000000-0x000000040000 : "Andy_uboot"
0x000000200000-0x000000400000 : "Andy_kernel"
0x000000400000-0x00000ff80000 : "Andy_yaffs2"
dm9000 Ethernet Driver, V1.31
Now use the default MAC address: 10:23:45:67:89:ab
eth0: dm9000e at c4810000,c4814004 IRQ 51 MAC: 10:23:45:67:89:ab (EmbedSky)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 2.6.38-Andy ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
s3c2410_udc: debugfs dir creation failed -19
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
ALSA device list:
  No soundcards found.
TCP cubic registered
lib80211: common routines for IEEE802.11 drivers
s3c-rtc s3c2410-rtc: setting system clock to 2000-01-02 00:47:19 UTC (946774039)
yaffs: dev is 32505858 name is "mtdblock2" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 116K

Please press Enter to activate this console.

    移植过程中产生的问题及其解决方法将在下一节说明。还有一些驱动没有移植。继续努力!

 

 

 

 

 

在移植linux2.6.38过程中,遇见了很多的问题,通过在网上查阅相关信息和在图书馆不停的查阅资料,终于成功了。下面将移植过程中产生的问题及其解放方法与大家共享一下。

1、编译内核时yaffs2出现unknown field 'clear_inode' specified in initializer的

错误,原因是所下载的yaffs2不支持linux2.6.38.
   解决方法:最新的yaffs2采用git发布,所以采用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
 ./patch-ker.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

 

2、移植linux内核到开发板后,出现data abort的错误,错误原因为内核大小超过了2M,

天嵌的Uboot只分配给内核2M的空间,所以报错。
   解决方法:精简内核,使其小于2M。或者修改Uboot,是内核大小大于2M。
所以个人认为天嵌的Uboot值得改进,下一步我将移植Uboot,用自己的Uboot就不存在这个问题了。嘿嘿

 

3.移植内核时,出现Uncompressing Linux... done, booting the kernel后,系统不能启动,网上好多人说是因为在menuconfig选项中的Boot options中的Default kernel command string中没有设置noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0 rootfs=yaffs2 rw。其实不用设置这个参数也可以,我采用在内核配置文件中将Kernel Feature/Provide old way to pass kernel parameters选上就行了,因为天嵌用的bootloader太老了,从打印的内核信息中就可以看出。(ATAG_INITRD is deprecated; please update your bootloader.)

 

4.内核启动时,出现Failed to execute /linuxrc的错误,原因是:
(1)文件系统中没有包含linuxrc的可执行文件。在文件系统中添加linuxrc就可完成linux的启动。
(2)在/driver/mtd/nand/s3c2410.c中将chip->ecc.mode = NAND_ECC_SOFT;改为chip->ecc.mode = NAND_ECC_NONE;并在配置内核中将Samsung S3C NAND Hardware ECC选项删掉。

    这个问题纠结了我好久,我遇见这个问题后,先尝试用nfs挂载,能够挂载上,所以我确定肯定是nandflash出了问题了,以为nandflash坏了(因为被我不停的擦写,嘿嘿),后来用天嵌自带的镜像试了是好的,我就明白了,估计是我的nand驱动有问题了,仔细检查驱动,发现内核配置中的Samsung S3C NAND Hardware ECC没有去掉,移植linux2.6.38产生的问题及其解决方法,一个小小的问题折磨了我这么久。所以一定一定要仔细啊。

 

5.编译串口驱动是出现error: implicit declaration of function 's3c2410_gpio_cfgpin'的错误,是因为内核版本2.6.38的内核定义s3c2410_gpio_cfgpin是在linux/gpio.h中,所以添加#include <linux/gpio.h>后即可。

 

6.编译串口驱动是出现error: 'S3C2410_GPH6' undeclared (first use in this function)是因为在内核版本2.6.38的内核定义s3c2410_gpio_cfgpin的函数变量采用的是S3C2410_GPH(6),而非S3C2410_GPH6,将其改为S3C2410_GPH(6)即可解决问题。

 

7.linux内核2.6.38的串口程序samsung.c在/driver/tty/serial中。这里与原来的内核版本不一致。这个要注意,内核版本改了,接口也改了,我当时找不到samsung.c,然后通过find命令一看,晕,原来在这里面。

 

8.在添加yaffs2内核支持时,找不到Kconfig,复制Yaffs2文件夹中的Kconfig_muti到linux内核的fs/yaffs2中,并将Kconfig_muti修改为Kconfig。

 

    还有一下细小的问题就不在这说了,有其他问题的朋友我们可以一起探讨,我们一起进步!最后,小小祝贺自己一下,今天终于可以睡个好觉了!哈哈!




    经过一个星期的不停修改错误,看代码,每天都忙到2点才睡,今天终于解决了所有问题,成功移植linux2.6.38内核到TQ2440。

移植步骤:

1.修改根目录的Makefile中的ARCH=arm,CROSS-COMPILE=arm-linux-

2.在arch/arm/mach-s3c2440/mach-smdk2440.c中,将163行的s3c24xx_init_clocks(16934400)改为s3c24xx_init_clocks(12000000)。

3.修改arch/arm/tools/mach-types中379行的362改为168,因为uboot中定义的机器码是168.

4.修改arch/arm/boot/中的Makefile文件,在58行添加@cp -f arch/arm/boot/zImage zImage.bin,实现把生成的zImage文件复制到内核源码根目录下。

5.在根目录的Makefile的1164行添加rm -f zImage.bin,使得在执行make distclean在清除产生的文件的同时,把内核根目录下的zImage也清除。

6.修改arch/arm/plat-s3c24xx/common-smdk.c中111行的static struct mtd_partition smdk_default_nand_part[]的nandflash分区为:
 [0] = {
  .name  = "Andy_uboot",
  .offset = 0x00000000,
  .size  = 0x00040000,
 },
 [1] = {
  .name  = "Andy_kernel",
  .offset = 0x00200000,
  .size  = 0x00200000,
 },
 [2] = {
  .name  = "Andy_yaffs2",
  .offset = 0x00400000,
  .size  = 0x0FB80000,
 }

7.修改drivers/mtd/nand/s3c2410.c中的839行为chip->ecc.mode=NAND_ECC_NONE;

8.修改arch/arm/mach-s3c2440/mach-smdk2440.c中100行为.ulcon = 0x03。

9.在drivers/serial/samsung.c的51行添加
   #include <mach/regs-gpio.h>
   #include <linux/gpio.h>
  在433行添加:
 if (port->line == 2) {
     s3c2410_gpio_cfgpin(S3C2410_GPH(6), S3C2410_GPH6_TXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(6), 1);
     s3c2410_gpio_cfgpin(S3C2410_GPH(7), S3C2410_GPH7_RXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(7), 1);
 }

10.用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
./patch-kernel.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

11.用make menuconfig配置linux内核。

12.执行make zImage,将生成的zImage.bin下载到TQ2440。

13.制作文件系统。

解压busybox-1.18.4.tar.bz2,修改busybox-1.18.4中的Makefile,在164行和190行分别修改为CROSS-COMPILE=arm-linux-和ARCH=arm。执行make,然后在执行make install。将生成_install复制到根目录,添加文件系统文件,用天嵌提供的mkyaffs2image生成root.bin的可执行文件,下载到开发板。

14.启动开发板,打印信息如下:

Start Linux ...
Copy linux kernel from 0x00200000 to 0x30008000, size = 0x00200000 ... Copy Kernel to SDRAM done,NOW, Booting Linux......
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.38-Andy (root@Andy) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-176) ) #15 Fri Apr 8 20:21:42 CST 2011
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: Andy's TQ2440 development board!
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60896k/60896k available, 4640k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0025000   ( 116 kB)
      .text : 0xc0025000 - 0xc0399000   (3536 kB)
      .data : 0xc039a000 - 0xc03bac40   ( 132 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 97 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.23.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
msgmni has been set to 118
io scheduler noop registered (default)
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
loop: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=2, 20ns Twrph0=6 60ns, Twrph1=2 20ns
s3c24xx-nand s3c2440-nand: NAND ECC disabled
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
NAND_ECC_NONE selected by board driver. This is not recommended !!
Scanning device for bad blocks
Bad eraseblock 62 at 0x0000007c0000
Bad eraseblock 1435 at 0x00000b360000
cmdlinepart partition parsing not available
Creating 3 MTD partitions on "NAND":
0x000000000000-0x000000040000 : "Andy_uboot"
0x000000200000-0x000000400000 : "Andy_kernel"
0x000000400000-0x00000ff80000 : "Andy_yaffs2"
dm9000 Ethernet Driver, V1.31
Now use the default MAC address: 10:23:45:67:89:ab
eth0: dm9000e at c4810000,c4814004 IRQ 51 MAC: 10:23:45:67:89:ab (EmbedSky)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 2.6.38-Andy ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
s3c2410_udc: debugfs dir creation failed -19
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
ALSA device list:
  No soundcards found.
TCP cubic registered
lib80211: common routines for IEEE802.11 drivers
s3c-rtc s3c2410-rtc: setting system clock to 2000-01-02 00:47:19 UTC (946774039)
yaffs: dev is 32505858 name is "mtdblock2" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 116K

Please press Enter to activate this console.

    移植过程中产生的问题及其解决方法将在下一节说明。还有一些驱动没有移植。继续努力!

 

 

 

 

 

在移植linux2.6.38过程中,遇见了很多的问题,通过在网上查阅相关信息和在图书馆不停的查阅资料,终于成功了。下面将移植过程中产生的问题及其解放方法与大家共享一下。

1、编译内核时yaffs2出现unknown field 'clear_inode' specified in initializer的

错误,原因是所下载的yaffs2不支持linux2.6.38.
   解决方法:最新的yaffs2采用git发布,所以采用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
 ./patch-ker.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

 

2、移植linux内核到开发板后,出现data abort的错误,错误原因为内核大小超过了2M,

天嵌的Uboot只分配给内核2M的空间,所以报错。
   解决方法:精简内核,使其小于2M。或者修改Uboot,是内核大小大于2M。
所以个人认为天嵌的Uboot值得改进,下一步我将移植Uboot,用自己的Uboot就不存在这个问题了。嘿嘿

 

3.移植内核时,出现Uncompressing Linux... done, booting the kernel后,系统不能启动,网上好多人说是因为在menuconfig选项中的Boot options中的Default kernel command string中没有设置noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0 rootfs=yaffs2 rw。其实不用设置这个参数也可以,我采用在内核配置文件中将Kernel Feature/Provide old way to pass kernel parameters选上就行了,因为天嵌用的bootloader太老了,从打印的内核信息中就可以看出。(ATAG_INITRD is deprecated; please update your bootloader.)

 

4.内核启动时,出现Failed to execute /linuxrc的错误,原因是:
(1)文件系统中没有包含linuxrc的可执行文件。在文件系统中添加linuxrc就可完成linux的启动。
(2)在/driver/mtd/nand/s3c2410.c中将chip->ecc.mode = NAND_ECC_SOFT;改为chip->ecc.mode = NAND_ECC_NONE;并在配置内核中将Samsung S3C NAND Hardware ECC选项删掉。

    这个问题纠结了我好久,我遇见这个问题后,先尝试用nfs挂载,能够挂载上,所以我确定肯定是nandflash出了问题了,以为nandflash坏了(因为被我不停的擦写,嘿嘿),后来用天嵌自带的镜像试了是好的,我就明白了,估计是我的nand驱动有问题了,仔细检查驱动,发现内核配置中的Samsung S3C NAND Hardware ECC没有去掉,移植linux2.6.38产生的问题及其解决方法,一个小小的问题折磨了我这么久。所以一定一定要仔细啊。

 

5.编译串口驱动是出现error: implicit declaration of function 's3c2410_gpio_cfgpin'的错误,是因为内核版本2.6.38的内核定义s3c2410_gpio_cfgpin是在linux/gpio.h中,所以添加#include <linux/gpio.h>后即可。

 

6.编译串口驱动是出现error: 'S3C2410_GPH6' undeclared (first use in this function)是因为在内核版本2.6.38的内核定义s3c2410_gpio_cfgpin的函数变量采用的是S3C2410_GPH(6),而非S3C2410_GPH6,将其改为S3C2410_GPH(6)即可解决问题。

 

7.linux内核2.6.38的串口程序samsung.c在/driver/tty/serial中。这里与原来的内核版本不一致。这个要注意,内核版本改了,接口也改了,我当时找不到samsung.c,然后通过find命令一看,晕,原来在这里面。

 

8.在添加yaffs2内核支持时,找不到Kconfig,复制Yaffs2文件夹中的Kconfig_muti到linux内核的fs/yaffs2中,并将Kconfig_muti修改为Kconfig。

 

    还有一下细小的问题就不在这说了,有其他问题的朋友我们可以一起探讨,我们一起进步!最后,小小祝贺自己一下,今天终于可以睡个好觉了!哈哈!



    经过一个星期的不停修改错误,看代码,每天都忙到2点才睡,今天终于解决了所有问题,成功移植linux2.6.38内核到TQ2440。

移植步骤:

1.修改根目录的Makefile中的ARCH=arm,CROSS-COMPILE=arm-linux-

2.在arch/arm/mach-s3c2440/mach-smdk2440.c中,将163行的s3c24xx_init_clocks(16934400)改为s3c24xx_init_clocks(12000000)。

3.修改arch/arm/tools/mach-types中379行的362改为168,因为uboot中定义的机器码是168.

4.修改arch/arm/boot/中的Makefile文件,在58行添加@cp -f arch/arm/boot/zImage zImage.bin,实现把生成的zImage文件复制到内核源码根目录下。

5.在根目录的Makefile的1164行添加rm -f zImage.bin,使得在执行make distclean在清除产生的文件的同时,把内核根目录下的zImage也清除。

6.修改arch/arm/plat-s3c24xx/common-smdk.c中111行的static struct mtd_partition smdk_default_nand_part[]的nandflash分区为:
 [0] = {
  .name  = "Andy_uboot",
  .offset = 0x00000000,
  .size  = 0x00040000,
 },
 [1] = {
  .name  = "Andy_kernel",
  .offset = 0x00200000,
  .size  = 0x00200000,
 },
 [2] = {
  .name  = "Andy_yaffs2",
  .offset = 0x00400000,
  .size  = 0x0FB80000,
 }

7.修改drivers/mtd/nand/s3c2410.c中的839行为chip->ecc.mode=NAND_ECC_NONE;

8.修改arch/arm/mach-s3c2440/mach-smdk2440.c中100行为.ulcon = 0x03。

9.在drivers/serial/samsung.c的51行添加
   #include <mach/regs-gpio.h>
   #include <linux/gpio.h>
  在433行添加:
 if (port->line == 2) {
     s3c2410_gpio_cfgpin(S3C2410_GPH(6), S3C2410_GPH6_TXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(6), 1);
     s3c2410_gpio_cfgpin(S3C2410_GPH(7), S3C2410_GPH7_RXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(7), 1);
 }

10.用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
./patch-kernel.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

11.用make menuconfig配置linux内核。

12.执行make zImage,将生成的zImage.bin下载到TQ2440。

13.制作文件系统。

解压busybox-1.18.4.tar.bz2,修改busybox-1.18.4中的Makefile,在164行和190行分别修改为CROSS-COMPILE=arm-linux-和ARCH=arm。执行make,然后在执行make install。将生成_install复制到根目录,添加文件系统文件,用天嵌提供的mkyaffs2image生成root.bin的可执行文件,下载到开发板。

14.启动开发板,打印信息如下:

Start Linux ...
Copy linux kernel from 0x00200000 to 0x30008000, size = 0x00200000 ... Copy Kernel to SDRAM done,NOW, Booting Linux......
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.38-Andy (root@Andy) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-176) ) #15 Fri Apr 8 20:21:42 CST 2011
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: Andy's TQ2440 development board!
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60896k/60896k available, 4640k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0025000   ( 116 kB)
      .text : 0xc0025000 - 0xc0399000   (3536 kB)
      .data : 0xc039a000 - 0xc03bac40   ( 132 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 97 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.23.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
msgmni has been set to 118
io scheduler noop registered (default)
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
loop: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=2, 20ns Twrph0=6 60ns, Twrph1=2 20ns
s3c24xx-nand s3c2440-nand: NAND ECC disabled
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
NAND_ECC_NONE selected by board driver. This is not recommended !!
Scanning device for bad blocks
Bad eraseblock 62 at 0x0000007c0000
Bad eraseblock 1435 at 0x00000b360000
cmdlinepart partition parsing not available
Creating 3 MTD partitions on "NAND":
0x000000000000-0x000000040000 : "Andy_uboot"
0x000000200000-0x000000400000 : "Andy_kernel"
0x000000400000-0x00000ff80000 : "Andy_yaffs2"
dm9000 Ethernet Driver, V1.31
Now use the default MAC address: 10:23:45:67:89:ab
eth0: dm9000e at c4810000,c4814004 IRQ 51 MAC: 10:23:45:67:89:ab (EmbedSky)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 2.6.38-Andy ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
s3c2410_udc: debugfs dir creation failed -19
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
ALSA device list:
  No soundcards found.
TCP cubic registered
lib80211: common routines for IEEE802.11 drivers
s3c-rtc s3c2410-rtc: setting system clock to 2000-01-02 00:47:19 UTC (946774039)
yaffs: dev is 32505858 name is "mtdblock2" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 116K

Please press Enter to activate this console.

    移植过程中产生的问题及其解决方法将在下一节说明。还有一些驱动没有移植。继续努力!

 

 

 

 

 

在移植linux2.6.38过程中,遇见了很多的问题,通过在网上查阅相关信息和在图书馆不停的查阅资料,终于成功了。下面将移植过程中产生的问题及其解放方法与大家共享一下。

1、编译内核时yaffs2出现unknown field 'clear_inode' specified in initializer的

错误,原因是所下载的yaffs2不支持linux2.6.38.
   解决方法:最新的yaffs2采用git发布,所以采用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
 ./patch-ker.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

 

2、移植linux内核到开发板后,出现data abort的错误,错误原因为内核大小超过了2M,

天嵌的Uboot只分配给内核2M的空间,所以报错。
   解决方法:精简内核,使其小于2M。或者修改Uboot,是内核大小大于2M。
所以个人认为天嵌的Uboot值得改进,下一步我将移植Uboot,用自己的Uboot就不存在这个问题了。嘿嘿

 

3.移植内核时,出现Uncompressing Linux... done, booting the kernel后,系统不能启动,网上好多人说是因为在menuconfig选项中的Boot options中的Default kernel command string中没有设置noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0 rootfs=yaffs2 rw。其实不用设置这个参数也可以,我采用在内核配置文件中将Kernel Feature/Provide old way to pass kernel parameters选上就行了,因为天嵌用的bootloader太老了,从打印的内核信息中就可以看出。(ATAG_INITRD is deprecated; please update your bootloader.)

 

4.内核启动时,出现Failed to execute /linuxrc的错误,原因是:
(1)文件系统中没有包含linuxrc的可执行文件。在文件系统中添加linuxrc就可完成linux的启动。
(2)在/driver/mtd/nand/s3c2410.c中将chip->ecc.mode = NAND_ECC_SOFT;改为chip->ecc.mode = NAND_ECC_NONE;并在配置内核中将Samsung S3C NAND Hardware ECC选项删掉。

    这个问题纠结了我好久,我遇见这个问题后,先尝试用nfs挂载,能够挂载上,所以我确定肯定是nandflash出了问题了,以为nandflash坏了(因为被我不停的擦写,嘿嘿),后来用天嵌自带的镜像试了是好的,我就明白了,估计是我的nand驱动有问题了,仔细检查驱动,发现内核配置中的Samsung S3C NAND Hardware ECC没有去掉,移植linux2.6.38产生的问题及其解决方法,一个小小的问题折磨了我这么久。所以一定一定要仔细啊。

 

5.编译串口驱动是出现error: implicit declaration of function 's3c2410_gpio_cfgpin'的错误,是因为内核版本2.6.38的内核定义s3c2410_gpio_cfgpin是在linux/gpio.h中,所以添加#include <linux/gpio.h>后即可。

 

6.编译串口驱动是出现error: 'S3C2410_GPH6' undeclared (first use in this function)是因为在内核版本2.6.38的内核定义s3c2410_gpio_cfgpin的函数变量采用的是S3C2410_GPH(6),而非S3C2410_GPH6,将其改为S3C2410_GPH(6)即可解决问题。

 

7.linux内核2.6.38的串口程序samsung.c在/driver/tty/serial中。这里与原来的内核版本不一致。这个要注意,内核版本改了,接口也改了,我当时找不到samsung.c,然后通过find命令一看,晕,原来在这里面。

 

8.在添加yaffs2内核支持时,找不到Kconfig,复制Yaffs2文件夹中的Kconfig_muti到linux内核的fs/yaffs2中,并将Kconfig_muti修改为Kconfig。

 

    还有一下细小的问题就不在这说了,有其他问题的朋友我们可以一起探讨,我们一起进步!最后,小小祝贺自己一下,今天终于可以睡个好觉了!哈哈!

    经过一个星期的不停修改错误,看代码,每天都忙到2点才睡,今天终于解决了所有问题,成功移植linux2.6.38内核到TQ2440。

移植步骤:

1.修改根目录的Makefile中的ARCH=arm,CROSS-COMPILE=arm-linux-

2.在arch/arm/mach-s3c2440/mach-smdk2440.c中,将163行的s3c24xx_init_clocks(16934400)改为s3c24xx_init_clocks(12000000)。

3.修改arch/arm/tools/mach-types中379行的362改为168,因为uboot中定义的机器码是168.

4.修改arch/arm/boot/中的Makefile文件,在58行添加@cp -f arch/arm/boot/zImage zImage.bin,实现把生成的zImage文件复制到内核源码根目录下。

5.在根目录的Makefile的1164行添加rm -f zImage.bin,使得在执行make distclean在清除产生的文件的同时,把内核根目录下的zImage也清除。

6.修改arch/arm/plat-s3c24xx/common-smdk.c中111行的static struct mtd_partition smdk_default_nand_part[]的nandflash分区为:
 [0] = {
  .name  = "Andy_uboot",
  .offset = 0x00000000,
  .size  = 0x00040000,
 },
 [1] = {
  .name  = "Andy_kernel",
  .offset = 0x00200000,
  .size  = 0x00200000,
 },
 [2] = {
  .name  = "Andy_yaffs2",
  .offset = 0x00400000,
  .size  = 0x0FB80000,
 }

7.修改drivers/mtd/nand/s3c2410.c中的839行为chip->ecc.mode=NAND_ECC_NONE;

8.修改arch/arm/mach-s3c2440/mach-smdk2440.c中100行为.ulcon = 0x03。

9.在drivers/serial/samsung.c的51行添加
   #include <mach/regs-gpio.h>
   #include <linux/gpio.h>
  在433行添加:
 if (port->line == 2) {
     s3c2410_gpio_cfgpin(S3C2410_GPH(6), S3C2410_GPH6_TXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(6), 1);
     s3c2410_gpio_cfgpin(S3C2410_GPH(7), S3C2410_GPH7_RXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(7), 1);
 }

10.用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
./patch-kernel.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

11.用make menuconfig配置linux内核。

12.执行make zImage,将生成的zImage.bin下载到TQ2440。

13.制作文件系统。

解压busybox-1.18.4.tar.bz2,修改busybox-1.18.4中的Makefile,在164行和190行分别修改为CROSS-COMPILE=arm-linux-和ARCH=arm。执行make,然后在执行make install。将生成_install复制到根目录,添加文件系统文件,用天嵌提供的mkyaffs2image生成root.bin的可执行文件,下载到开发板。

14.启动开发板,打印信息如下:

Start Linux ...
Copy linux kernel from 0x00200000 to 0x30008000, size = 0x00200000 ... Copy Kernel to SDRAM done,NOW, Booting Linux......
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.38-Andy (root@Andy) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-176) ) #15 Fri Apr 8 20:21:42 CST 2011
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: Andy's TQ2440 development board!
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60896k/60896k available, 4640k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0025000   ( 116 kB)
      .text : 0xc0025000 - 0xc0399000   (3536 kB)
      .data : 0xc039a000 - 0xc03bac40   ( 132 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 97 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.23.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
msgmni has been set to 118
io scheduler noop registered (default)
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
loop: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=2, 20ns Twrph0=6 60ns, Twrph1=2 20ns
s3c24xx-nand s3c2440-nand: NAND ECC disabled
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
NAND_ECC_NONE selected by board driver. This is not recommended !!
Scanning device for bad blocks
Bad eraseblock 62 at 0x0000007c0000
Bad eraseblock 1435 at 0x00000b360000
cmdlinepart partition parsing not available
Creating 3 MTD partitions on "NAND":
0x000000000000-0x000000040000 : "Andy_uboot"
0x000000200000-0x000000400000 : "Andy_kernel"
0x000000400000-0x00000ff80000 : "Andy_yaffs2"
dm9000 Ethernet Driver, V1.31
Now use the default MAC address: 10:23:45:67:89:ab
eth0: dm9000e at c4810000,c4814004 IRQ 51 MAC: 10:23:45:67:89:ab (EmbedSky)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 2.6.38-Andy ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
s3c2410_udc: debugfs dir creation failed -19
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
ALSA device list:
  No soundcards found.
TCP cubic registered
lib80211: common routines for IEEE802.11 drivers
s3c-rtc s3c2410-rtc: setting system clock to 2000-01-02 00:47:19 UTC (946774039)
yaffs: dev is 32505858 name is "mtdblock2" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 116K

Please press Enter to activate this console.

    移植过程中产生的问题及其解决方法将在下一节说明。还有一些驱动没有移植。继续努力!

 

 

 

 

 

在移植linux2.6.38过程中,遇见了很多的问题,通过在网上查阅相关信息和在图书馆不停的查阅资料,终于成功了。下面将移植过程中产生的问题及其解放方法与大家共享一下。

1、编译内核时yaffs2出现unknown field 'clear_inode' specified in initializer的

错误,原因是所下载的yaffs2不支持linux2.6.38.
   解决方法:最新的yaffs2采用git发布,所以采用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
 ./patch-ker.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

 

2、移植linux内核到开发板后,出现data abort的错误,错误原因为内核大小超过了2M,

天嵌的Uboot只分配给内核2M的空间,所以报错。
   解决方法:精简内核,使其小于2M。或者修改Uboot,是内核大小大于2M。
所以个人认为天嵌的Uboot值得改进,下一步我将移植Uboot,用自己的Uboot就不存在这个问题了。嘿嘿

 

3.移植内核时,出现Uncompressing Linux... done, booting the kernel后,系统不能启动,网上好多人说是因为在menuconfig选项中的Boot options中的Default kernel command string中没有设置noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0 rootfs=yaffs2 rw。其实不用设置这个参数也可以,我采用在内核配置文件中将Kernel Feature/Provide old way to pass kernel parameters选上就行了,因为天嵌用的bootloader太老了,从打印的内核信息中就可以看出。(ATAG_INITRD is deprecated; please update your bootloader.)

 

4.内核启动时,出现Failed to execute /linuxrc的错误,原因是:
(1)文件系统中没有包含linuxrc的可执行文件。在文件系统中添加linuxrc就可完成linux的启动。
(2)在/driver/mtd/nand/s3c2410.c中将chip->ecc.mode = NAND_ECC_SOFT;改为chip->ecc.mode = NAND_ECC_NONE;并在配置内核中将Samsung S3C NAND Hardware ECC选项删掉。

    这个问题纠结了我好久,我遇见这个问题后,先尝试用nfs挂载,能够挂载上,所以我确定肯定是nandflash出了问题了,以为nandflash坏了(因为被我不停的擦写,嘿嘿),后来用天嵌自带的镜像试了是好的,我就明白了,估计是我的nand驱动有问题了,仔细检查驱动,发现内核配置中的Samsung S3C NAND Hardware ECC没有去掉,移植linux2.6.38产生的问题及其解决方法,一个小小的问题折磨了我这么久。所以一定一定要仔细啊。

 

5.编译串口驱动是出现error: implicit declaration of function 's3c2410_gpio_cfgpin'的错误,是因为内核版本2.6.38的内核定义s3c2410_gpio_cfgpin是在linux/gpio.h中,所以添加#include <linux/gpio.h>后即可。

 

6.编译串口驱动是出现error: 'S3C2410_GPH6' undeclared (first use in this function)是因为在内核版本2.6.38的内核定义s3c2410_gpio_cfgpin的函数变量采用的是S3C2410_GPH(6),而非S3C2410_GPH6,将其改为S3C2410_GPH(6)即可解决问题。

 

7.linux内核2.6.38的串口程序samsung.c在/driver/tty/serial中。这里与原来的内核版本不一致。这个要注意,内核版本改了,接口也改了,我当时找不到samsung.c,然后通过find命令一看,晕,原来在这里面。

 

8.在添加yaffs2内核支持时,找不到Kconfig,复制Yaffs2文件夹中的Kconfig_muti到linux内核的fs/yaffs2中,并将Kconfig_muti修改为Kconfig。

 

    还有一下细小的问题就不在这说了,有其他问题的朋友我们可以一起探讨,我们一起进步!最后,小小祝贺自己一下,今天终于可以睡个好觉了!哈哈!

    经过一个星期的不停修改错误,看代码,每天都忙到2点才睡,今天终于解决了所有问题,成功移植linux2.6.38内核到TQ2440。

移植步骤:

1.修改根目录的Makefile中的ARCH=arm,CROSS-COMPILE=arm-linux-

2.在arch/arm/mach-s3c2440/mach-smdk2440.c中,将163行的s3c24xx_init_clocks(16934400)改为s3c24xx_init_clocks(12000000)。

3.修改arch/arm/tools/mach-types中379行的362改为168,因为uboot中定义的机器码是168.

4.修改arch/arm/boot/中的Makefile文件,在58行添加@cp -f arch/arm/boot/zImage zImage.bin,实现把生成的zImage文件复制到内核源码根目录下。

5.在根目录的Makefile的1164行添加rm -f zImage.bin,使得在执行make distclean在清除产生的文件的同时,把内核根目录下的zImage也清除。

6.修改arch/arm/plat-s3c24xx/common-smdk.c中111行的static struct mtd_partition smdk_default_nand_part[]的nandflash分区为:
 [0] = {
  .name  = "Andy_uboot",
  .offset = 0x00000000,
  .size  = 0x00040000,
 },
 [1] = {
  .name  = "Andy_kernel",
  .offset = 0x00200000,
  .size  = 0x00200000,
 },
 [2] = {
  .name  = "Andy_yaffs2",
  .offset = 0x00400000,
  .size  = 0x0FB80000,
 }

7.修改drivers/mtd/nand/s3c2410.c中的839行为chip->ecc.mode=NAND_ECC_NONE;

8.修改arch/arm/mach-s3c2440/mach-smdk2440.c中100行为.ulcon = 0x03。

9.在drivers/serial/samsung.c的51行添加
   #include <mach/regs-gpio.h>
   #include <linux/gpio.h>
  在433行添加:
 if (port->line == 2) {
     s3c2410_gpio_cfgpin(S3C2410_GPH(6), S3C2410_GPH6_TXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(6), 1);
     s3c2410_gpio_cfgpin(S3C2410_GPH(7), S3C2410_GPH7_RXD2);
     s3c2410_gpio_pullup(S3C2410_GPH(7), 1);
 }

10.用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
./patch-kernel.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

11.用make menuconfig配置linux内核。

12.执行make zImage,将生成的zImage.bin下载到TQ2440。

13.制作文件系统。

解压busybox-1.18.4.tar.bz2,修改busybox-1.18.4中的Makefile,在164行和190行分别修改为CROSS-COMPILE=arm-linux-和ARCH=arm。执行make,然后在执行make install。将生成_install复制到根目录,添加文件系统文件,用天嵌提供的mkyaffs2image生成root.bin的可执行文件,下载到开发板。

14.启动开发板,打印信息如下:

Start Linux ...
Copy linux kernel from 0x00200000 to 0x30008000, size = 0x00200000 ... Copy Kernel to SDRAM done,NOW, Booting Linux......
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.38-Andy (root@Andy) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-176) ) #15 Fri Apr 8 20:21:42 CST 2011
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: Andy's TQ2440 development board!
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60896k/60896k available, 4640k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0025000   ( 116 kB)
      .text : 0xc0025000 - 0xc0399000   (3536 kB)
      .data : 0xc039a000 - 0xc03bac40   ( 132 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 97 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.23.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
msgmni has been set to 118
io scheduler noop registered (default)
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
loop: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=2, 20ns Twrph0=6 60ns, Twrph1=2 20ns
s3c24xx-nand s3c2440-nand: NAND ECC disabled
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
NAND_ECC_NONE selected by board driver. This is not recommended !!
Scanning device for bad blocks
Bad eraseblock 62 at 0x0000007c0000
Bad eraseblock 1435 at 0x00000b360000
cmdlinepart partition parsing not available
Creating 3 MTD partitions on "NAND":
0x000000000000-0x000000040000 : "Andy_uboot"
0x000000200000-0x000000400000 : "Andy_kernel"
0x000000400000-0x00000ff80000 : "Andy_yaffs2"
dm9000 Ethernet Driver, V1.31
Now use the default MAC address: 10:23:45:67:89:ab
eth0: dm9000e at c4810000,c4814004 IRQ 51 MAC: 10:23:45:67:89:ab (EmbedSky)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 2.6.38-Andy ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
s3c2410_udc: debugfs dir creation failed -19
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
ALSA device list:
  No soundcards found.
TCP cubic registered
lib80211: common routines for IEEE802.11 drivers
s3c-rtc s3c2410-rtc: setting system clock to 2000-01-02 00:47:19 UTC (946774039)
yaffs: dev is 32505858 name is "mtdblock2" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 116K

Please press Enter to activate this console.

    移植过程中产生的问题及其解决方法将在下一节说明。还有一些驱动没有移植。继续努力!

 

 

 

 

 

在移植linux2.6.38过程中,遇见了很多的问题,通过在网上查阅相关信息和在图书馆不停的查阅资料,终于成功了。下面将移植过程中产生的问题及其解放方法与大家共享一下。

1、编译内核时yaffs2出现unknown field 'clear_inode' specified in initializer的

错误,原因是所下载的yaffs2不支持linux2.6.38.
   解决方法:最新的yaffs2采用git发布,所以采用git工具下载最新的yaffs2源代码。

具体为在终端输入git clone    git://www.aleph1.co.uk/yaffs2下载最新的yaffs2,下

载完成给内核打补丁,进入yaffs目录,执行
 ./patch-ker.sh c m opt/Andy/linux-2.6.38(以自己的内核目录为准),其中的c代表复制,m代表复合类型。

 

2、移植linux内核到开发板后,出现data abort的错误,错误原因为内核大小超过了2M,

天嵌的Uboot只分配给内核2M的空间,所以报错。
   解决方法:精简内核,使其小于2M。或者修改Uboot,是内核大小大于2M。
所以个人认为天嵌的Uboot值得改进,下一步我将移植Uboot,用自己的Uboot就不存在这个问题了。嘿嘿

 

3.移植内核时,出现Uncompressing Linux... done, booting the kernel后,系统不能启动,网上好多人说是因为在menuconfig选项中的Boot options中的Default kernel command string中没有设置noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0 rootfs=yaffs2 rw。其实不用设置这个参数也可以,我采用在内核配置文件中将Kernel Feature/Provide old way to pass kernel parameters选上就行了,因为天嵌用的bootloader太老了,从打印的内核信息中就可以看出。(ATAG_INITRD is deprecated; please update your bootloader.)

 

4.内核启动时,出现Failed to execute /linuxrc的错误,原因是:
(1)文件系统中没有包含linuxrc的可执行文件。在文件系统中添加linuxrc就可完成linux的启动。
(2)在/driver/mtd/nand/s3c2410.c中将chip->ecc.mode = NAND_ECC_SOFT;改为chip->ecc.mode = NAND_ECC_NONE;并在配置内核中将Samsung S3C NAND Hardware ECC选项删掉。

    这个问题纠结了我好久,我遇见这个问题后,先尝试用nfs挂载,能够挂载上,所以我确定肯定是nandflash出了问题了,以为nandflash坏了(因为被我不停的擦写,嘿嘿),后来用天嵌自带的镜像试了是好的,我就明白了,估计是我的nand驱动有问题了,仔细检查驱动,发现内核配置中的Samsung S3C NAND Hardware ECC没有去掉,移植linux2.6.38产生的问题及其解决方法,一个小小的问题折磨了我这么久。所以一定一定要仔细啊。

 

5.编译串口驱动是出现error: implicit declaration of function 's3c2410_gpio_cfgpin'的错误,是因为内核版本2.6.38的内核定义s3c2410_gpio_cfgpin是在linux/gpio.h中,所以添加#include <linux/gpio.h>后即可。

 

6.编译串口驱动是出现error: 'S3C2410_GPH6' undeclared (first use in this function)是因为在内核版本2.6.38的内核定义s3c2410_gpio_cfgpin的函数变量采用的是S3C2410_GPH(6),而非S3C2410_GPH6,将其改为S3C2410_GPH(6)即可解决问题。

 

7.linux内核2.6.38的串口程序samsung.c在/driver/tty/serial中。这里与原来的内核版本不一致。这个要注意,内核版本改了,接口也改了,我当时找不到samsung.c,然后通过find命令一看,晕,原来在这里面。

 

8.在添加yaffs2内核支持时,找不到Kconfig,复制Yaffs2文件夹中的Kconfig_muti到linux内核的fs/yaffs2中,并将Kconfig_muti修改为Kconfig。

 

    还有一下细小的问题就不在这说了,有其他问题的朋友我们可以一起探讨,我们一起进步!最后,小小祝贺自己一下,今天终于可以睡个好觉了!哈哈!

阅读更多
个人分类: 内核
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

成功移植linux2.6.38内核到TQ2440(转)

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭