Running RISCV linux on QEMU with machine model Sifive_u

I want to run riscv64 linux on top of qemu with the machine model sifive_u.
I had a preinstalled server ubuntu-23.04.img, prebuilt u-boot image and qemu version 8.0.0.
And in the qemu website itself they mentioned there is no PCI -bus support or virtio-bus support for sifive_u board.

when I ran this bash script with the following qemu commands,

-machine sifive_u
-m 8192 -smp 5
-kernel $U_BOOT
-drive file=./ubuntu-23.04.img,format=raw,if=none

It’s not booting the ubuntu image. Upto the following message is booting
OpenSBI v1.2

/ __ \ / | _ _ |
| | | |
__ ___ _ __ | (
| |
) || |
| | | | '_ \ / _ \ '_ \ ___ | _ < | |
| || | |) | __/ | | |) | |) || |
/| ./ _|| ||/|____/|
| |

Platform Name : SiFive HiFive Unleashed A00
Platform Features : medeleg
Platform HART Count : 5
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000000Hz
Platform Console Device : sifive_uart
Platform HSM Device : —
Platform PMU Device : —
Platform Reboot Device : gpio-restart
Platform Shutdown Device : —
Firmware Base : 0x80000000
Firmware Size : 244 KB
Runtime SBI Version : 1.0

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

Boot HART ID : 3
Boot HART Domain : root
Boot HART Priv Version : v1.10
Boot HART Base ISA : rv64imafdc
Boot HART ISA Extensions : none
Boot HART PMP Count : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count : 0
Boot HART MIDELEG : 0x0000000000000222
Boot HART MEDELEG : 0x000000000000b109

U-Boot 2023.07-rc2 (May 16 2023 - 12:25:28 +0530)

CPU: rv64imafdc_zicsr_zifencei
Model: SiFive HiFive Unleashed A00
Core: 17 devices, 9 uclasses, devicetree: board
Loading Environment from nowhere… OK
In: serial@10010000
Out: serial@10010000
Err: serial@10010000
Net: No ethernet found.
Working FDT set to ff72f430
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.

Please guide me on this on how to make it for sifive_u machine model. Any other method also fine.

Hi Swedha,
Can you confirm your steps for building the Uboot image?

If you are using a prebuilt U-Boot image, you can start QEMU with the following command instead:

qemu-system-riscv64 -machine sifive_u -nographic -m 8192 -smp 5 -kernel <u-boot_image> -drive file=<rootfs_image>,format=raw,if=none

Replace <u-boot_image> with the path to the prebuilt U-Boot image, and replace <rootfs_image> with the path to the root filesystem image you created in step 3.

Also, please note that the sifive_u QEMU model does not support PCI or VirtIO buses. Therefore, you will need to use a root filesystem image that does not rely on these devices.

Some troubleshooting ideas:

  • Make sure that you are using a Linux kernel image that has been built for RISC-V64.
  • Make sure that you are using a root filesystem image that does not rely on PCI or VirtIO devices.

Let me know if this helps or if you face the similar/new issues.


Thanks for the immediate reply Shree.

Is there any particular steps we need to follow for creating rootfs image for sifive_u machine model that does not rely on those devices? If possible, please share any resource to do that.
Because , I have tried creating rootfs image using busybox. This is the command I used,

qemu-system-riscv64 -M sifive_u -smp 5 -m 2G -display none -serial stdio
-kernel ./riscv/linux/arch/riscv/boot/Image -initrd ./riscv/lin/obj/initramfs.igz -append “root=/dev/ram init=./riscv/lin/initramfs/riscv-busybox/init”

But get the following kernel panic error.
[ 26.178623] Starting init: /bin/sh exists but couldn’t execute it (error -8)
[ 26.185183] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[ 26.189685] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.5.0-rc5 #1
[ 26.194997] Hardware name: SiFive HiFive Unleashed A00 (DT)
[ 26.200905] Call Trace:
[ 26.202722] dump_backtrace+0x1c/0x24
[ 26.208314] show_stack+0x2c/0x38
[ 26.209065] dump_stack_lvl+0x3c/0x54
[ 26.209632] dump_stack+0x14/0x1c
[ 26.210242] panic+0x102/0x29e
[ 26.210815] _cpu_down+0x0/0x494
[ 26.211451] ret_from_fork+0xa/0x1c
[ 26.213224] SMP: stopping secondary CPUs
[ 26.222646] —[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]—

Will you please help us on this. The linux kernel version-v6.5.0-rc5 and qemu-v8.0.0 we are using.

Hi Shree,
Will you please reply on the above query?


Hi Swedha,
Te error message suggests that /bin/sh exists but couldn’t be executed. This might be due to the incorrect path or permission issues.

Some troubleshooting steps:

  • Check the init binary’s path and permissions in rootfs.
  • Correct typographical errors in -append option: use straight quotes (").
    -append “root=/dev/ram init=./riscv/lin/initramfs/riscv-busybox/init”
  • Validate the contents of initramfs.igz for required binaries.
  • Ensure kernel compatibility with SiFive U in QEMU.

Let me know if this helps.