1. riscv-gun-toolchain
1.1 Getting the sources
git clone https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain
git submodule update --init --recursive
1.2 Install Ubuntu dependency packages
sudo apt install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
1.3 Install Newlib or Linux
To build the Newlib cross-compiler, pick an install path. If you choose, say, /opt/riscv, then add /opt/riscv/bin to your PATH now. Then, simply run the following command:
./configure --prefix=/opt/riscv
sudo make -j$(nproc) # newlib
sudo make linux -j$(nproc) # linux
2. riscv-tools
1.1 Getting the sources
git clone https://github.com/riscv/riscv-tools.git
cd riscv-tools
git submodule update --init --recursive
1.2 Install Ubuntu dependency packages
sudo apt install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev
1.3 Compiler
export RISCV=/path/to/install/riscv/toolchain
./build.sh
3.riscv-isa-sim
3.1 Build
We assume that the RISCV environment variable is set to the RISC-V tools install path.
cd riscv-isa-sim
apt install device-tree-compiler
mkdir build
cd build
../configure --prefix=$RISCV
make
[sudo] make install
3.2 Compiling and Running
riscv64-unknown-elf-gcc -o hello hello.c
spike pk hello
4.riscv-tests
4.1 Build
We assume that the RISCV environment variable is set to the RISC-V tools install path, and that the riscv-gnu-toolchain package is installed.
cd riscv-tests
git submodule update --init --recursive
autoconf
./configure --prefix=$RISCV/target
make
sudo make install
4.2 Runing benchmark
cd benchmarks
spike dhrystone.riscv