Skip to content

Setup Arch Linux RISC V using qemu system

Levi Zim edited this page Mar 7, 2023 · 3 revisions

CAUTION

We (distro packagers) decided to modify GCC spec to get rid of just way too many atomic symbol missing error. AFAIK debian does the same thing in the same way.

So, you may notice that some program compiles without -latomic flag, but that's not the case if you switch to some other distros. I wrote another blog post explaining this in detail.

In short: For GCC you should add -latomic if you use std::atomic<T> where sizeof(T) is lower than 4. Also apply to those __atomic_compare_exchange_2() stuff. Clang is not affected.

Method

This approach requires you to be on an non-RISC-V Arch Linux (x86_64 or aarch64, etc.) machine, because we use pacstrap and pacman.

# pacman -Syu then reboot is recommended before this
sudo pacman -S arch-install-scripts git qemu-img qemu-system-riscv riscv64-linux-gnu-gcc devtools-riscv64
git clone https://github.com/CoelacanthusHex/archriscv-scriptlet.git
cd archriscv-scriptlet
./mkrootfs
./mkimg
./startqemu.sh

If, in the last step, you find yourself stucked at [ OK ] Reached target Graphical Interface for over 5 minutes, just press Ctrl-C and re-run startqemu.sh.

After booting the machine, you may need to install necessary packages:

sudo pacman -S git vim gcc

Detailed Explanation

TBD

Clone this wiki locally