Friday, 2 June 2017

[Week before GSoC 2017: RTEMS for HiFive1] Building toolchain, simulator and learning ISA

The purpose of this article is to show how to build RISCV simulator. 

First of all, we need to obtain and build GNU Toolchain. it consists mainly of a cross-compiler and a debugger. Also, it includes C libraries and DejaGNU testing framework.

$ git clone --recursive

After that, we should install packages' dependencies:

$ sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev

Now, it is time to configure our toolchain:

$ export RISCV=$(HOME)/bin/rv32imac/
$ cd riscv-gnu-toolchain
$ ./configure --prefix=$RISCV --with-arch=rv32imac --with-abi=ilp32

--prefix option here specifies the location where our toolchain will be installed;
--with-arch=rv32imac - specifies that we want to build a toolchain for architecture which supports: 32 - 32 bit ISA, i - base ISA, a - atomic extension, c - compressed extension.
--with-abi=ilp32 - stands for  soft-float ABI.


$ make -j4

We should add the tools to our PATH variable:

$ export PATH=$RISCV/bin:$PATH

Now we should install riscv Frontend Server:

$ git clone
$ cd riscv-fesvr
$ ../configure --prefix=$RISCV
$ make install

The next step is to install PK - proxy kernel, on top of which programs will run in SPIKE.

$ git clone
$ cd riscv-pk
$ mkdir build
$ cd build
$ ../configure --prefix=$RISCV --host=riscv32-unknown-elf
$ make
$ ../configure --prefix=$RISCV --host=riscv32-unknown-elf --enable-32bit
$ make install

And it is time to actually install SPIKE simulator:

$ git clone
$ cd riscv-isa-sim
$ apt-get install device-tree-compiler
$ mkdir build
$ cd build
$ ../configure --prefix=$RISCV --with-fesvr=$RISCV
$ make
$ [sudo] make install

Now we have a working SPIKE simulator and can run it:

$ spike pk test

No comments:

Post a Comment