Skip to content

sohamukute/RISC-V-Development-Environment-Setup-on-qemu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

RISC-V Development Environment Setup

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.


Table of Contents


Prerequisites

Ensure you have at least 25GB of free disk space and 8GB of RAM for smooth operation.

Installing Dependencies

For Debian/Ubuntu-based Systems

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-dev

Setting up RISC-V GNU Toolchain

Clone the RISC-V GNU Toolchain Repository

git clone --recursive https://github.com/riscv/riscv-gnu-toolchain

Configure and Build the Toolchain for Linux

cd riscv-gnu-toolchain
./configure --prefix=$HOME/riscv/toolchain --enable-multilib
make linux -j$(nproc)

Add the Toolchain to Your PATH

echo 'export PATH=$PATH:$HOME/riscv/toolchain/bin' >> ~/.bashrc
source ~/.bashrc

Setting up QEMU for RISC-V

Clone QEMU Source Code

git clone https://github.com/qemu/qemu.git
cd qemu

Configure and Build QEMU with RISC-V Support

./configure --target-list=riscv64-softmmu,riscv64-linux-user,riscv32-softmmu,riscv32-linux-user
make -j$(nproc)
sudo make install

Verify QEMU Installation

qemu-system-riscv64 --version  # Should show v8.2 or newer

Installing Ubuntu 22.04.5 LTS for RISC-V

Installation Steps

  1. Download the Ubuntu 22.04.5 LTS (Jammy Jellyfish) image:
    wget <Ubuntu-22.04.5-riscv64-image-URL>
  2. Unpack the disk image:
    gzip -d ubuntu-22.04.5-live-server-riscv64.img.gz
  3. Create a Disk Image for Ubuntu Installation (16 GiB should be sufficient):
    fallocate -l 16G disk
  4. 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
  5. Follow the standard Ubuntu Server installation tutorial

Running the Installed Ubuntu Image

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-pci

References


Contributing

Pull requests are welcome! If you encounter any issues, please open an issue in this repository.


🚀 Happy Coding with RISC-V!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published