
On Tue, Apr 11, 2023 at 01:14:27PM +0200, Gerd Hoffmann wrote:
The second approach is the one described in the Ubuntu wiki[3], and also requires passing two files to QEMU, except this time they come from the opensbi and u-boot-qemu packages respectively. The usage looks like
-bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf
I think in this case the first file is a minimal build of OpenSBI that likely just initializes enough hardware before handing control to an arbitrary payload - in this case, u-boot.
Yes. These days opensbi seems to be loaded by default, so the first line is not needed. In fact I'm running a guest here, on fedora 37 + virt-preview with just this ...
<os> <type arch='riscv64' machine='virt'>hvm</type> <kernel>/home/kraxel/projects/u-boot/build-qemu-riscv64-smode/u-boot.bin</kernel> <boot dev='hd'/> </os>
... and it works fine.
This matches my experience. I've tried both u-boot.bin (referenced in openSUSE and FreeBSD documentation) and uboot.elf (Debian and Ubuntu documentation) and it doesn't seem to make a difference which one you choose.
There is also this variant ...
<qemu:commandline> <qemu:arg value='-drive'/> <qemu:arg value='if=pflash,index=1,format=raw,file=/vmdisk/hdd/pool-risc-v/RISCV_VIRT.raw'/> </qemu:commandline>
... to boot edk2 firmware. Note this is a single image carrying both code and vars. Also note 'index=1', which I think is needed because the (default) opensbi is loaded to the pflash device with 'index=0'.
This doesn't boot the distro due to grub2 not having full riscv64 efi support (yet).
The openSUSE images are using grub2, and possibly EFI somehow? Right after selecting the entry I see EFI stub: Booting Linux Kernel... EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path EFI stub: Using DTB from configuration table EFI stub: Exiting boot services... The image never manages to boot all the way for me: it looks like it can't find the root filesystem. But eventually I get dropped into a rescue shell, and /sys/firmware/efi/ contains some data. Note that I'm not using edk2 in this case, just the same u-boot.bin file that I've used to boot other images. -- Andrea Bolognani / Red Hat / Virtualization