How to set up an Eclipse and GNU gcc based toolchain to build and debug your Renesas RX based project on Linux (part 1)

Since I spent many evenings on this topic, in this article I will explain all the steps it took me to set up my complete Renesas RX GNU gcc based toolchain on Linux. The JTAG-Debugger I use is a SEGGER J-Link and the debug target is the Gadget Renesas GR-Sakura board which runs with a RX63N-Controller.

The installation process was tested on a fresh Ubuntu 13.10 installation and the complete installation procedure can be downloaded here as a single script.

I split this how-to into three parts:

First of all I have to thank DJ Delorie who had a really good tutorial on how to build a GNU gcc toolchain on his site which helped me a lot. All the credits for this part of my tutorial should go to him. I only added a few things so you can copy all the commands to your comand line and it should work right out of the box.

The first step is to create a directory where you want to put all the sources necessary to build the toolchain. Set the variable SRCDIR to the directory where you want to store the source code and and PREFIX where you want the toolchain to be installed.

export SRCDIR=/usr/src/rx-elf-src
export PREFIX=/opt/rx-elf
mkdir $SRCDIR

Install all the required dependencies for the installation on a fresh UBuntu 13.10 installation.

apt-get -q -y install libgmp-dev libmpfr-dev libmpc-dev texinfo libncurses-dev openjdk-7-jre

After that, you have to download all the source tarballs for gcc, binutils, gdb and newlib.

cd /tmp
wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.6.4/gcc-4.6.4.tar.bz2
wget ftp://sourceware.org/pub/binutils/snapshots/binutils-2.23.52.tar.bz2
wget ftp://ftp.gnu.org/gnu/gdb/gdb-7.6.tar.bz2
wget ftp://sourceware.org/pub/newlib/newlib-2.0.0.tar.gz

For me the above downloaded versions worked. The binutils version is only a snapshot and not a real release, but the latest major release binutils-2.23.2 found on the gnu.org ftp-server did not build without errors.

Now you can extract the sources and start building the toolchain. As mentioned in the gcc build documentation, the tools should not be built inside the source directories, but in seperate ones.

First start building the binutils:

cd $SRCDIR
tar xvjf /tmp/binutils-2.23.52.tar.bz2
mkdir rx-binutils
cd $SRCDIR/rx-binutils
../binutils-2.23.52/configure --prefix=$PREFIX --target=rx-elf
make
make install

After that, you can compile gcc as far as it succeeds without newlib. The switch –disable-libssp is set because I got a build error while compiling libssp. For me the toolchain works without it.

cd $SRCDIR
tar xvjf /tmp/gcc-4.6.4.tar.bz2
mkdir rx-gcc
cd $SRCDIR/rx-gcc
../gcc-4.6.4/configure --prefix=$PREFIX --target=rx-elf --enable-languages=c --with-newlib --disable-libssp
make -k
make -k install

Now newlib can be built with the new rx-elf-gcc. You have to make sure to put $PREFIX/bin into our search path before running the build:

cd $SRCDIR
tar xvf /tmp/newlib-2.0.0.tar.gz
mkdir rx-newlib
cd $SRCDIR/rx-newlib
../newlib-2.0.0/configure --prefix=$PREFIX --target=rx-elf --enable-languages=c --with-newlib
ln -s $PREFIX/bin/rx-elf-gcc $PREFIX/bin/rx-elf-cc
export PATH=$PREFIX/bin/:$PATH
make
make install

After newlib is built, the rest of gcc can be built:

cd $SRCDIR/rx-gcc
make
make install

Finally you can build gdb:

cd $SRCDIR
tar xvjf /tmp/gdb-7.6.tar.bz2
mkdir rx-gdb
cd $SRCDIR/rx-gdb
../gdb-7.6/configure --prefix=$PREFIX --target=rx-elf
make
make install

After that, all the tools to compile your RX project are available, you can verify that your gcc is working with Andrew Karpow’s GR-Sakura template. Download all the files contained in his git repository, cd into the directory containing the downloaded files, make sure the directory where all your toolchain binaries are installed ($PREFIX/bin) is in your search path PATH variable and type “make” in the command-line. The template should compile without errors.

Continue with Part 2.