This guide provides a step-by-step process for setting up a RISC-V development environment, including the GNU toolchain, QEMU, and Ubuntu 22.04.5 LTS for RISC-V.
- Prerequisites
- Installing Dependencies
- Setting up RISC-V GNU Toolchain
- Setting up QEMU for RISC-V
- Installing Ubuntu 22.04.5 LTS for RISC-V
- Running the Installed Ubuntu Image
- References
Ensure you have at least 25GB of free disk space and 8GB of RAM for smooth operation.
sudo apt update
sudo apt install git build-essential autoconf automake autotools-dev curl python3 libmpc-dev \
libmpfr-dev libgmp-dev gawk bison flex texinfo gperf libtool patchutils bc zlib1g-dev \
libexpat-dev ninja-build cmake libglib2.0-dev libpixman-1-devgit clone --recursive https://github.com/riscv/riscv-gnu-toolchaincd riscv-gnu-toolchain
./configure --prefix=$HOME/riscv/toolchain --enable-multilib
make linux -j$(nproc)echo 'export PATH=$PATH:$HOME/riscv/toolchain/bin' >> ~/.bashrc
source ~/.bashrcgit clone https://github.com/qemu/qemu.git
cd qemu./configure --target-list=riscv64-softmmu,riscv64-linux-user,riscv32-softmmu,riscv32-linux-user
make -j$(nproc)
sudo make installqemu-system-riscv64 --version # Should show v8.2 or newer- Download the Ubuntu 22.04.5 LTS (Jammy Jellyfish) image:
wget <Ubuntu-22.04.5-riscv64-image-URL>
- Unpack the disk image:
gzip -d ubuntu-22.04.5-live-server-riscv64.img.gz
- Create a Disk Image for Ubuntu Installation (16 GiB should be sufficient):
fallocate -l 16G disk
- Start the Installer:
qemu-system-riscv64 -machine virt -m 4G -smp cpus=2 -nographic \ -kernel /usr/lib/u-boot/qemu-riscv64_smode/u-boot.bin \ -netdev user,id=net0 \ -device virtio-net-device,netdev=net0 \ -drive file=ubuntu-22.04.5-live-server-riscv64.img,format=raw,if=virtio \ -drive file=disk,format=raw,if=virtio \ -device virtio-rng-pci
- Follow the standard Ubuntu Server installation tutorial
qemu-system-riscv64 -machine virt -m 4G -smp cpus=2 -nographic \
-kernel /usr/lib/u-boot/qemu-riscv64_smode/u-boot.bin \
-netdev user,id=net0 \
-device virtio-net-device,netdev=net0 \
-drive file=disk,format=raw,if=virtio \
-device virtio-rng-pciPull requests are welcome! If you encounter any issues, please open an issue in this repository.
🚀 Happy Coding with RISC-V!