[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…

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