/riscv64-in-qemu

Primary LanguageCOtherNOASSERTION

Run a RISC-V code in QEMU.

Bare metal RISC-V assembly in QEMU

Run a bare metal RISC-V code in QEMU without any OS or C. Based on the source code from here and here.

This code is compiled with the riscv-gnu-toolchain and can be run with the QEMU sifive_u and sifive_e machines. Both 32bit and 64bit targets are supported.

As of this writing, these are the latest versions of the software involved:

  • Qemu: v5.1.0
  • RISC-V GNU toolchain: 10.1.0

Make targets

make run-baremetal -- build payload file and boot it via QEMU.

Debugging with gdb

  1. make download-sifive-toolchain to download SiFive version of toolchain, as the regular apt-gettable toolchain won't work
  2. Run as usual with and extra DBG=1 argument, e.g. make run-baremetal DBG=1
  3. In a separate terminal, run make gdb

Make targets

  • make prereqs -- apt-get the prerequisites.
  • make qemu -- build Qemu for RISC-V.

RISC-V Quick References