最近pcduino官方公布了kernel源碼,很是興奮,決定開始在pcduino上移植linux系統,有興趣的一起討論哈
目標:
1.移植u-boot 2012.10
2.移植linux內核
3.移植最小文件系統
開發環境:
系統:Ubuntu 10.04.4
單板:pcDuino
編譯器:arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
下面移植pcDuino官方最新公布的u-boot
1.獲取源碼
pcDuino提供的u-boot-sunxi https://github.com/pcduino/kernel 下載u-boot-sunxi源碼
獲取交叉編譯鏈 http://code.google.com/p/smp-on-qemu/downloads/list
選擇arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2並下載。然後在ubuntu下直接解壓即可,還要配置環境變量
sudo gedit /etc/environment
修改PATH,在最後再加“:/.../arm-2009q3/bin”,其中“...”是上面arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2解壓的路徑。
接著Log Out ubuntu系統,就可以直接使用交叉編譯鏈。
2.編譯u-boot
解壓上面下載的u-boot-sunxi-sunxi.zip到工作目錄,接著配置單板並編譯
make pcduino CROSS_COMPILE=arm-none-linux-gnueabi
最後輸出如下,編譯成功
arm-none-linux-gnueabi-ld -g -Ttext 0x50000000 \
-o hello_world -e hello_world hello_world.o libstubs.o \
-L/home/linuxidc/tools/arm-2009q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1 -lgcc
arm-none-linux-gnueabi-objcopy -O srec hello_world hello_world.srec 2>/dev/null
arm-none-linux-gnueabi-objcopy -O binary hello_world hello_world.bin 2>/dev/null
make[2]: Leaving directory `/home/linuxidc/Si/A10/pcduino/u-boot-sunxi-sunxi/examples/standalone'
make -C examples/api all
make[2]: Entering directory `/home/linuxidc/Si/A10/pcduino/u-boot-sunxi-sunxi/examples/api'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/linuxidc/Si/A10/pcduino/u-boot-sunxi-sunxi/examples/api'
make[1]: Leaving directory `/home/linuxidc/Si/A10/pcduino/u-boot-sunxi-sunxi'
3.燒寫、測試
上述生成的第一階段/spl/sunxi-spl.bin 、第二階段 /u-boot.bin,是支持sd卡啟動的,准備tf卡讀卡器,連接到PC,下面是燒寫命令
linuxidc@linuxidc:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.511973 s, 2.0 MB/s
linuxidc@linuxidc:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo dd if=spl/sunxi-spl.bin of=/dev/sdb bs=1024 seek=8
20+0 records in
20+0 records out
20480 bytes (20 kB) copied, 0.0134902 s, 1.5 MB/s
linuxidc@linuxidc:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo dd if=u-boot.bin of=/dev/sd
sda sda1 sda2 sda3 sda4 sda5 sda6 sdb
linuxidc@linuxidc:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo dd if=u-boot.bin of=/dev/sdb bs=1024 seek=32
171+1 records in
171+1 records out
175272 bytes (175 kB) copied, 0.0930407 s, 1.9 MB/s
取下tf卡,插到pcDuino的tf卡槽,接上串口線,pcDuino默認是從sd卡啟動的,上電串口輸出如下:
U-Boot SPL 2012.10 (Apr 19 2013 - 18:46:44)
DRAM: 1024MB
SUNXI SD/MMC: 0
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
sun4i#
u-boot基本移植成功,下階段實現目標二linux內核移植。http://www.linuxidc.com/Linux/2013-04/83606p2.htm