# Running RISCV linux on QEMU with machine model Sifive\_u

**URL:** <https://forums.sifive.com/t/running-riscv-linux-on-qemu-with-machine-model-sifive-u/6296>\
**Category:** HiFive Unleashed\
**Created:** [September 25, 2023, 5:21am UTC](https://forums.sifive.com/t/running-riscv-linux-on-qemu-with-machine-model-sifive-u/6296 "2023-09-25T05:21:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swedha](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@Swedha](https://forums.sifive.com/u/Swedha)\
**Post date:** [September 25, 2023, 5:21am UTC](https://forums.sifive.com/t/running-riscv-linux-on-qemu-with-machine-model-sifive-u/6296/1 "2023-09-25T05:21:20Z")

</div>

Hi,  
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,  
U\_BOOT=./U-boot  
QEMU=/usr/local/bin/qemu-system-riscv64  
IMAGE=./ubuntu-23.04.img

$QEMU   
-machine sifive\_u   
-nographic   
-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  
DRAM: 8 GiB  
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.

---

<div class="post-metadata">

**Author:** ![Shree\_SiFive](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@Shree\_SiFive](https://forums.sifive.com/u/Shree_SiFive)\
**Post date:** [September 26, 2023, 9:34pm UTC](https://forums.sifive.com/t/running-riscv-linux-on-qemu-with-machine-model-sifive-u/6296/2 "2023-09-26T21:34:13Z")

</div>

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.

Regards,  
Shree

---

<div class="post-metadata">

**Author:** ![Swedha](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@Swedha](https://forums.sifive.com/u/Swedha)\
**Post date:** [September 28, 2023, 6:08am UTC](https://forums.sifive.com/t/running-riscv-linux-on-qemu-with-machine-model-sifive-u/6296/3 "2023-09-28T06:08:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Swedha](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@Swedha](https://forums.sifive.com/u/Swedha)\
**Post date:** [October 3, 2023, 3:47pm UTC](https://forums.sifive.com/t/running-riscv-linux-on-qemu-with-machine-model-sifive-u/6296/4 "2023-10-03T15:47:35Z")

</div>

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

Regards,  
Swedha

---

<div class="post-metadata">

**Author:** ![Shree\_SiFive](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@Shree\_SiFive](https://forums.sifive.com/u/Shree_SiFive)\
**Post date:** [October 12, 2023, 11:13pm UTC](https://forums.sifive.com/t/running-riscv-linux-on-qemu-with-machine-model-sifive-u/6296/5 "2023-10-12T23:13:13Z")

</div>

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.

Regards,  
Shree
