[RISCV]3, 用u-boot來引導riscv-linux kernel

上面一篇文章說到了一個問題,就是我們雖然已經實現了qemu在不使用busybear的情況下啓動kernel進shell,但是我們還是受制於bbl,雖然bbl也是開源的但是我們更習慣於u-boot來引導kernel,所以這篇就是來解決這個問題,用u-boot引導kernel。

1, 下載u-boot的最新源碼

git clone https://gitee.com/mirrors/u-boot.git

切到最新的版本

git checkout v2020.04-rc3

2, 編譯

最新版本的u-boot自帶了qemu-riscv相關的一些defconfig
在這裏插入圖片描述

make qemu-riscv64_defconfig
export ARCH="riscv"
export CONFIG_REMAKE_ELF="n"
export CROSS_COMPILE="riscv64-unknown-linux-gnu-"
export V="0"
make all -j8 V=0

編譯成功
在這裏插入圖片描述

3, 啓動

sudo qemu-system-riscv64 -nographic -machine virt \
        -kernel u-boot/u-boot \ 
        -drive file=linux/arch/riscv/boot/Image,format=raw,id=hd0 \
        -drive file=qemu_rootfs.img,format=raw,id=hd1\
        -append "root=/dev/vda rootfstype=ext4 rw console=ttyS0" \
        -device virtio-blk-device,drive=hd1

這裏出現error, 不能繼續引導kernel
在這裏插入圖片描述
這裏的錯誤提示是

Device 0: QEMU VirtIO Block Device
            Type: Hard Disk
            Capacity: 6.9 MB = 0.0 GB (14228 x 512)
... is now current device
** No partition table - virtio 0 **

這是因爲沒有找到啓動的設備,uboot有這麼幾種啓動設備
在這裏插入圖片描述
下一步就是我們要dd一個dev模擬上面的啓動介質。


雖然現在還沒能引導kernel,但是Uboot已經可以正常跑了,我們可以在此基礎上學習基於RISCV的Uboot.

========> To Be Continue…

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章