riscvarchive / risc-v-getting-started-guide

The official RISC-V getting started guide
https://risc-v-getting-started-guide.readthedocs.io/en/latest/
Creative Commons Attribution 4.0 International
198 stars 56 forks source link

qemu emulation problems #41

Open IvanVnucec opened 3 years ago

IvanVnucec commented 3 years ago

I'm following the tutorial and had stumbled on this error

qemu-system-riscv64: -drive file=busybox,format=raw,id=hd0: A regular file was expected by the 'file' driver, but something else was given

when running QEMU as:

sudo qemu-system-riscv64 -nographic -machine virt \
     -kernel linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" \
     -drive file=busybox,format=raw,id=hd0 \
     -device virtio-blk-device,drive=hd0

Next I've modified the 'file' to be busybox/busybox because in busybox folder I have built busybox as stated in the tutorial. Then I get new warnings:

qemu-system-riscv64: warning: No -bios option specified. Not loading a firmware.
qemu-system-riscv64: warning: This default will change in a future QEMU release. Please use the -bios option to avoid breakages when this happens.
qemu-system-riscv64: warning: See QEMU's deprecation documentation for details.

And the QEMU just hangs.

I've also built the QEMU as stated in the guide.

QEMU version:

$ qemu-system-riscv64 --version
QEMU emulator version 5.0.0 (v5.0.0-dirty)
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers

Ubuntu version:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:    18.04
Codename:   bionic
louyshong commented 3 years ago

I think there are two issues here. Firstly, add -bios default when running QEMU and the warning should disappear. Then, a kernel panic saying Unable to mount root fs will probably pop up and you will have to prepare a root filesystem to resolve that. A good tutorial can be found here: https://ibug.io/blog/2019/04/os-lab-1/

dnlombard commented 2 years ago

As indicated above, the qemu execution line is incorrect and will not work as documented. The '-drive' option must specify a root filesystem image, which Busybox does not produce.

The page should be fixed, e.g., by adding steps to create a root filesystem. At the very least, the page should clearly indicate it's not valid and should not be used.