Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1413304
  • 博文数量: 1334
  • 博客积分: 645
  • 博客等级: 上士
  • 技术积分: 5762
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-25 16:56
文章分类

全部博文(1334)

文章存档

2014年(108)

2013年(1059)

2012年(169)

分类:

2013-01-09 16:17:42

Linux2.6.35TQ2440的移植过程(一)

本文为原创,版本归作者:Machoe . Yang 所有。如需转载,请注明:http://machoe.cublog.cn/

环境:

硬件平台:TQ2440

软件平台:VM7.1  Fedora10  arm-linux-gcc-4.3.3  Linux2.6.35版本源码  天嵌科技提供的u-boot2010.06

一、获取并解压源码

  本人一直习惯从下载源码,极为方便,本次移植选则的源码为Linux2.6.35版本。下载后,将源码保存在了/opt/kernel/目录下。

成功得到源码后,开始对其解压:、

tar xvfj linux2.6.35.tar.bz2 –C ./

当解压过程结束后,即可在当前目录下看到:

                                                        root@EmbedSky kernel]# ls

cvs              linux-2.6.25.8          linux-2.6.30.4          linux-2.6.35    linux-2.6.35.4.tar.bz2

cvs-root.tar[1]  linux-2.6.25.8.tar.bz2  linux-2.6.30.4.tar.bz2  linux-2.6.35.4  linux-2.6.35.tar.bz2

二、修改Makefile文件添加对arm平台的支持

修改顶层Makefile文件,VIM Makefile 。修改其文件的第191192两行,修改后:

                                      191 ARCH            ?= arm

 192 CROSS_COMPILE   ?= arm-linux-

至于第193行的CORSS_COMPILE选项这里我们可以不用理会,它是在配置内核时用到的,只需改前面两项即可。

三、修改部分源码以支持TQ2440平台

1.     修改平台时钟

修改arch/arm/mach-s3c2440/mach-smdk2440.c文件的第163行,将16000000改成12000000即可。

160 static void __init smdk2440_map_io(void)

161 {

162         s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));

163         s3c24xx_init_clocks(12000000);

164         s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));

165 }

2.修改机器码与u-boot保持一致

修改arch/arm/tools/mach-types文件的第379行,将最后的362修改成为168

379  s3c2440                 ARCH_S3C2440            S3C2440                 168

此处修改的机器码会在文件arch/arm/mach-s3c2440/mach-smdk2440.c文件中被下面这段代码调用,此处如果没有修改,会导致内核无法启动。

MACHINE_START(S3C2440, "SMDK2440")

177         /* Maintainer: Ben Dooks */

178         .phys_io        = S3C2410_PA_UART,

179         .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,

180         .boot_params    = S3C2410_SDRAM_PA + 0x100,

181

182         .init_irq       = s3c24xx_init_irq,

183         .map_io         = smdk2440_map_io,

184         .init_machine   = smdk2440_machine_init,

185         .timer          = &s3c24xx_timer,

186 MACHINE_END

3.修改nandflash源码

修改nandflash的分区表,打开arch/arm/plat-s3c24xx/common-smdk.c ,修改111行的结构体,修改成下面的代码:

111 static struct mtd_partition smdk_default_nand_part[] = {

112         [0] = {

113                 .name   = "EmbedSky_Board_uboot",

114                 .offset = 0x00000000,

115                 .size   = 0x00040000,

116         },

117         [1] = {

118                 .name   = "EmbedSky_Board_kernel",

119                 .offset = 0x00200000,

120                 .size   = 0x00200000,

121         },

122         [2] = {

123                 .name   = "EmbedSky_Board_yaffs2",

124                 .offset = 0x00400000,

125                 .size   = 0x0FB80000,

126         }

127

128 };

并且将其后面的代码修改成下面,以支持TQ2440的硬件,注意这里不同的Nandflash芯片,下面的取值可能不同,可以参考天嵌给出的linux2.6.30.4的。

          143 static struct s3c2410_platform_nand smdk_nand_info = {

144         .tacls          = 10,

145         .twrph0         = 25,

146         .twrph1         = 10,

147         .nr_sets        = ARRAY_SIZE(smdk_nand_sets),

148         .sets           = smdk_nand_sets,

149 };

修改driver/mtd/nand/s3c2410.c文件的第822行,修改成下面的部分:

                                          chip->ecc.mode      = NAND_ECC_NONE;

  至此,整个nandflash的源码修改结束,我们可以配置内核了。

三、配置内核

(由于图片不能贴过来,需要的话,稍候我把文件传上来,供大家下载)

在完成了上述工作后,使用make distclean 清除内核,再make menuconfig配置内核,配置的具体步骤如下:

1.     利用别人的配置单

在进入到配置界面后,选择Load an Alternate Configuration File,进入后,输入如图的配置单。

    

       arch/arm/configs/s3c2410_defconfig

 

2.修改    General setup  ---> 

这里只修改了第3项,Local.version,修改成了我自己名字,Machoe.Yang,其它的选择默认,选择默认的原因并不是不需要修改,只是我们目前只是为了验证内核能不能跑得起来,稍候的移植教程中,我人和大家分享配置单的详细配置情况。这里只要注意Kernel compression mod 选项,默认的是GZIP方式,如果不是,请修改过来。

2.     个性system type选项

这里是我们本次配置的重点,由于我们刚才调用了s3c2410的配置单,现在出现在我们面前的,第二项,ARM system type已经是我们所需要的CPU了,因此也不用修改了。

但这里我们的一定要修改的是中间部分,从s3c2400 Machines 一直到s3c2443 Machines。将它们的所有选项全部取消,只保留s3c2410 Machines 中的smdk2410/ARM92410 s3c2440 and s3c2442 Machines选项中的SMDK2440 SMDK2440 with S3c2440 CPU Module (new)选项。

注意:这里一定要取消其它的开发板支持,否则会出现内核(zImage)启动不了,而uImage可以正常启动的现象。这是因为,如果配置了其它开发板后,zImage的解压缩地址会改变,具体的可以参考各目录下的kconfig文件、Makefile.lds文件。也可以参考本人的上一篇拙著“基于linux2.6.35zImage内核启动研究”。

 

3.修改Kernel Features选项

由于我使用的交叉编译工具为4.3.3版本,因此,此处选上下面两个选项

[*] Use the ARM EABI to compile the kernel                                                  

                [*]   Allow old ABI binaries to run with this kernel (EXPERIMENTAL) (NEW) 

4.添加对nandflash驱动

Device Driversà

 <*> Memory Technology Device (MTD) support  --->

 <*>   NAND Device Support  --->    

 选项上中,我们要配置上

     <*>   NAND Flash support for Samsung S3C SoCs  

其它的选择默认即可。

四、编译内核

在完成上面的配置后,退出到顶层配置界面,选择      

 Save an Alternate Configuration File                                                  

将其保存为.config配置单,然后退出。此处注意,如果不以这种方式退出,而直接退出保存,则保存的有可能是我们调用的arch/arm/configs/s3c2410_defconfig 配置单,这样就破坏了原配置单。

 

最后,执行 make zImage进行编译。

  Kernel: arch/arm/boot/Image is ready

  AS      arch/arm/boot/compressed/head.o

  GZIP    arch/arm/boot/compressed/piggy.gzip

  AS      arch/arm/boot/compressed/piggy.gzip.o

  CC      arch/arm/boot/compressed/misc.o

  CC      arch/arm/boot/compressed/decompress.o

  SHIPPED arch/arm/boot/compressed/lib1funcs.S

  AS      arch/arm/boot/compressed/lib1funcs.o

  LD      arch/arm/boot/compressed/vmlinux

  OBJCOPY arch/arm/boot/zImage

  Kernel: arch/arm/boot/zImage is ready

出现上述,说明zImage已经编译成功,将其copywindows的共享目录下,

                                               cp  arch/arm/boot/zImage  /mnt/hjfs/abc/zImage.bin

其中,/mnt/hjfs/abc/VM虚拟机设置的共享目录。

将镜像文件烧到开发板中,启动开发板,此处要确认一下,开发板中一定要事先烧好u-boot,这是初学者容易犯的错误。另外,天嵌提供的u-boot中,提供zImage测试功能,可以不必将其烧到nandflash中,如要使用该功能,详见天嵌的教程。

当正确完成上述工作后,串口会打印如下信息,重点信息用颜色标出:

Now, Downloading [ADDRESS:30008000h,TOTAL:2019522]

RECEIVED FILE SIZE: 2019522 (986KB/S, 2S)

NOW, Booting Linux......

Uncompressing Linux... done, booting the kernel.

Linux version 2.6.35---Machoe.Yang (root@EmbedSky) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-176) ) #1 Tue Sep 28 09:28:25 CST 2010

CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177

CPU: VIVT data cache, VIVT instruction cache

Machine: SMDK2440

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: 60796k/60796k available, 4740k reserved, 0K highmem

Virtual kernel memory layout:

    vector  : 0xffff0000 - 0xffff1000   (   4 kB)

    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)

    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)

    vmalloc : 0xc4800000 - 0xe0000000   ( 440 MB)

    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)

    modules : 0xbf000000 - 0xc0000000   (  16 MB)

      .init : 0xc0008000 - 0xc0028000   ( 128 kB)

      .text : 0xc0028000 - 0xc03a8000   (3584 kB)

      .data : 0xc03c0000 - 0xc03e1860   ( 135 kB)

Hierarchical RCU implementation.

        RCU-based detection of stalled CPUs is disabled.

        Verbose stalled-CPUs detection is disabled.

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

S3C Power Management, Copyright 2004 Simtec Electronics

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 at 0

SCSI subsystem initialized

usbcore: registered new interface driver usbfs

usbcore: registered new interface driver hub

usbcore: registered new device driver usb

Advanced Linux Sound Architecture Driver Version 1.0.23.

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.

NetWinder Floating Point Emulator V0.97 (extended precision)

JFFS2 version 2.2. (NAND) (SUMMARY)  2001-2006 Red Hat, Inc.

ROMFS MTD (C) 2007 Red Hat, Inc.

msgmni has been set to 118

io scheduler noop registered

io scheduler deadline registered

io scheduler cfq registered (default)

Console: switching to colour frame buffer device 30x40

fb0: s3c2410fb frame buffer device

lp: driver loaded but no devices found

ppdev: user-space parallel port driver

Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled

s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440

s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440

s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440

brd: module loaded

loop: module loaded

Uniform Multi-Platform E-IDE driver

ide-gd driver 1.18

ide-cd driver 5.00

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

s3c24xx-nand s3c2440-nand: Tacls=1, 10ns Twrph0=3 30ns, Twrph1=1 10ns

s3c24xx-nand s3c2440-nand: NAND soft ECC

NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)

Scanning device for bad blocks

Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":

0x000000000000-0x000000040000 : "EmbedSky_Board_uboot"

0x000000200000-0x000000400000 : "EmbedSky_Board_kernel"

0x000000400000-0x00000ff80000 : "EmbedSky_Board_yaffs2"

dm9000 Ethernet Driver, V1.31

usbmon: debugfs is not available

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

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

usbcore: registered new interface driver libusual

usbcore: registered new interface driver usbserial

USB Serial support registered for generic

usbcore: registered new interface driver usbserial_generic

usbserial: USB Serial Driver core

USB Serial support registered for FTDI USB Serial Device

usbcore: registered new interface driver ftdi_sio

ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver

USB Serial support registered for pl2303

usbcore: registered new interface driver pl2303

pl2303: Prolific PL2303 USB to serial adaptor driver

mice: PS/2 mouse device common for all mice

S3C24XX RTC, (c) 2004,2006 Simtec Electronics

S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics

s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled

ALSA device list:

  No soundcards found.

TCP cubic registered

NET: Registered protocol family 17

drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

List of all partitions:

1f00             256 mtdblock0 (driver?)

1f01            2048 mtdblock1 (driver?)

1f02          257536 mtdblock2 (driver?)

No filesystem could mount root, tried:  ext3 ext2 cramfs vfat msdos iso9660 romfs

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)

[] (unwind_backtrace+0x0/0xec) from [] (panic+0x54/0xdc)

[] (panic+0x54/0xdc) from [] (mount_block_root+0x1d0/0x210)

[] (mount_block_root+0x1d0/0x210) from [] (prepare_namespace+0x164/0x1bc)

[] (prepare_namespace+0x164/0x1bc) from [] (kernel_init+0x10c/0x14c)

[] (kernel_init+0x10c/0x14c) from [] (kernel_thread_exit+0x0/0x8)

由于没有烧写文件系统,因此后面会报错。

本次编译的内核其中还有好多地方需要完善,这次配置过程,只是为了回答在论坛上有人提出的zImageTQ2440启动的过程。后续,我还会继续完善2.6.35内核的移植过程,直至整个移植工作的完成。

上述内容只是个人拙见,如果错误,希望广大网友不吝赐教,给我指出,望大家共同提高。

由于图片上传比较麻烦,如果有需要完整版,请到CSDN下载。下载地址:

 

阅读(295) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~