2014年11月4日 星期二

u-boot 編譯

~/qemu_image/bootloader -> 放置 u-boot

一、安裝 toolchain

參考前面文章 安裝 ARM toolchain

二、下載 u-boot


本文下載最新版 u-boot-latest.bz2 (u-boot-2014-07)

mkdir -p ~/qemu_image/bootloader
cd ~/qemu_image/bootloader
wget ftp://ftp.denx.de/pub/u-boot/u-boot-latest.bz2
tar xfva  u-boot-latest.bz2

會得到目前最新版 u-boot-2014.10 。

三、查看設定參數

先設我們要用板子是 Beagle Board…
cd ~/qemu_image/bootloader/u-boot-2014.10/
vi boards.cfg

內容如下(可以得知參數為 omap3_beagle ):
omap3_beagle                 arm         armv7       beagle              ti             omap3

下指令設定參數 config
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap3_beagle_config

設定完成會出現:
Configuring for omap3_beagle board...

四、編譯 u-boot

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- all -j ${core number}

編完會出現四個檔案:
MLO
u-boot
u-boot.bin
u-boot.img

五、測試 u-boot 開機

cat MLO u-boot u-boot.bin u-boot.img > sd.img
qemu-system-arm -M beagle -nographic -sd sd.img

結果會因為沒核心,而當機,如下輸出:
U-Boot SPL 2012.07 (Oct 04 2012 - 11:43:34)
Texas Instruments Revision detection unimplemented
OMAP SD/MMC: 0
mmc_init_stream: timedout waiting for cc!
spl: mmc init failed: err - -19
### ERROR ### Please RESET the board ###


離開 QEMU 方法:
先按 Ctrl + A
放開 Ctrl + A
再單按 X 鍵

Debug
開虛擬機出現下面訊息:
qemu: hardware error: no boot device found
CPU #0:
R00=00000000 R01=00000000 R02=00000000 R03=00000000
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00000000
R12=00000000 R13=00000000 R14=00000000 R15=400140a4
PSR=400001d3 -Z-- A svc32
s00=00000000 s01=00000000 d00=0000000000000000
s02=00000000 s03=00000000 d01=0000000000000000
s04=00000000 s05=00000000 d02=0000000000000000
s06=00000000 s07=00000000 d03=0000000000000000
s08=00000000 s09=00000000 d04=0000000000000000
s10=00000000 s11=00000000 d05=0000000000000000
s12=00000000 s13=00000000 d06=0000000000000000
s14=00000000 s15=00000000 d07=0000000000000000
s16=00000000 s17=00000000 d08=0000000000000000
s18=00000000 s19=00000000 d09=0000000000000000
s20=00000000 s21=00000000 d10=0000000000000000
s22=00000000 s23=00000000 d11=0000000000000000
s24=00000000 s25=00000000 d12=0000000000000000
s26=00000000 s27=00000000 d13=0000000000000000
s28=00000000 s29=00000000 d14=0000000000000000
s30=00000000 s31=00000000 d15=0000000000000000
s32=00000000 s33=00000000 d16=0000000000000000
s34=00000000 s35=00000000 d17=0000000000000000
s36=00000000 s37=00000000 d18=0000000000000000
s38=00000000 s39=00000000 d19=0000000000000000
s40=00000000 s41=00000000 d20=0000000000000000
s42=00000000 s43=00000000 d21=0000000000000000
s44=00000000 s45=00000000 d22=0000000000000000
s46=00000000 s47=00000000 d23=0000000000000000
s48=00000000 s49=00000000 d24=0000000000000000
s50=00000000 s51=00000000 d25=0000000000000000
s52=00000000 s53=00000000 d26=0000000000000000
s54=00000000 s55=00000000 d27=0000000000000000
s56=00000000 s57=00000000 d28=0000000000000000
s58=00000000 s59=00000000 d29=0000000000000000
s60=00000000 s61=00000000 d30=0000000000000000
s62=00000000 s63=00000000 d31=0000000000000000
FPSCR: 00000000
已經終

解決:
fdisk sd.img
a
1
w

將開機選項 * 加到 sd.img 第一分割區。






Reference:

沒有留言:

張貼留言