This is the recommended method.
1. Install RISC-V Toolchain
First, we need to install the following dependencies.
Copy sudo apt install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev
Clone the RISC-V GNU Toolchain repo.
Copy cd ~/Downloads/
git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git
cd ~/Downloads/riscv-gnu-toolchain/
Run configuration. The prefix is where we want to install the toolchain. Here, we will be installing under the riscv64-unknown-toolchain
directory.
We can specify which architecture we want to build into the toolchain with the --with-multilib-generator=
flag. We add support for the most common ones here.
Copy ./configure --prefix=/home/tk/Documents/RISCV/riscv64-unknown-toolchain/ --with-multilib-generator="rv32i-ilp32--;rv32im-ilp32--;rv32iac-ilp32--;rv32imac-ilp32--;rv32imafc-ilp32f--;rv64imac-lp64--;rv64imafdc-lp64d--"
Build the toolchain
To check which architecture the toolchain supports, run the following command
Copy riscv64-unknown-elf-gcc --print-multi-lib
Copy $ riscv64-unknown-elf-gcc --print-multi-lib
. ;
rv32i/ilp32 ; @march =rv32i@mabi=ilp32
rv32im/ilp32 ; @march =rv32im@mabi=ilp32
rv32iac/ilp32 ; @march =rv32iac@mabi=ilp32
rv32imac/ilp32 ; @march =rv32imac@mabi=ilp32
rv32imafc/ilp32f ; @march =rv32imafc@mabi=ilp32f
rv64imac/lp64 ; @march =rv64imac@mabi=lp64
rv64imafdc/lp64d ; @march =rv64imafdc@mabi=lp64d
Finally, add the RISCV toolchain to PATH in ~/.bashrc
Copy ...
# RISCV
export RISCV = "/home/tk/Documents/RISCV/"
export PATH = "${RISCV}riscv64-unknown-toolchain/bin/:$PATH"
...
2. Install OpenOCD
First, we need to install the following dependencies.
Copy sudo apt install libtool pkg-config
sudo apt install libusb-1.0-0-dev
sudo apt install libftdi-dev
Clone the RISC-V OpenOCD repo
Copy cd ~/Documents/RISCV/
git clone https://github.com/riscv/riscv-openocd.git
cd ~/Documents/RISCV/riscv-openocd/
Run the following command to generate the necessary configuration and build files for OpenOCD.
Configure the build process according to the current system and settings by running the following command.
Finally, compile and install the software
Copy make
sudo make install
Also add OpenOCD to PATH
Copy ...
# RISCV
export RISCV = "/home/tk/Documents/RISCV/"
export PATH = "${RISCV}riscv64-unknown-toolchain/bin/:$PATH"
export PATH = "${RISCV}riscv-openocd/:$PATH"
...
Common Error
libtool: Version mismatch error when building openocd
Last updated 4 months ago