WARNING: THIS IS STILL SKETCH
This post is about how to prepare toolchain and install ORPSoCv2 on Altera Terasic de2-115 board.
This article is based on OpenRISC tutorial from Kevin Mehalli and OpenRISC Tutorial – Linux on DE0-Nano. Part I
Preparation
To start working building You will need to have already installed Linux distribution on Your workstation. Depending on distribution You will need to install building tools.
Preparing workspace
To create clean workspace I recommend to create seperate directory in our home directory and make all changes there.
To create directory and go inside
~$ mkdir openrisc; cd openrisc
From now any sources and tools will be placed here.
Installing toolchain
We will need sources of gcc and set of openrisc tools. This can be downloaded from git repositories placed on github.com
~/openrisc $ git clone git://github.com/openrisc/or1k-src.git
~/openrisc $ git clone git://github.com/openrisc/or1k-gcc.git
According to second sources for this article I prefer also to create set of seperated directories for build artifacts of our sources to make our workspace easier do clean.
We will need co create directories build_gcc for temporary files of gcc compilation and build_src for temporary files from tools and toolchain directory for ready to work tools.
~/openrisc $ mkdir build_gcc; mkdir build_src; mkdir toolchain;
Now we should append path to our new created tools in enviroment variable PATH I prefer to create file .openriscrc in our home directory and put there all envirtoment variables To create this:
~/openrisc $ echo 'export PATH=$PATH:$HOME/openrisc/toolchain/bin' > ~/.openriscrc
From now every time when You want to work with openrisc tools You will need to type:
$ source ~/.openriscrc
With this approach You don’t create mess in Your main enviroment in Your shell.
If You want to set this enviroment each time You can add this file to Your .profile configuration.
$ echo "source ~/.openriscrc" >> ~/.profile
Building toolchain
First we will need to compile set of basic tools
~/openrisc $ cd $HOME/openrisc/build_src;
../or1k-src/configure --target=or1k-elf \
--prefix=$HOME/openrisc/toolchain --enable-shared \
--disable-itcl --disable-tk --disable-tcl \
--disable-winsup --disable-gdbtk \
--disable-libgui --disable-rda --disable-sid \
--disable-sim --disable-gdb --with-sysroot \
--disable-newlib --disable-libgloss \
--disable-werror;
make;make install
Now we will build bootstrap gcc, which will make us able to compile the rest of tools (those that requires C librares)
~/openrisc $ cd $HOME/openrisc/build_gcc;
../or1k-gcc/configure --target=or1k-elf \
--prefix=$HOME/openrisc/toolchain --enable-languages=c \
--disable-shared --disable-libssp;
make;make install
If gcc built successfully then You should be able from now to check version of it:
~/openrisc $ or1k-elf-gcc --version
Now We can build utilities again but now with the rest of tools:
~/openrisc $ cd $HOME/openrisc/;
rm -rf build_src; mkdir build_src; cd build_src;
../or1k-src/configure --target=or1k-elf \
--prefix=$HOME/openrisc/toolchain --enable-shared \
--disable-itcl --disable-tk --disable-tcl \
--disable-winsup --disable-gdbtk --disable-libgui \
--disable-rda --disable-sid --enable-sim \
--disable-or1ksim --enable-gdb --with-sysroot \
--enable-newlib --enable-libgloss;
make; make install;
Building simulator (optionally)
Go to the openrisc workspace
~ $ cd $HOME/openrisc
Download the sources:
~/openrisc $ git clone --branch or1k-master git://github.com/openrisc/or1ksim.git
Build simulator
~/openrisc $ mkdir build_sim; cd build_sim; ../or1ksim/configure --target=or1k-elf --prefix=$HOME/openrisc/simulator
make all
make install
Append path to simulator
echo 'export PATH=$PATH:$HOME/openrisc/simulator/bin' >> ~/.openriscrc
Running on Hardware
Preparing hardware
All You need is de2-115 board with all equipment in box(power supply,usb cable) and rs232 cable or rs232 to usb cable. In my case I used cheap usb-rs232 serial cable based on ch340 chip.
- Connect power supply to Your board
- plug usb cable to first from left corner usb port in de2 board and connect to workstation.
- connect rs232 cable with Your workstation
- Make sure that You have set board on run
- turn on device
Preparing Software
In this part You will need to have already installed Altera Quartus software to synthesize Verilog to bitfile for FPGA.
Append quartus path to enviroment variable
$ echo 'export ALTERA_PATH=/opt/altera' >> ~/.openriscrc
Download orpsoc repository
~/openrisc $ git clone git://openrisc.net/stefan/orpsoc
In diffrence to de0 nano board we don’t need to setup any uart files. There is arleady set uart on board de2 115.
Now You need to go to this directory:
~/openrisc $ cd orpsoc/boards/altera/de2_115/syn/quartus/run
To program via usb blaster You need to type:
make pgm
If You didn’t receive any errors then Congratulation! You have ready board with openRISC!
Now lets do something with this SoC!
We will need OpenOCD
~/openrisc $ git clone https://github.com/openrisc/openOCD
cd openOCD/
mkdir build; cd build
../configure --enable-usb_blaster_libftdi --enable-adv_debug_sys --enable-altera_vjtag --enable-maintainer-mode
make
cd ..
./build/src/openocd -f altera-dev.tcl
Running software on hardware
For start You can use examples that I prepared
~/openrisc $ git clone https://github.com/matbaj/openrisc-examples
cd openrisc-examples/hello
make run
This will compile hello program and load to openrisc. Everything should be already setup. All You need is type command c to continue