Installing & Building RISC-V Toolchain
RISC-V
A walkthrough of installing and building the RISC-V toolchain from scratch on Ubuntu 20 LTS.
This post walks you through how to install and build the RISC-V toolchain from scratch.
Prerequisites
- Install
giton your system:
sudo apt install git-all- A Linux machine (tested on Ubuntu 20 LTS).
- Sufficient storage — around 30 GB free.
- Install a few dependencies:
sudo apt-get install autoconf automake autotools-dev curl python3 \
libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison \
flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-devCreate a directory and clone
mkdir risc-v
cd risc-v
git clone https://github.com/riscv/riscv-gnu-toolchainCreate a directory in /opt
mkdir /opt/riscvConfigure and make
./configure --prefix=/opt/riscv
make linuxThis might take several hours depending on your machine configuration. The tool will be available in /opt/riscv/bin.
Add /opt/riscv/bin to PATH
Open ~/.bashrc:
sudo gedit ~/.bashrcAdd near the end of the file and save:
export PATH="$PATH:/opt/riscv/bin"Now the RISC-V tools will be available without specifying the path.