1. 程式人生 > >移植linux-3.0.62 + busybox最小系統到單板TQ2440

移植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.下載原始碼

獲取交叉編譯鏈 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-

編譯成功,燒寫核心到單板,啟動會提示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_256K,
  .size = SZ_128K,
 },
 [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的

編譯成功,燒到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 ([email protected]) (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

首先修改根目錄下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-

預設配置,編譯OK,接著安裝到我的nfs共享目錄

[email protected]:~/Si/busybox-1.21.0$ make install CONFIG_PREFIX=/home/change/work/nfs_root/rootfs_dir

[email protected]:~/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庫

3.建立裝置檔案

4.構建配置檔案

console::askfirst:-/bin/sh

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

儲存退出

#!/bin/sh

ifconfig eth0 172.16.1.111

mount-a

proc     /proc     proc     defaults     0     0

5.建立其它檔案

最小根檔案系統搞定,開始驗證,用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 (
[email protected]) (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
/ #

相關推薦

移植linux-3.0.62 + busybox系統單板TQ2440

玩了一段時間裸板開發,u-boot也移植好了,現在開始專注驅動開發,首先把linux最小系統搭建起來,移植網絡卡驅動,用NFS掛載檔案系統,再完善其它驅動。 開發環境: 系統:ubuntu 10.04.4 單板:tq2440 NAND FLASH:K9F1216U0A 25

#嵌入式Linux系統移植# yaffs2根檔案系統移植出錯記錄

busybox官網地址: 本次移植採用的busybox版本: busybox-1.26.0.tar.bz2 交叉編譯工具鏈版本: $ arm-linux-gcc -v gcc version 4.4.3 (ctng-1.6.1) 1

iperf-2.0.5移植到IMX6DQRM的linux-3.0.35

首先匯出交叉編譯鏈的路徑: export PATH=$PATH:/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/ 切換到iperf-2.0.5的主目錄

基於itop4412在Linux系統下的 ffmpeg 的移植和測試

近期在做一個視訊監控的專案,在網上了解到如下的方案: 用的V4L2的視訊驅動,然後配合ffmpeg、x264的軟體編解碼,通過udp上傳至pc顯示,配合開源的編解碼庫,實現h.264的流編碼與傳輸。 前面我們已經實現了x264編碼庫的移植,並且做了測

基於fl2440核心linux-3.0移植----新增adc驅動

三、配置核心 make menuconfig來配置核心,因為我用的核心是linux-3.0版本,其對ADC是預設選項的(不可選擇),   System Type  --->   -*- ADC common driver support  如果用的核心版本是不可選擇的,那個可以直接建立裝置

#嵌入式Linux系統移植# 對uboot移植和裁剪的一點點個人思考和總結

思路: 1.分析啟動流程 2.移植config檔案(smdk440_config) 3.移植包含控制條件編譯巨集的.h檔案(configs/s3c2440.h) 4.移植板級初始化.c檔案(s3c2440.c) 5.移植RAM初始化?DDR? 6.移植NorF

iMX6Q Linux 3.0.35移植ffmpeg及二進位制下載

編譯環境:Ubuntu 16.04.4交叉編譯工具:gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12        FFmpeg是一套可以用來記錄、轉換數字音訊、視訊,並能將其轉化為流的開源計算機程式。採用LGPL或GPL許可證。它提供

Linux系統移植之早期打印CONFIG_DEBUG_LL

ace makefile add ssa ptr 終端 同時 虛擬 固件 一、幾個關鍵宏定義   CONFIG_DEBUG_LL、 CONFIG_DEBUG_LL_INCLUDE   容我慢慢道來, 首先要使能早期打印, menuconfig必須選中CONFIG_

12、Cocos2dx 3.0遊戲開發找三之3.0中的生命周期分析

ide () mil and 地理 splay ioe ase ima 重開發人員的勞動成果。轉載的時候請務必註明出處:http://blog.csdn.net/haomengzhu/article/details/27706303 生命周期分析 在前面文章中我

CentOS 7.3系統安裝KVM

state lib mirror system 修改 creat port snapshot strong 安裝wget和vim yum install -y wget vim 修改yum源為阿裏源 wget -O /etc/yum.repos.d/CentOS-Ba

移植Linux-3.4.2內核到S3C2440

解析 Coding 復制 ace otf fail port segment abs 一、BootLoader引導內核過程 1、Bootloader的工作 1.1、將內核讀入內存 2.2、保存內核啟動參數到指定位置,內核啟動時去這個位置解析

[2018.3.25集訓]cti-

來源 所有 its AC 最小 ++ int mark out 題目大意 給定一個$n*m$的網格圖上 有些格子內存在炮臺,每個炮臺都被指定了上下左右四個方向中的某一個方向,並可以選定這個方向上的一個格子發動一次攻擊。 保證沒有任何炮臺能攻擊另一個炮臺,同時炮臺可以不攻擊。

LInux-3.0.8中基於S5PV210的GPIO模塊代碼追蹤和分析

clas deb down then rect drivers 基於 lee 使用   編寫按鍵驅動時,想知道內核是如何管理GPIO的,所以開始追蹤代碼,中間走了一些彎路,現記錄於此。   追蹤代碼之前,我猜測:第一,這部分代碼應該在系統set up階段執行;第二,GPIO

LInux-3.0.8中基於S5PV210的IRQ模塊代碼追蹤和分析

PV 塊代碼 smd 函數定義 void 全局 對數 radix ali init/main.c: 1 asmlinkage void start_kernel(void) 2 { 3 ...... 4 early_irq_init(); 5 in

Linux-3.0.8 input subsystem代碼閱讀筆記

wak evdev dump 輸入子系統 延遲 cbi reg 用戶空間 rup   先亂序記錄一下閱讀Linux input subsystem代碼的筆記。      在input device driver的入口代碼部分,需要分配並初始化input device結構,內

Linux虛擬機CentOS系統安裝

同時 防火 eboot 設置dns ping wall 磁盤文件 sysconfig 開始 最近在學習和工作中linux時,安裝了CentOS7的最小系統,發現最小系統沒有一些常用的命令等。在此,寫一篇博文,記錄一下Linux系統從新建虛擬機到最終可以上網的步驟,供自己復習

LOJ #10084. 「一本通 3.3 練習 1」圈(二分+SPFA判負環)

ont 題意 二分 size 描述 負環 -s bsp lan 題意描述:    見原LOJ:https://loj.ac/problem/10084 題解:   LOJ #10084. 「一本通 3.3 練習 1」最小圈(二分+SPFA判負環)

HDU 4370 0 or 1

urn int ifdef size std ems return spf queue #include <bits/stdc++.h>//題目要求01矩陣的//第一行除了A11只能有1個1//最後一列除了Ann只能有1個1//除了矩陣的四條邊,裏面的點要求該

linux 3.0.8 alsa資料流程分析

ALSA開啟資料流程      soc_pcm_open => cpu_dai->driver->ops->startup => platform->driver->ops->open => co

【Kibana6.3.0】Kibana6入門白教程之下載安裝與資料準備

1. Kibana簡介及下載安裝 Kibana是專門用來為ElasticSearch設計開發的,可以提供資料查詢,資料視覺化等功能。 下載地址為:https://www.elastic.co/downloads/kibana#ga-release,請選擇適合當前es版本的K