User Tools

Site Tools


This is an old revision of the document!


For testing your kernel builds it's much easier to use QEMU than normal hardware, especially if you are working on arch-specific code. QEMU has upstream support for RISC-V since version 2.12 so you may use the upstream binaries from your distribution or build your own either from the official qemu repo or from the riscv-qemu repo.

Build QEMU from riscv-qemu

The process is the same no matter where you got your QEMU sources from, it's pretty standard…

git clone --depth=1
cd riscv-qemu
./configure --target-list=riscv64-softmmu,riscv32-softmmu --prefix=<qemu install dir>

Running Linux on QEMU

There are various ways of invoking qemu, lets start with a standard virt machine that boots the test environment.

<qemu install dir>/bin/qemu-system-riscv64 -nographic -machine virt -smp 8 -m 2G \
				-bios <path to bbl or fw_jump.elf (in case of OpenSBI)> \
				-kernel <linux sources dir>/vmlinux \
				-initrd <path to initramfs.img> \
				-netdev user,id=unet -device virtio-net-device,netdev=unet -net user \
				-object rng-random,filename=/dev/urandom,id=rng0 \
				-device virtio-rng-device,rng=rng0

In case you built bbl or OpenSBI with the Linux kernel as its payload you can omit the -bios parameter and point the -kernel parameter directly to the combined bbl / fw_payload.elf binary.

developers/env_emul.1554923250.txt.gz · Last modified: 2019/04/10 22:07 by mick