编译文件系统移植linux-3.0.62 + busybox最小系统到单板TQ2440

改章节是一篇关于编译文件系统的帖子

    玩了一段时间裸板开辟,u-boot也植移好了,当初开始注专驱动开辟,首先把linux最小系统搭建起来,植移卡网驱动,用NFS挂载文件系统,再完善其它驱动。

    开辟环境:
系统:ubuntu 10.04.4
板单:tq2440
NAND FLASH:K9F1216U0A 256MB
NOR Flash:EN29LV160AB 2MB
SDRAM:HY57V561620 x2 64MB
NET:DM9000AEP
编译器:arm-none-linux-gnueabi-

    搭建开辟环境详见ubuntu 10.04.4开辟环境置配。
标目:
1.植移linux-3.0.62到板单,口串畸形出输内核启动信息
2.植移卡网驱动
3.busybox作制最小文件系统
4.NFS挂载文件系统

    一、植移linux-3.0.62到板单,口串畸形出输内核启动信息

    1.载下源码

    linux源码https://www.kernel.org/pub/linux/kernel/v3.0/ 载下linux-3.0.62.tar.bz2。

    取获交叉编译链 http://code.google.com/p/smp-on-qemu/downloads/list 选择arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2并载下。然后在ubuntu下直接解压便可

    2.置配、编译

    首先修改根目录下Makefile:195

    ARCH  ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)

    改成:其中/home/change/tools/arm-2009q3是我的解压径路

    ARCH  ?= arm
CROSS_COMPILE ?= /home/change/tools/arm-2009q3/bin/arm-none-linux-gnueabi-

    change@change:~/Si/linux-3.0.62$ make s3c2410_defconfig

    change@change:~/Si/linux-3.0.62$ make uImage

    编译胜利,烧写内核到板单,启动会提示machid error,Please check your kernel config and/or bootloader.并且供持支板单的id,其中0000016a   SMDK2440,OK设置id

    U-Boot 2012.04.01 (May 04 2013 - 15:32:54)

    CPUID: 32440001
FCLK:      400 MHz
HCLK:      100 MHz
PCLK:       50 MHz
DRAM:  64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Hit any key to stop autoboot:  0
TQ2440 # mtdpart

    device nand0 <TQ2440-0>, # parts = 4
 #: name                size            offset          mask_flags
 0: u-boot              0x00040000      0x00000000      0
 1: params              0x00020000      0x00040000      0
 2: kernel              0x00400000      0x00060000      0
 3: rootfs              0x0fba0000      0x00460000      0

    active partition: nand0,0 - (u-boot) 0x00040000 @ 0x00000000

    defaults:
mtdids  : nand0=TQ2440-0
mtdparts: mtdparts=TQ2440-0:256k(u-boot),128k(params),4M(kernel),-(rootfs)
TQ2440 # tftp 0x32000000 uImage
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:0c:29:4d:e4:f4
could not establish link
Using dm9000 device
TFTP from server 172.16.1.132; our IP address is 172.16.1.111
Filename 'uImage'.
Load address: 0x32000000
Loading: #################################################################
         #################################################################
         ###########################
done
Bytes transferred = 2297920 (231040 hex)
TQ2440 # nand erase.part kernel

    NAND erase.part: device 0 offset 0x60000, size 0x400000
Erasing at 0x440000 -- 100% complete.
OK
TQ2440 # nand write 0x32000000 kernel

    NAND write: device 0 offset 0x60000, size 0x400000
 4194304 bytes written: OK
TQ2440 # set machid 16a

    TQ2440 # boot

    NAND read: device 0 offset 0x60000, size 0x400000
 4194304 bytes read: OK
## Booting kernel from Legacy Image at 30000000 ...
   Image Name:   Linux-3.0.62
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2297856 Bytes = 2.2 MiB
   Load Address: 30108000
   Entry Point:  30108000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK
Using machid 0x16a from environment

    Starting kernel ...

    Uncompressing Linux... done, booting the kernel.
8??腛s?浄''d??G寑8?惴Lc;儳`納[?竾腛s?嫥''凣矴硨€D$ttD##[#[莽c?[?掣柠Ъ荂7?<{劎t?3'媚

    面下修改源码,新建Source Insight工程。看到编译的uImage这么大,顺便把我的u-boot分区kernel分大了点。涌现码乱应当时钟问题。置配文件*_defconfig在arch/arm/configs,machid在include/generated/mach-types.h.修改arch/arm/mach-s3c2440/mach-smdk2440.c:163:

    s3c24xx_init_clocks(16934400);改成s3c24xx_init_clocks(12000000);//TQ2440板单的晶振是12M

    再次置配编译成生的uImage就可以畸形出输启动信息了。

    二、修改板单源码

    1.增长NAND分区

    修改arch/arm/pla-s3c24xxt/common-smdk.c.根据前以u-boot分区修改,将NAND分区改成如下

    /* NAND parititon from 2.4.18-swl5 */

    static struct mtd_partition smdk_default_nand_part[] = {
 [0] = {
  .name = "u-boot",
  .size = SZ_256K,
  .offset = 0,
 },
 [1] = {
  .name = "u-boot-env",
  .offset = SZ_128K,
  .size = SZ_256K,
 },
 [2] = {
  .name = "kernel",
  .offset = SZ_256K + SZ_128K,
  .size = SZ_4M,
 },
 [3] = {
  .name = "rootfs",
  .offset = SZ_256K + SZ_128K + SZ_4M,
  .size = MTDPART_SIZ_FULL,
 }
};

    2.DM9000持支

    其实当初linux内核自带DM9000卡网驱动,我们只需要置配便可,谈不上什么植移,参考别人码代修改eg:mach-mini2440.c。修改arch/arm/mach-s3c2440/mach-smdk2440.c.从mach-mini2440.c拷贝DM9000分部序程,并修改成TQ2440.

    #include <linux/dm9000.h>

    #define MACH_TQ2440_DM9K_BASE (S3C2410_CS4 + 0x300)
/* DM9000AEP 10/100 ethernet controller */

    static struct resource TQ2440_dm9k_resource[] = {
 [0] = {
  .start = MACH_TQ2440_DM9K_BASE,
  .end   = MACH_TQ2440_DM9K_BASE + 3,
  .flags = IORESOURCE_MEM
 },
 [1] = {
  .start = MACH_TQ2440_DM9K_BASE + 4,
  .end   = MACH_TQ2440_DM9K_BASE + 7,
  .flags = IORESOURCE_MEM
 },
 [2] = {
  .start = IRQ_EINT7,
  .end   = IRQ_EINT7,
  .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
 }
};

    /*
 * The DM9000 has no eeprom, and it's MAC address is set by
 * the bootloader before starting the kernel.
 */
static struct dm9000_plat_data TQ2440_dm9k_pdata = {
 .flags  = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
};

    static struct platform_device TQ2440_device_eth = {
 .name  = "dm9000",
 .id  = -1,
 .num_resources = ARRAY_SIZE(TQ2440_dm9k_resource),
 .resource = TQ2440_dm9k_resource,
 .dev  = {
  .platform_data = &TQ2440_dm9k_pdata,
 },
};

    再将&TQ2440_device_eth,添加到static struct platform_device *smdk2440_devices[]

    static struct platform_device *smdk2440_devices[] __initdata = {
 &s3c_device_ohci,
 &s3c_device_lcd,
 &s3c_device_wdt,
 &s3c_device_i2c0,
 &s3c_device_iis,
 &TQ2440_device_eth,
 &s3c_device_nand,
};

    开始编译,有问题再修改。make menuconfig 看到认默置配是持支DM9000的

    change@change:~/Si/linux-3.0.62$ make uImage

    编译胜利,烧到NAND,内核启动出输如下

    
NAND read: device 0 offset 0x60000, size 0x400000
 4194304 bytes read: OK
## Booting kernel from Legacy Image at 30000000 ...
   Image Name:   Linux-3.0.62
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2297764 Bytes = 2.2 MiB
   Load Address: 30108000
   Entry Point:  30108000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK
Using machid 0x16a from environment

    Starting kernel ...

    Uncompressing Linux... done, booting the kernel.
Linux version 3.0.62 (change@change) (gcc version 4.7.3 20130328 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) ) #7 Sat May 4 18:39:15 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
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: console=ttySAC0,115200 root=/dev/mtdblock3 rootfstype=jffs2
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: 60200k/60200k available, 5336k 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 : 0xc0108000 - 0xc012f000   ( 156 kB)
      .text : 0xc012f000 - 0xc0541000   (4168 kB)
      .data : 0xc0542000 - 0xc0570320   ( 185 kB)
       .bss : 0xc0570344 - 0xc0599058   ( 164 kB)
NR_IRQS:99
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
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
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.24.
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 named UNIX socket transport module.
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 117
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
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
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
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
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=2, 20ns Twrph0=6 60ns, Twrph1=2 20ns
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
Bad eraseblock 549 at 0x0000044a0000
Creating 4 MTD partitions on "NAND":
0x000000000000-0x000000040000 : "u-boot"
0x000000020000-0x000000060000 : "u-boot-env"
0x000000060000-0x000000460000 : "kernel"
0x000000460000-0x000010000000 : "rootfs"
dm9000 Ethernet Driver, V1.31
eth0: dm9000e at c4862300,c4864304 IRQ 51 MAC: 00:0c:29:4d:e4:f4 (chip)
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
mousedev: 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)
VFS: Mounted root (jffs2 filesystem) on device 31:3.
Freeing init memory: 156K
Kernel panic - not syncing: No init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
Backtrace:
[<c013dc7c>] (dump_backtrace+0x0/0x10c) from [<c044df4c>] (dump_stack+0x18/0x1c)
 r6:c0155f38 r5:c04dd52c r4:c0570898
[<c044df34>] (dump_stack+0x0/0x1c) from [<c044e0d0>] (panic+0x64/0x188)
[<c044e06c>] (panic+0x0/0x188) from [<c044ddcc>] (init_post+0xac/0xd0)
 r3:00000000 r2:00000012 r1:00000080 r0:c04dd52c
 r7:00000013
[<c044dd20>] (init_post+0x0/0xd0) from [<c0108a64>] (kernel_init+0xf8/0x128)
 r4:c012853c
[<c010896c>] (kernel_init+0x0/0x128) from [<c0155f38>] (do_exit+0x0/0x6a0)
 r5:c010896c r4:00000000

    三、作制最小根文件系统

    1.编译安装busybox

    在http://www.busybox.net/载下busybox-1.21.0

    首先修改根目录下Makefile:195

    190:ARCH  ?= $(SUBARCH)
164:CROSS_COMPILE ?=

    改成:其中/home/change/tools/arm-2009q3是我的解压径路

    ARCH  ?= arm
CROSS_COMPILE ?= /home/change/tools/arm-2009q3/bin/arm-none-linux-gnueabi-

    change@change:~/Si$ tar xjf busybox-1.21.0.tar.bz2
change@change:~/Si$ cd busybox-1.21.0/
change@change:~/Si/busybox-1.21.0$ vim Makefile

    change@change:~/Si/busybox-1.21.0$ make menuconfig
change@change:~/Si/busybox-1.21.0$ make

    认默置配,编译OK,接着安装到我的nfs同享目录

    change@change:~/Si/busybox-1.21.0$ make install CONFIG_PREFIX=/home/change/work/nfs_root/rootfs_dir

    change@change:~/Si/busybox-1.21.0$ ls /home/change/work/nfs_root/rootfs_dir -l
total 12
drwxr-xr-x 2 change change 4096 2013-05-04 21:02 bin
lrwxrwxrwx 1 change change   11 2013-05-04 21:02 linuxrc -> bin/busybox
drwxr-xr-x 2 change change 4096 2013-05-04 21:02 sbin
drwxr-xr-x 4 change change 4096 2013-05-04 21:02 usr

    2.安装glibc库

    change@change:~/work/nfs_root/rootfs_dir$ mkdir lib
change@change:~/work/nfs_root/rootfs_dir$ cp /home/change/tools/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/lib/*.so* lib/ -d
change@change:~/work/nfs_root/rootfs_dir$ cp /home/change/tools/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/usr/lib/*.so* lib/ -d
change@change:~/work/nfs_root/rootfs_dir$ 

    3.建创备设文件

    change@change:~/work/nfs_root/rootfs_dir$ mkdir dev
change@change:~/work/nfs_root/rootfs_dir$ sudo mknod dev/console c 5 1
[sudo] password for change:
change@change:~/work/nfs_root/rootfs_dir$ sudo mknod dev/null c 1 3

    4.构建置配文件

    change@change:~/work/nfs_root/rootfs_dir$ mkdir etc
change@change:~/work/nfs_root/rootfs_dir$ vim etc/inittab

    console::askfirst:-/bin/sh

    ::sysinit:/etc/init.d/rcS

    保存退出

    change@change:~/work/nfs_root/rootfs_dir$ vim etc/init.d/rcS

    #!/bin/sh

    ifconfig eth0 172.16.1.111

    mount-a

    change@change:~/work/nfs_root/rootfs_dir$ chmod +x etc/init.d/rcS
change@change:~/work/nfs_root/rootfs_dir$ vim etc/fstab

    proc     /proc     proc     defaults     0     0

    5.建创其它文件

    change@change:~/work/nfs_root/rootfs_dir$ mkdir proc mnt tmp sys root

    最小根文件系统弄定,开始验证,用NFS挂载文件系统启动

    四、烧写、测试

    板单从NAND启动,口串出输

    
U-Boot 2012.04.01 (May 04 2013 - 15:32:54)

    CPUID: 32440001
FCLK:      400 MHz
HCLK:      100 MHz
PCLK:       50 MHz
DRAM:  64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Hit any key to stop autoboot:  0
TQ2440 # printenv   
baudrate=115200
bootargs=console=ttySAC0,115200 root=/dev/nfs nfsroot=172.16.1.132:/home/chang/work/ \
nfs_root/rootfs_dir nolock ip=172.16.1.111:172.16.1.132:172.16.1.1:255.255.255.0::eth0:off init=/linuxrc
bootcmd=nand read 30000000 kernel;bootm 30000000
bootdelay=5
ethact=dm9000
ethaddr=00:0c:29:4d:e4:f4
fileaddr=30000000
filesize=3B8E30
ipaddr=172.16.1.111
machid=16a
mtddevname=u-boot
mtddevnum=0
mtdids=nand0=TQ2440-0
mtdparts=mtdparts=TQ2440-0:256k(u-boot),128k(params),4M(kernel),-(rootfs)
netmask=255.255.255.0
partition=nand0,0
serverip=172.16.1.132
stderr=serial
stdin=serial
stdout=serial

    每日一道理
哦,妈妈 亲爱的妈妈,您对我的爱比太阳还要炽热,比白雪更为圣洁。在我成长的道路上,您就是女儿夏日里的浓荫,冬天里的炭火,您更是女儿人生路上的一盏明灯。

    Environment size: 645/131068 bytes
TQ2440 # tftp 0x32000000 uImage
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:0c:29:4d:e4:f4
could not establish link
Using dm9000 device
TFTP from server 172.16.1.132; our IP address is 172.16.1.111
Filename 'uImage'.
Load address: 0x32000000
Loading: #################################################################
         #################################################################
         #############################################
done
Bytes transferred = 2563820 (271eec hex)
TQ2440 # nand erase.part kernel

    NAND erase.part: device 0 offset 0x60000, size 0x400000
Erasing at 0x440000 -- 100% complete.
OK
TQ2440 # nand write 0x32000000 kernel

    NAND write: device 0 offset 0x60000, size 0x400000
 4194304 bytes written: OK
TQ2440 # boot

    ..................................//省略干若

    dm9000 dm9000: eth0: link down
IP-Config: Complete:
     device=eth0, addr=172.16.1.111, mask=255.255.255.0, gw=172.16.1.1,
     host=172.16.1.111, domain=, nis-domain=(none),
     bootserver=172.16.1.132, rootserver=172.16.1.132, rootpath=
dm9000 dm9000: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "nfs" or unknown-block(2,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00             256 mtdblock0  (driver?)
1f01             256 mtdblock1  (driver?)
1f02            4096 mtdblock2  (driver?)
1f03          257664 mtdblock3  (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
Backtrace:
[<c0140c70>] (dump_backtrace+0x0/0x10c) from [<c04a1fe8>] (dump_stack+0x18/0x1c)
 r6:c05c06e0 r5:c05c0b98 r4:c05c0b98
[<c04a1fd0>] (dump_stack+0x0/0x1c) from [<c04a2050>] (panic+0x64/0x190)
[<c04a1fec>] (panic+0x0/0x190) from [<c0108f10>] (mount_block_root+0x174/0x228)
 r3:c384b2b4 r2:00000000 r1:c3819f54 r0:c052e9f8
[<c0108d9c>] (mount_block_root+0x0/0x228) from [<c0109098>] (mount_root+0xd4/0xf8)
[<c0108fc4>] (mount_root+0x0/0xf8) from [<c0109228>] (prepare_namespace+0x16c/0x1c0)
 r7:00000013 r6:c015b3c0 r5:c0129b2d r4:c05c06e0
[<c01090bc>] (prepare_namespace+0x0/0x1c0) from [<c0108494>] (kernel_init+0xec/0x128)
 r5:c01290ec r4:c01290ec
[<c01083a8>] (kernel_init+0x0/0x128) from [<c015b3c0>] (do_exit+0x0/0x6d0)
 r5:c01083a8 r4:00000000

    可能bootargs参数设置问题,从新设置

    TQ2440 # set bootargs root=/dev/nfs nfsroot=172.16.1.132:/home/change/work/nfs_root/rootfs_dir nolock \
> ip=172.16.1.111:172.16.1.132:172.16.1.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC0
TQ2440 # save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x40000 -- 100% complete.
Writing to Nand... done
TQ2440 # boot

    ..................................//省略干若

    dm9000 dm9000: eth0: link down
IP-Config: Complete:
     device=eth0, addr=172.16.1.111, mask=255.255.255.0, gw=172.16.1.1,
     host=172.16.1.111, domain=, nis-domain=(none),
     bootserver=172.16.1.132, rootserver=172.16.1.132, rootpath=
dm9000 dm9000: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
VFS: Mounted root (nfs filesystem) on device 0:12.
Freeing init memory: 160K
Kernel panic - not syncing: Attempted to kill init!
Backtrace:
[<c0140c70>] (dump_backtrace+0x0/0x10c) from [<c04a1fe8>] (dump_stack+0x18/0x1c)
 r6:c05a3e7c r5:c05c0b98 r4:c05c0b98
[<c04a1fd0>] (dump_stack+0x0/0x1c) from [<c04a2050>] (panic+0x64/0x190)
[<c04a1fec>] (panic+0x0/0x190) from [<c015ba60>] (do_exit+0x6a0/0x6d0)
 r3:60000013 r2:c3818000 r1:c3815e80 r0:c0533fc0
[<c015b3c0>] (do_exit+0x0/0x6d0) from [<c015bad4>] (do_group_exit+0x44/0xc4)
[<c015ba90>] (do_group_exit+0x0/0xc4) from [<c0168ac0>] (get_signal_to_deliver+0x1b8/0x3ac)
 r4:0830009f
[<c0168908>] (get_signal_to_deliver+0x0/0x3ac) from [<c013fb80>] (do_signal+0x8c/0x558)
[<c013faf4>] (do_signal+0x0/0x558) from [<c01400a0>] (do_notify_resume+0x54/0x60)
[<c014004c>] (do_notify_resume+0x0/0x60) from [<c013d974>] (work_pending+0x24/0x28)
 r4:400ba000

    挂载胜利了,可是Kernel panic - not syncing: Attempted to kill init!

    处理方法:内核编译时没选上EABI

    kernel features

    编译文件系统 Use the ARM EABI to compile the kernel                                             | |
  | |                编译文件系统   Allow old ABI binaries to run with this kernel (EXPERIMENTAL) (NEW)
置配内核后从新编译,应当就没问题了。心耐等吧,编译太慢了,试了问题还是没处理,来日再弄吧

    一般都是这样理处就没问题了,google看了不少文章,于终找到处理方法了

    修改busybox-1.21.0/Makefile:292

    cc = $(CROSS_COMPILE)gcc

    改成

    cc = $(CROSS_COMPILE)gcc -march=armv4t

    从新编译安装busybox以可就了,我终究的启动界面如下:

    
U-Boot 2012.04.01 (May 04 2013 - 15:32:54)

    CPUID: 32440001
FCLK:      400 MHz
HCLK:      100 MHz
PCLK:       50 MHz
DRAM:  64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Hit any key to stop autoboot:  0

    NAND read: device 0 offset 0x60000, size 0x400000
 4194304 bytes read: OK
## Booting kernel from Legacy Image at 30000000 ...
   Image Name:   Linux-3.0.62
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2597756 Bytes = 2.5 MiB
   Load Address: 30108000
   Entry Point:  30108000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK
Using machid 0x16a from environment

    Starting kernel ...

    Uncompressing Linux... done, booting the kernel.
Linux version 3.0.62 (
change@change) (gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67) ) #1 Sat May 4 23:23:28 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
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: /dev/nfs nfsroot=172.16.1.132:/home/change/work/rootfs_dir/fs_mini nolock
ip=172.16.1.111:172.16.1.132:172.16.1.1:255.255.255.0::eth0:off 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: 59920k/59920k available, 5616k 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 : 0xc0108000 - 0xc012e000   ( 152 kB)
      .text : 0xc012e000 - 0xc0587d9c   (4456 kB)
      .data : 0xc0588000 - 0xc05b6a60   ( 187 kB)
       .bss : 0xc05b6a84 - 0xc05df2c4   ( 163 kB)
NR_IRQS:99
irq: clearing pending ext status 00080000
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
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
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.24.
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 named UNIX socket transport module.
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 117
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
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
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
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
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=2, 20ns Twrph0=6 60ns, Twrph1=2 20ns
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
Bad eraseblock 549 at 0x0000044a0000
Creating 4 MTD partitions on "NAND":
0x000000000000-0x000000040000 : "u-boot"
0x000000020000-0x000000060000 : "u-boot-env"
0x000000060000-0x000000460000 : "kernel"
0x000000460000-0x000010000000 : "rootfs"
dm9000 Ethernet Driver, V1.31
dm9000 dm9000: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000e at c4862300,c4864304 IRQ 51 MAC: be:59:a6:f3:77:c8 (random)
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
mousedev: 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)
dm9000 dm9000: eth0: link down
IP-Config: Complete:
     device=eth0, addr=172.16.1.111, mask=255.255.255.0, gw=172.16.1.1,
     host=172.16.1.111, domain=, nis-domain=(none),
     bootserver=172.16.1.132, rootserver=172.16.1.132, rootpath=
dm9000 dm9000: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
VFS: Mounted root (nfs filesystem) on device 0:12.
Freeing init memory: 152K
mount: mounting proc on /proc failed: No such file or directory

    Please press Enter to activate this console.

    Processing /etc/profile... Done

    / # ls
bin      dev      etc      lib      linuxrc  sbin     usr
/ # ifconfig
ifconfig: /proc/net/dev: No such file or directory
eth0      Link encap:Ethernet  HWaddr BE:59:A6:F3:77:C8 
          inet addr:172.16.1.111  Bcast:172.16.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:51 Base address:0x2300

    lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1

    / # ping 172.16.1.132
PING 172.16.1.132 (172.16.1.132): 56 data bytes
64 bytes from 172.16.1.132: seq=0 ttl=64 time=1.420 ms
64 bytes from 172.16.1.132: seq=1 ttl=64 time=0.609 ms
^C
--- 172.16.1.132 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.609/1.014/1.420 ms
/ # ls
bin      dev      etc      lib      linuxrc  sbin     usr
/ #

    卡网也ping通了,基本畸形。就是下面Kernel panic 卡了一晚上。一般来说Freeing init memory: 152K,kernel已开始运行init进程了,但是rootfs与kernel在编译时使用了不同的ABI致导错误,OABI和EABI函数调用不平等。涌现Kernel panic- not syncing: Attempted to kill init!,不要张皇,基本上都已编译器置配不对引发的,心耐设置编译参数就没问题。

    搭建最小文件系统,遇到了些问题总结一下,免避再犯似类错误:

    1.编译、安装busybox。用高本版的交叉编译链,为了够能启动根文件系统,证保3点:

     1)置配linux内核时勾选EABI、ABI

     2)busybox/Makefile:cc = $(CROSS_COMPILE)gcc改成cc = $(CROSS_COMPILE)gcc -march=armv4t

     3)编译内核和busybox的交叉编译链必须致一

    2.安装glibc库。就是将交叉编译链中的库拷到根文件系统lib目录,拷贝时加“-d” 选上,留保接链

    3.构建置配文件,你可以一个个建创,也可以偷点勤,直接从busybox里拷贝eg:cp busybox-1.21.0/examples/bootfloppy/etc /home/change/work/rootfs_dir/fs_mini -r 然后再其基础上修改。我只是单简修改了etc/inittab 为

    console::askfirst:-/bin/sh    

 ::sysinit:/etc/init.d/rcS

    4.建创其它目录 eg:mkdir proc mnt tmp sys root

    以上4步以可就构建一个最小的根文件系统。面下续继完善根文件系统,增长主动建创备设节点 vim etc/fstab 

proc		/proc	proc	defaults    0	0
sysfs		/sys	sysfs	defaults    0	0
tmpfs		/tmp	tmpfs	defaults    0	0

 vim etc/init.d/rcS

#! /bin/sh

mount -a
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

    完善后的跟文件系统启动如下:

    ..................................

    dm9000 dm9000: eth0: link down
IP-Config: Complete:
     device=eth0, addr=172.16.1.111, mask=255.255.255.0, gw=172.16.1.1,
     host=172.16.1.111, domain=, nis-domain=(none),
     bootserver=172.16.1.132, rootserver=172.16.1.132, rootpath=
dm9000 dm9000: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
VFS: Mounted root (nfs filesystem) on device 0:12.
Freeing init memory: 152K
mkdir: can't create directory '/dev/pts': File exists

    Please press Enter to activate this console.

    Processing /etc/profile... Done

    / # ls
bin      etc      linuxrc  proc     sbin     tmp
dev      lib      mnt      root     sys      usr
/ # ifconfig
eth0      Link encap:Ethernet  HWaddr BA:7C:EB:08:59:BF 
          inet addr:172.16.1.111  Bcast:172.16.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3705 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2623 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2651020 (2.5 MiB)  TX bytes:438498 (428.2 KiB)
          Interrupt:51 Base address:0x2300

    lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

    / # cat /proc/devices
Character devices:
  1 mem
  2 pty
  3 ttyp
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  6 lp
  7 vcs
 10 misc
 13 input
 14 sound
 21 sg
 29 fb
 90 mtd
 99 ppdev
116 alsa
128 ptm
136 pts
180 usb
188 ttyUSB
189 usb_device
204 ttySAC
254 rtc

    Block devices:
  1 ramdisk
259 blkext
  7 loop
  8 sd
 31 mtdblock
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
179 mmc
/ #

 

文章结束给大家分享下程序员的一些笑话语录: 自从有了Photoshop,我再也不相信照片了!(没有Photoshop的年代,胶片照片年代做假的也不少,那时候都相信假的!)

你可能感兴趣的:(linux)