您尚未登录。

楼主 # 2021-06-06 09:28:18

riscv
会员
注册时间: 2021-06-06
已发帖子: 2
积分: 1

qemu 虚拟机运行 u-boot / opensbi

参考: https://github.com/u-boot/u-boot/blob/master/doc/board/emulation/qemu-riscv.rst

步骤:

1. 准备gcc & qemu

2. 克隆 u-boot 代码:

或者用这个加速地址:

3. 编译 u-boot

cd u-boot
make qemu-riscv64_defconfig
CROSS_COMPILE=riscv64-linux-gnu- make

4. qemu运行u-boot.bin

qemu-system-riscv64 -nographic -machine virt -bios u-boot

$ qemu-system-riscv64 -nographic -machine virt -bios u-boot


U-Boot 2021.07-rc3-00070-gc003d2cd6b (Jun 06 2021 - 09:19:12 +0800)

CPU:   rv64imafdcsu
Model: riscv-virtio,qemu
DRAM:  128 MiB
Loading Environment from nowhere... OK
In:    uart@10000000
Out:   uart@10000000
Err:   uart@10000000
Net:   No ethernet found.
Hit any key to stop autoboot:  0

Device 0: unknown device
scanning bus for devices...

Device 0: unknown device
No ethernet found.
No ethernet found.
=> printenv
arch=riscv
baudrate=115200
board=qemu-riscv
board_name=qemu-riscv
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootriscv64.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_efi_bootmgr=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_pci_enum=pci enum
....

离线

楼主 #1 2021-06-06 09:43:36

riscv
会员
注册时间: 2021-06-06
已发帖子: 2
积分: 1

Re: qemu 虚拟机运行 u-boot / opensbi

1. 克隆opensbi源码:
git clone https://github.com/riscv/opensbi
git clone https://hub.fastgit.org/riscv/opensbi

2. 编译:
cd opensbi
CROSS_COMPILE=riscv64-linux-gnu- make PLATFORM=generic

3. qemu运行:

qemu-system-riscv64 -M virt -m 256M -nographic -bios build/platform/generic/firmware/fw_payload.bin

日志:

$ qemu-system-riscv64 -M virt -m 256M -nographic -bios build/platform/generic/firmware/fw_payload.bin

OpenSBI v0.9-64-gf30b189
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : mfdeleg
Platform HART Count       : 1
Platform IPI Device       : clint
Platform Timer Device     : clint
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform SysReset Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 112 KB
Runtime SBI Version       : 0.3

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008001ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000082200000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcsu
Boot HART Features        : scounteren,mcounteren,time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109

Test payload running

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn