2.6.24.4内核移植到s3c2440----之使用busybox-1.9.2制作根文件系统 --------------------------------------------------------------------------------------------------- 移植环境: 主机:CentOS 5.1 交叉编译器:arm-linux-gcc-3.4.1 开发板平台:S3C2440(YL-2440/YLP-2440开发板) 开始移植 1. 下载最新的busybox1.9.2,并解压缩。 下载busybox源代码:http://busybox.net/downloads/busybox-1.9.2.tar.bz2 交叉编译工具:同内核 解压源码:tar -jxvf busybox-1.9.2.tar.bz2 2. 修改Makefile中的174行的 arch和编译工具链头。 ARCH ?= arm CROSS_COMPILE ?= /usr/local/arm/3.4.1/bin/arm-linux- 3. make menuconfig. 修改编译配置选项。 Busybox Setting-----> build option--> [ ] Build BusyBox as a static binary (no shared libs) [*] Build shared libbusybox [*] Produce a binary for each applet, linked against libbusybox [*] Produce additional busybox binary linked against libbusybox [ ] Build with Large File Support (for accessing files > 2 GB) installation option--> [*] Don't use /usr Applets links (as soft-links) ---> (./_install) BusyBox installation prefix Busybox Library Tuning ---> MD5: Trade Bytes for Speed [*] Faster /proc scanning code (+100 bytes) [*] Support for /etc/networks [*] Support for /etc/networks [*] Additional editing keys [*] vi-style line editing commands [*] History saving [*] Tab completion [*] Username completion [*] Fancy shell prompts Linux Module Utilities ---> [*] Support version 2.6.x Linux kernels [*] insmod [*] Enable load map (-m) option [*] Symbols in load map [*] rmmod [*] lsmod [*] lsmod pretty output for 2.6.x Linux kernels [*] modprobe [ ] Multiple options parsing [ ] Fancy alias parsing --- Options common to multiple modutils [ ] Support tainted module checking with new kernels [ ] Support version 2.2.x to 2.4.x Linux kernels [*] Support version 2.6.x Linux kernels 其他的用默认值 4.编译busybox [kevin@localhost busybox-1.9.2]# make install 在busybox/_install 目录下会生成我们需要的文件。 5. 修改_install/bin/busybox的属性。为4755 chmod 4755 ./_install/bin/busybox 必须要要修改属性,否则在busybox中很多命令会受限制,比如: $ su su: must be suid to work properly 6.建立root fs的文件系统所需的目录和文件。 Mkdir /nfsroot Mkdir /nfsroot/s3c2440 在root文件夹中建立基本的目录 [root@centos s3c2440]# ls bin dev home linuxrc proc sbin tmp var boot etc lib mnt root sys usr 6. 以root身份建立节点文件/dev/console, /dev/null mknod -m 600 dev/console c 5 1 mknod -m 666 dev/null c 1 3 7. 建立配置文件如下: [root@centos etc]# more profile #!/bin/sh #/etc/profile:system-wide .profile file for the Bourne shells echo echo -n "Processing /etc/profile......" # Set search library path export LD_LIBRARY_PATH=/lib:/usr/lib # set user path export PATH=/bin:/sbin:/usr/bin:/usr/sbin #Set PS1 USER = "`id -un`" LOGNAME=$USER PS1='[/u@/h/W]/$' PATH=$PATH echo "Done!" [root@centos etc]# more init.d/rcS #!/bin/sh # set hostname, needed host file in /etc directory #./etc/host hostname `cat /etc/host` # mount all filesystem defined in "fstab" echo "#mount all......." /bin/mount -a #+yangdk /bin/chmod 0666 /dev/null echo "# starting mdev...." /bin/echo /sbin/mdev > /proc/sys/kernel/hotplug mdev -s /usr/etc/init echo "******************************************" echo " yangdk linux-2.6.24.4 boot " echo " 2008-5-9 " echo " " echo "******************************************" [root@centos etc]# more fstab host inittab passwd shadow group init.d/ mdev.conf profile [root@centos etc]# more fstab proc /proc proc defaults 0 0 none /tmp ramfs defaults 0 0 none /var ramfs defaults 0 0 mdev /dev ramfs defaults 0 0 sysfs /sys sysfs defaults 0 0 [root@centos etc]# more inittab ::sysinit:/etc/init.d/rcS ::respawn:-/bin/sh tty2::askfirst:-/bin/sh ::ctrlaltdel:/bin/umount -a -r ::shutdown:/bin umount -a -r ::shutdown:/sbin/swapoff -a [root@centos etc]# more ../usr/etc/init #!/bin/sh ifconfig eth0 192.168.1.111 up ifconfig lo 127.0.0.1 8.建立文件/etc/mdev.conf,内容为空 [root@centos etc]# vi mdev.conf 9.复制主机/etc/下面的文件passwd, group, shadow文件到/etc [root@centos etc]# cp /etc/group . [root@centos etc]# cp /etc/passwd . [root@centos etc]# cp /etc/shadow . ok,所需要的文件都已经建立ok了 [root@centos etc]# ls fstab group host init.d inittab mdev.conf passwd profile shadow 10.复制刚刚编译的busybox到/root目录下 [root@centos _install]# sudo cp -Rfv * /nfsroot/s3c2440 11.因为是编译的时候使用的是动态链接。所以先看看/busybox/_install/bin/busybox使用了哪些lib,然后从glibc复制相应的lib到/nfsroot/s3c2440/lib中。 [root@centos bin]# /usr/local/arm/3.4.1/arm-linux-gnu-readelf -d busybox Dynamic section at offset 0xb8014 contains 22 entries: Tag Type Name/Value 0x00000001 (NEEDED) Shared library:[libcrypt.so.1] 0x00000001 (NEEDED) Shared library: [libm.so.6] 0x00000001 (NEEDED) Shared library: [libc.so.6] 0x0000000c (INIT) 0xc04c 0x0000000d (FINI) 0xa26f0 0x00000004 (HASH) 0x80e8 0x00000005 (STRTAB) 0xa384 0x00000006 (SYMTAB) 0x8b24 …… …… …… 复制lib 文件到lib目录下: [root@centos lib]cp /usr/local/arm/3.4.1/arm-linux/lib/ld* . [root@centos lib]cp /usr/local/arm/3.4.1/arm-linux/lib/libc-2.3.2.so . [root@centos lib]cp /usr/local/arm/3.4.1/arm-linux/lib/libc.so.6 . [root@centos lib]cp /usr/local/arm/3.4.1/arm-linux/lib/libm * . [root@centos lib]cp /usr/local/arm/3.4.1/arm-linux/lib/libcrypt* . 12.使用工具mkcramfs将整个s3c2440文件夹制作成文件系统 [root@centos nfsroot]# mkcramfs s3c2440 fs_2.6.24.4_busybox.cramfs -e 2.6.24.4 下载并烧录到nandflash中。启动… Read chip id = ec76 Nand flash status = c0 Set boot params = root=/dev/mtdblock2 init=/linuxrc load_ramdisk=0 console=ttySAC1,115200 mem=65536K devfs=mount Load Kernel... Linux version 2.6.24.4 (root@centos) (gcc version 3.4.1) #49 Wed May 7 18:57:08 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 S3C2440A (id 0x32440001) S3C244X: core 400.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/mtdblock2 init=/linuxrc load_ramdisk=0 console=ttySAC1,115200 mem=65536K devfs=mount irq: clearing pending ext status 0005f600 irq: clearing subpending status 0000009a irq: clearing subpending status 00000092 PID hash table entries: 256 (order: 8, 1024 bytes) timer tcon=00590000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8 Console: colour dummy device 80x30 console [ttySAC1] 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: 61628KB available (2824K code, 299K data, 120K 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 S3C2440: Initialising architecture S3C2440: IRQ Support S3C2440: Clock Support, DVS off 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 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) 漏 2001-2006 Red Hat, Inc. 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 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 RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize loop: module loaded Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410) +yangdk-->debug:PP_IntNum: 21844 +yangdk-->debug2:PP_IntNum: 21840 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 s3c2440-nand s3c2440-nand: Tacls=1, 10ns Twrph0=4 40ns, Twrph1=1 10ns NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit) NAND_ECC_NONE selected by board driver. This is not recommended !! Scanning device for bad blocks Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit": 0x00000000-0x00030000 : "Bootloader" 0x00030000-0x00200000 : "Linux kernel" 0x00200000-0x02000000 : "Linux rootfs" 0x02000000-0x04000000 : "User" 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 s3c2440-i2c s3c2440-i2c: slave address 0x10 s3c2440-i2c s3c2440-i2c: bus frequency set to 390 KHz s3c2440-i2c s3c2440-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 RPC: Registered udp transport module. RPC: Registered tcp transport module. VFS: Mounted root (cramfs filesystem) readonly. Freeing init memory: 120K init started: BusyBox v1.9.2 (2008-04-16 00:31:28 CST) starting pid 766, tty '': '/etc/init.d/rcS' #mount all....... chmod: /dev/null: No such file or directory # starting mdev.... +yangdk--->debug:request_irq successful ****************************************** yangdk linux-2.6.24.4 boot 2008-5-9 ****************************************** starting pid 776, tty '': '/bin/sh' Processing /etc/profile......-/bin/sh: USER: not found Done! [root@yangdk/]#