How to Run Linux on RISC-V with QEMU Emulator

RISC-V open source architecture is starting to become more and more interesting thanks the growing RISC-V hardware & software ecosystem, and with the recent release of HiFive Unleashed, we even have a board capable of running Linux. The only problem: it costs $999.

But luckily, it’s possible to experiment with Linux on RISC-V without extra hardware, just using your current PC. Imperas offers a commercial solution working on both Windows and Linux that relies on busybear-linux RISC-V Linux root filesystem comprised of busybox and dropbear SSH server. The rootfs also works with QEMU, so I tried it in Ubuntu 16.04.

The instructions on Github are quite easy to follow. My computer is powered by an AMD FX8350 processor coupled with 16GB RAM, and the whole process took around 2 hours, so better use the fastest computer possible. It also requires around 26 GB of storage on your build machine.

First, let’s create a working directory, and retrieve the RISC-V toolchain:

Now we can now build the RISC-V newlib & Linux toolchains) after installing some dependencies:

We’ll also need to build qemu for RISC-V

The next three steps will build the rootfs, Linux 4.14 kernel, and the bootloader, but there are optional since you could just as well as download the binary releases.

  • Build busybear-linux

  • Build RISC-V Linux

  • Build BBL (Berkeley Boot Loader):

If we’re going to use the release files instead:

You’d normally want to setup Linux bridged networking, and I tried, but failed and ran out of time. I added the following lines to /etc/network/interfaces in my computer:

and create two scripts in the current directory

  • ifup

  • ifdown

But I did not get it to work in a reasonable time. Studying QEMU Networking page on Arch Linux in details should help. [Update: See comments’ section for SSH access using the Fedora RISC-V image instead]

Nevertheless I could still run Linux on RISC-V with QEMU using the following command:

The boot takes just over one second to our minimal rootfs. Here’s the boot log:

We can login with root using password “busybear” without quote.

Type halt to turn off Linux and QEMU:

Support CNX Software - Donate via PayPal or become a Patron on Patreon

Leave a Reply

6 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
5 Comment authors
cnxsoftSanderdavidltblu Recent comment authors
newest oldest most voted
Notify of

Thanks for the very useful article!


You are also welcome to use Fedora RISC-V stage 4 image with thousands of packages compiled natively and available via DNF. Find the latest disk images and instructions (special riscv-qemu package is available via Copr repository):

There is also a 2 part article on LWN. The first part was posted a couple of days ago and Fedora specific one should be posted next week.


“ucbvax” … is that a joke referring to University of California Berkeley VAX?


MTTCG works up to 8 cores (QEMU can utilize 8 cores/threads on your host machine) thus you can speed up compilations of your beloved packages (if missing).

If something is missing or not working properly you can report on IRC #fedora-riscv on FreeNode.


Many thanks for this useful tutorial!

I have faced a minor issue that the kernel can’t finish his boot process because of a problem in mounting the file system, I got the error message:
can’t open /dev/ttyS0: No such file or directory
The solution was to enable the following options in the configuration:
To enable these options:
make ARCH=riscv menuconfig
>Device Drivers > Generic Driver Options:
[*] Maintain a devtmpfs filesystem to mount at /dev
[*] Automount devtmpfs at /dev, after the kernel mounted the rootfs