You need to be on Linux with qemu-static and binfmt-misc installed. On Ubuntu, install the qemu-user-static package, and everything should be setup automatically. To setup a custom build of qemu, use to run docker run --privileged --rm -e QEMU_BINARY_PATH=/path/to/qemu/bin tonistiigi/binfmt --install riscv64  (the use of docker here is only a mean of packaging and it works regardless of the use of docker).

The idea is you make a docker environment using native RISC-V binaries that are auto-run in qemu-user mode. This presents an environment in which RISC-V is the native architecture. It has its own root filesystem, but one can use -v flag to mount the current working directory to /workspace.

Essentially it looks like a real native Ubuntu RISC-V environment with the caveat that ptrace() doesn't work.  Much faster than full system emulation as well.

docker network create sdknet  # only one time
docker run -it --volume=$(readlink -f .):/workspace --network=sdknet --platform=riscv64 riscv64/ubuntu
  • No labels