Chinaunix首页 | 论坛 | 博客
  • 博客访问: 803951
  • 博文数量: 489
  • 博客积分: 475
  • 博客等级: 下士
  • 技术积分: 3087
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 16:28
文章分类

全部博文(489)

文章存档

2013年(7)

2012年(301)

2011年(181)

分类:

2012-01-12 13:40:30

Jacky Xu @ 2008.7.13

一、主机环境
  Linux version 2.4.20-8, RedHat9, VMWare5.5.3;
  gcc version 3.4.4, Thread model: posix;
  GNU Make 3.81;
  arm-linux-gcc 4.2.1 (此创建过程见另贴用crosstool脚本编译针对Linux2.6内核的交叉编译工具链

二、编译内核
1、解压linux-2.6.24.7.tar.gz,修改Makefile中的ARCH和CROSS_COMPILE对应内容。修改本机的交叉编译工具链的路径和前缀。

ARCH ?= arm
CROSS_COMPILE ?= /opt/crosstool/bin/arm-s3c2410-linux-gnu-

2、修改NandFlash分区,和Bootloader中的一样。我分了5个区。
[root@Sure linux-2.6.24.7]# vim arch/arm/plat-s3c24xx/common-smdk.c

static struct mtd_partition smdk_default_nand_part[] = {
    [0] = {
        .name = "Bootloader",
        .size = SZ_1M,
        .offset = 0,
    },
    [1] = {
        .name = "Kernel",
        .offset = SZ_1M,
        .size = SZ_1M * 3,
    },
    [2] = {
        .name = "Root",
        .offset = SZ_4M,
        .size = SZ_4M * 12,
    },
    [3] = {
        .name = "ExtRoot",
        .offset = SZ_4M * 13,
        .size = 0x00be0000, //12M - 128K

    },
    [4] = {
        .name = "Param",
        .offset = SZ_4M * 13 + 0x00be0000,
        .size = 0x00020000, //128K

    },
 };


3、修改fs/Kconfig文件,使内核支持devfs以及在启动时并在/sbin/init运行之前能自动挂载/dev为devfs文件系统。

menu "Pseudo filesystems"
#jacky -->
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
#jacky <--


4、移植CS8900A网卡驱动。从网上下载了cs8900驱动,是针对2.6.14内核的。
(1)将cs8900.c、cs8900.h复制到drivers/net/arm目录下。
(2)在include/asm-arm/arch-s3c2410/下新建smdk2410.h,添加如下代码:

#define pSMDK2410_ETH_IO __phys_to_pfn(0x19000000)
#define vSMDK2410_ETH_IO 0xe0000000
#define SMDK2410_ETH_IRQ IRQ_EINT9

(3)修改arch/arm/mach-s3c2410/mach-smdk2410.c文件(line:59):

static struct map_desc smdk2410_iodesc[] __initdata = {
  /* nothing here yet */
    {vSMDK2410_ETH_IO, pSMDK2410_ETH_IO, SZ_1M, MT_DEVICE},
    //added by Jacky_Xu @ 2008.7.12
};

(4)注意cs8900.c源文件中,cs8900_probe()函数中的两句话(见下)不能被注释掉,否则会检测不到网卡的,我在这里搞了一天时间,原来是下载的源码被人为注释掉了。。。

    __raw_writel(0x2211d110,S3C2410_BWSCON);
    __raw_writel(0x1f7c,S3C2410_BANKCON3);

(5)在drivers/net/arm/Kconfig中添加编译选项。这样,在menuconfig时,CS8900A网卡会被添加并选中。

#jacky -->
config ARM_CS8900A
    tristate "CS8900A support"
    depends on NET_ETHERNET && ARM && ARCH_SMDK2410
    help
      Support for CS8900A chipset based Ethernet cards. If you have a network
      (Ethernet) card of this type, say Y and read the Ethernet-HOWTO,
      available from as well as. To compile this driver as a module,
      choose M here and read. The module will be called CS8900.o.
#jacky <--

(6)添加编译选项的依赖文件。在drivers/net/arm/Makefile中添加:

obj-$(CONFIG_ARM_CS8900A) += cs8900.o

5、复制make的配置文件。
[root@Sure linux-2.6.24.7]#  cp arch/arm/configs/s3c2410_defconfig .config

6、make menuconfig。上面手动添加的DEVFS和CS8900A应该都会出现并被选中了,再选择一些需要的东西,如传递给内核的参数、MMC/SD等。

7、make

8、把arch/arm/boot目录下的zImage下到板子上运行。我传递给内核的参数为
“root=/dev/nfs rw nfsroot=192.168.1.249:/home/jacky/root-s3c2410/rootfs ip=192.168.1.199:192.168.1.249:192.168.1.1:255.255.255.0:Jacky:eth0:off console=ttySAC0,115200 init=/linuxrc noinitrd”,可用Bootloader传,也可以在编译内核时写入内核。
以下是启动信息:

Boot Parameters: root=/dev/nfs rw nfsroot=192.168.1.249:/home/jacky/root-s3c2410/rootfs ip=192.168.1.199:192.168.1.249:192.168.1.1:255.255.255.0:Jacky:eth0:off console=ttySAC0,115200
init=/linuxrc noinitrd
Now, booting Linux...
Uncompressing Linux..................................................................
......................................... done, booting the kernel.
Linux version 2.6.24.7 (root@Sure) (gcc version 4.2.1) #5 Sat Jul 12 17:26:16 CST 2008
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
Machine: SMDK2410
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 200.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: root=/dev/nfs rw nfsroot=192.168.1.249:/home/jacky/busybox-s3c2410/root ip=192.168.1.199:192.168.1.249:192.168.1.1:255.255.255.0:Jacky:eth0:off console=ttySAC0,115200 init=/linuxrc
irq: clearing subpending status 00000003
PID hash table entries: 256 (order: 8, 1024 bytes)
timer tcon=00000000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8
Console: colour dummy device 80x30
console [ttySAC0] enabled
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: 61440KB available (3048K code, 314K data, 128K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 64 bytes
NET: Registered protocol family 16
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2410: Initialising architecture
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4800000, irq 33
DMA channel 1 at c4800040, irq 34
DMA channel 2 at c4800080, irq 35
DMA channel 3 at c48000c0, irq 36
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Bluetooth: Core ver 2.11
NET: Registered protocol family 31
Bluetooth: HCI device and connection manager initialized
Bluetooth: HCI socket layer initialized
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
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) &Acirc;&copy; 2001-2006 Red Hat, Inc.
JFS: nTxBlock = 480, nTxLock = 3840
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach
s3c2410-lcd: probe of s3c2410-lcd failed with error -22
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled
s3c2410-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
eth0: CS8900A rev E at 0xe0000300 irq=53, addr: 00: 0:3E:26:0A: 0
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2410-nand s3c2410-nand: Tacls=3, 30ns Twrph0=7 70ns, Twrph1=3 30ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
Scanning device for bad blocks
Creating 5 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x00000000-0x00100000 : "Bootloader"
0x00100000-0x00400000 : "Kernel"
0x00400000-0x03400000 : "Root"
0x03400000-0x03fe0000 : "ExtRoot"
0x03fe0000-0x04000000 : "Param"
usbmon: debugfs is not available
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: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-i2c s3c2410-i2c: slave address 0x10
s3c2410-i2c s3c2410-i2c: bus frequency set to 390 KHz
s3c2410-i2c s3c2410-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
IP-Config: Complete:
      device=eth0, addr=192.168.1.199, mask=255.255.255.0, gw=192.168.1.1,
     host=Jacky, domain=, nis-domain=(none),
     bootserver=192.168.1.249, rootserver=192.168.1.249, rootpath=
Looking up port of RPC 100003/2 on 192.168.1.249
Looking up port of RPC 100005/1 on 192.168.1.249
VFS: Mounted root (nfs filesystem).

因为主机的/home/jacky/busybox-s3c2410/root的文件系统还没做好,所以停在这里了。从主机的/var/log/message看出来目标板已经尝试连接NFS服务了:

Jul 12 21:33:05 localhost rpc.mountd: authenticated mount request from 192.168.1.199:966 for /home/jacky/busybox-s3c2410/root (/home/jacky/busybox-s3c2410/root)
Jul 12 21:38:41 localhost rpc.mountd: authenticated mount request from 192.168.1.199:806 for /home/jacky/busybox-s3c2410/root (/home/jacky/busybox-s3c2410/root)


至此,2.6.24内核已经移植成功了,下面是做根文件系统了。
-----------------------------------
  Jacky_Xu @ 2008.7.13
  MSN: 

  E-mail: 
-----------------------------------

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