pcDuino + busybox 成功搭建最小linux系統

通過一週的嘗試,個人pcDuino mini linux系統跑起來了。下面能夠專心作驅動開發,以及移植本身的Android系統。 node

準備一張tf卡,我用的1G Kingstorm。準備文件:sunxi-spl.bin、u-boot.bin、script.bin、uImage、boot.scr、uEnv.txt、rootfs linux

linux最小系統制做過程(詳細過程見linux移植一二三)以下: ubuntu

change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ ls /dev/sdb
sdb sdb1 ui

change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1
change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo sfdisk -R /dev/sdb this

change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo cat < 1,16,c
> ,,L
> EOT .net

change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo mkfs.vfat /dev/sdb1
mkfs.vfat 3.0.7 (24 Dec 2009)
change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo mkfs.ext4 /dev/sdb2 orm

change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo dd if=spl/sunxi-spl.bin of=/dev/sdb bs=1024 seek=8
change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo dd if=u-boot.bin of=/dev/sdb bs=1024 seek=32 遞歸

change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo mount /dev/sdb1 /mnt/ 接口

change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo cp ../linux-sunxi-sunxi-3.0/arch/arm/boot/uImage /mnt/
change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo cp ../sunxi-tools-master/script.bin /mnt/
change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo cp ../boot.scr /mnt/
change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo cp ../uEnv.txt /mnt/
change@change :~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo umount /dev/sdb1 ip

/dev/sdb1 最後包括文件:script.bin、uImage、boot.scr、uEnv.txt

change@change :~/Si/A10/pcduino$ sudo umount /dev/sdb2
change@change :~/Si/A10/pcduino$ sudo mount /dev/sdc2 /mnt/
change@change :~/Si/A10/pcduino$ sudo cp -pR rootfs/* /mnt/ -d
change@change :~/Si/A10/pcduino$ sudo umount /dev/sdc2

/dev/sdb2 最後包括rootfs中因此文件,以下:

bin dev etc home lib linuxrc mnt proc run sbin sys tmp usr var

最後取下tf卡,插到pcDuino,設置串口115200 8 n 1,單板默認從tf卡啓動。

啓動界面以下:

U-Boot 2012.10 (Apr 19 2013 – 18:46:44) Allwinner Technology

CPU: SUNXI Family
Board: pcDuino
I2C: ready
DRAM: 1 GiB
MMC: SUNXI SD/MMC: 0
*** Warning – bad CRC, using default environment

In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
reading uEnv.txt

144 bytes read
Loaded environment from uEnv.txt
reading boot.scr

289 bytes read
Jumping to boot.scr
## Executing script at 44000000
Wrong image format for 「source」 command
reading script.bin

44900 bytes read
reading uImage

4693132 bytes read
## Booting kernel from Legacy Image at 48000000 …
Image Name: Linux-3.0.62
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 4693068 Bytes = 4.5 MiB
Load Address: 40008000
Entry Point: 40008000
Verifying Checksum … OK
Loading Kernel Image … OK
OK

Starting kernel …

Initializing cgroup subsys cpuset
Linux version 3.0.62 (change@change) (gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67) ) #1 PREEMPT Sat Apr 20 18:32:39 CST 2013
CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d
CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: sun4i
Memory cut off:
MALI : 0x5c000000 – 0x5fffffff ( 64 MB)
Ignoring unrecognised tag 0×00000000
Memory Reserved:
SYS : 0×43000000 – 0x4300ffff ( 64 kB)
VE : 0×44000000 – 0x48ffffff ( 80 MB)
G2D : 0×49000000 – 0x49ffffff ( 16 MB)
LCD : 0x5a000000 – 0x5bffffff ( 32 MB)
Memory policy: ECC disabled, Data cache writeback
chip-id: A10 (AW1623 revision C)
On node 0 totalpages: 245760
free_area_init_node: node 0, pgdat c0887ea0, node_mem_map c094e000
Normal zone: 1280 pages used for memmap
Normal zone: 0 pages reserved
Normal zone: 146176 pages, LIFO batch:31
HighMem zone: 768 pages used for memmap
HighMem zone: 97536 pages, LIFO batch:31
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 243712
Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait loglevel=8 panic=10
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 448MB 512MB = 960MB total
Memory: 833852k/833852k available, 149188k reserved, 393216K highmem
Virtual kernel memory layout:
vector : 0xffff0000 – 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 – 0xfffe0000 ( 896 kB)

……..//太長了,省略若干

mmc0: new high speed SD card at address 1234
[ 4.140000] mmc0: new high speed SD card at address 1234
mmcblk0: mmc0:1234 SA01G 942 MiB
[ 4.160000] mmcblk0: mmc0:1234 SA01G 942 MiB
mmcblk0: p1 p2
[ 4.170000] mmcblk0: p1 p2
Console: switching to colour frame buffer device 160×45
[ 4.290000] Console: switching to colour frame buffer device 160×45
regulator_init_complete: axp20_buck3: incomplete constraints, leaving on
[ 4.330000] regulator_init_complete: axp20_buck3: incomplete constraints, leaving on
regulator_init_complete: axp20_buck2: incomplete constraints, leaving on
[ 4.350000] regulator_init_complete: axp20_buck2: incomplete constraints, leaving on
regulator_init_complete: axp20_ldo4: incomplete constraints, leaving on
[ 4.360000] regulator_init_complete: axp20_ldo4: incomplete constraints, leaving on
regulator_init_complete: axp20_ldo3: incomplete constraints, leaving on
[ 4.380000] regulator_init_complete: axp20_ldo3: incomplete constraints, leaving on
regulator_init_complete: axp20_ldo2: incomplete constraints, leaving on
[ 4.390000] regulator_init_complete: axp20_ldo2: incomplete constraints, leaving on
regulator_init_complete: axp20_ldo1: incomplete constraints, leaving on
[ 4.410000] regulator_init_complete: axp20_ldo1: incomplete constraints, leaving on
sunxi-rtc sunxi-rtc: sunxi_rtc_gettime
[ 4.420000] sunxi-rtc sunxi-rtc: sunxi_rtc_gettime
sunxi-rtc sunxi-rtc: read time 2010-1-1 0:0:10
[ 4.430000] sunxi-rtc sunxi-rtc: read time 2010-1-1 0:0:10
sunxi-rtc sunxi-rtc: setting system clock to 2010-01-01 00:00:10 UTC (1262304010)
[ 4.440000] sunxi-rtc sunxi-rtc: setting system clock to 2010-01-01 00:00:10 UTC (1262304010)
EXT3-fs (mmcblk0p2): error: couldn’t mount because of unsupported optional features (240)
[ 4.460000] EXT3-fs (mmcblk0p2): error: couldn’t mount because of unsupported optional features (240)
EXT2-fs (mmcblk0p2): error: couldn’t mount because of unsupported optional features (244)
[ 4.480000] EXT2-fs (mmcblk0p2): error: couldn’t mount because of unsupported optional features (244)
EXT4-fs (mmcblk0p2): recovery complete
[ 5.840000] EXT4-fs (mmcblk0p2): recovery complete
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 6.060000] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 6.080000] VFS: Mounted root (ext4 filesystem) on device 179:2.
devtmpfs: mounted
[ 6.090000] devtmpfs: mounted
Freeing init memory: 164K
[ 6.090000] Freeing init memory: 164K
mount: mounting devpts on /dev/pts failed: No such file or directory
mount: mounting /dev/mmcblk0p1 on /boot failed: No such file or directory

Please press Enter to activate this console.

Processing /etc/profile… Done

/ # ls
bin home lost+found run tmp
dev lib mnt sbin usr
etc linuxrc proc sys var

/ # ifconfig eth0
eth0 Link encap:Ethernet HWaddr 12:5B:BD:7D:C4:75
BROADCAST MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:55 Base address:0×8000

/ # ifconfig eth0 172.16.1.133
wemac wemac.0: WARNING: no IRQ resource flags set.
[ 2360.950000] wemac wemac.0: WARNING: no IRQ resource flags set.
wemac wemac.0: eth0: link down
[ 2361.060000] wemac wemac.0: eth0: link down
ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 2361.070000] ADDRCONF(NETDEV_UP): eth0: link is not ready
/ #

詳細移植過程見linux移植1、2、三。花了很多時間啊,這是移植心得。pcduino linux移植期間遇到了很多問題,總結以下:

1.pkg-config能夠解決明明在本身機器上編譯好好的,在別人電腦上編譯就不行問題,它能爲已安裝的庫時提供統一接口。瞭解pkg-config解決Package libusb-1.0 was not found in the pkg-config search path

2.用busybox製做文件系統時,要注意文件的屬性。包括動態連接、執行權限等。經過sudo cp -pR file1 file2 -d,保留文件屬性,不然系統跑步起來。

cp命令選項含義以下:
- a 該選項一般在拷貝目錄時使用。它保留連接、文件屬性,並遞歸地拷貝目錄,其做用等於dpR選項的組合。
- d 拷貝時保留連接。
- f 刪除已經存在的目標文件而不提示。
- i 和f選項相反,在覆蓋目標文件以前將給出提示要求用戶確認。回答y時目標文件將被覆蓋,是交互式拷貝。
- p 此時cp除複製源文件的內容外,還將把其修改時間和訪問權限也複製到新文件中。
- r 若給出的源文件是一目錄文件,此時cp將遞歸複製該目錄下全部的子目錄和文件。此時目標文件必須爲一個目錄名。
- l 不做拷貝,只是連接文件。

3.ubuntu下燒寫tf卡命令,這裏容易出問題,發現雜牌子的tf卡就不行,卡了一段時間,最後果斷Kingstorm

4.Kernel panic – not syncing: No init found. Try passing init= option to kernel,這個問題說了找不到init,而我設置init=/sbin/init,顯然沒問題。緣由何在呢?

change@change :~/Si/A10/pcduino/rootfs$ ls sbin/ -l

lrwxrwxrwx 1 change change 14 2013-04-28 21:16 init -> ../bin/busybox

change@change :~/Si/A10/pcduino/rootfs$ file linuxrc
linuxrc: symbolic link to `bin/busybox’

發現bin/busybox是一個動態連接庫文件,依賴交叉編譯鏈的相應庫。而交叉編譯鏈庫有不少,試了發現../arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/lib/和 /home/change/tools/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/usr/lib/ 下的*.so*庫可使用。

還有拷貝後linuxrc有1.9M左右,若是拷貝時沒加 -d選項,拷貝後只有0字節,啓動時也會出現上面問題。

相關文章
相關標籤/搜索