- 參考鏈接
使用Qemu和systemd-nspawn搭建RISC-V輕量級用戶模式開發環境 - 知乎
- 安裝Qemu
sudo apt updatesudo apt -y install qemu-user-binfmt qemu-user-static systemd-container
sudo apt -y install zstd
- 配置環境
RISCV_FILE=archriscv-2023-10-09.tar.zstwget -c http://mirrors.wsyu.edu.cn/archriscv/images/${RISCV_FILE}
mkdir archriscv
sudo tar -I zstd -xvf ${RISCV_FILE} -C archriscv
- 啟動虛擬機
sudo systemd-nspawn -D ${HOME}/archriscv/ --machine archriscv
- 測試
# pacman -Syyu# uname -m
riscv64
- 安裝gcc
pacman -Syyu g++
pacman -S vi jdk11-openjdk
- 代碼
#include <stdio.h>int main(int argc, char *argv[])
{printf("Hello RISC-V!\n");return 0;
}
- 測試
# gcc hello.c -o hello# file hello
hello: ELF 64-bit LSB pie executable, UCB RISC-V, RVC, double-float ABI, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-riscv64-lp64d.so.1, BuildID[sha1]=ca19bb1cab6f06c75002e1a6e0cde25c12432355, for GNU/Linux 4.15.0, not stripped# ./hello
Hello RISC-V!