If you wanna use or1ksim, start from openrisc/tutorials first !!!
Github: https://github.com/openrisc/tutorials
In the tutorials, you can run some demos simply following the instructions.
./bootstrap-quick-start.sh
source environment.sh
However, the PATH is not permanently modified, so you should run source environment.sh
every time you start a new terminal.
Here, I just wanna mark the instructions in the tutorial to permanently configure/install or1ksim.
The project is initialized in directory /openrisc.
Before we start, gcc is required on your Linux: sudo apt install gcc
mkdir -p toolchains
wget https://github.com/openrisc/newlib/releases/download/v2.4.0/or1k-elf_gcc5.3.0_binutils2.26_newlib2.4.0_gdb7.11.tgz
tar -xzf or1k-elf_gcc5.3.0_binutils2.26_newlib2.4.0_gdb7.11.tgz -C toolchains
rm or1k-elf_gcc5.3.0_binutils2.26_newlib2.4.0_gdb7.11.tgz
Or you can download it manually: https://github.com/openrisc/newlib/releases
Configure & make & make install
git clone https://github.com/openrisc/or1ksim.git
cd or1ksim/
mkdir build
cd build
../configure --program-prefix=or1k-
make
sudo make install
Add (only) the PATH of toolchains to the environment
export PATH="/home/username/openrisc/toolchains/or1k-elf/bin:$PATH"
Download the or1ksim tools zip file, and unzip it into /tools.
wget https://github.com/openrisc/tutorials/releases/download/2016.1/or1ksim.tgz
mkdir -p tools
tar -xzf or1ksim.tgz -C tools
rm or1ksim.tgz
Configure & make & make install
git clone https://github.com/openrisc/or1ksim.git
cd or1ksim/
mkdir build
cd build
../configure --prefix=${PWD}/../../tools/or1ksim/ --program-prefix=or1k-
make
make install
Add the PATH of both or1ksim and toolchains to the environment
export PATH="/home/username/openrisc/tools/or1ksim/bin:$PATH"
export PATH="/home/username/openrisc/toolchains/or1k-elf/bin:$PATH"
Type in or1k
and double-tap Tab. If you are seeing these, the installation is successful.
I’m going to show a simple hello world demo here.
First, we have a hello.c file like this:
#include
int main(int argc, char* argv[]) {
printf("Hello World!\n");
return 0;
}
Then, we run the following or1k-elf-gcc
command to generate hello.elf file:
or1k-elf-gcc -g -o hello.elf -mboard=or1ksim-uart hello.c
Run hello world
or1k-sim -f or1ksim.cfg hello.elf
The or1ksim.cfg file can be found in the following link:
https://github.com/openrisc/tutorials/blob/master/or1ksim/or1ksim.cfg
Otherwise, or1ksim will use sim.cfg as default.
Also, or1ksim can be much more verbose and give you a full execution trace:
or1k-sim -f or1ksim.cfg hello.elf -t