Building the RL78 Toolchain under Ubuntu 14.04
Steps for building the RL78 Toolchain under Ubuntu 14.04:
- Run the followings commands before you start:
sudo apt-get install build-essential sudo apt-get update sudo apt-get upgrade sudo apt-get install flex bison texinfo libncurses5-dev
1) Create a new folder for the toolchain
$ mkdir RL78-Toolchain
2) Change the current directory to RL78-Toolchain
$ cd RL78-Toolchain
3) Create 3 new folders : source, build, prefix
$ mkdir source $ mkdir build $ mkdir prefix
4) Download the source codes for Binutils-RL78_V15.02, Newlib-RL78_V15.02, GCC-RL78_V15.02, GDB-RL78_V15.01 from :
-GDB: https://gcc-renesas.com/downloads/d.php?f=rl78/gdb/15.01/gdb-7.8.2_rl78_v15.01.tar.bz2
-GCC: https://gcc-renesas.com/downloads/d.php?f=rl78/gcc/15.02/gcc-4.9.2-20150423_rl78_v15.02.tar.bz2
5) Copy the archive in the source folder that you previously created:
$ cp /home/<username>/Downloads/gdb-7.8.2_rl78_v15.01.tar.bz2 source $ cp /home/<username>/Downloads/binutils-2.24-20150423_rl78_v15.02.tar.bz2 source $ cp /home/<username>/Downloads/newlib-2.1.0-20150423_rl78_v15.02.tar.bz2 source $ cp /home/<username>/Downloads/gcc-4.9.2-20150423_rl78_v15.02.tar.bz2 source
- Assuming that Downloads is you default download folder.If not you have to put the path to the location where the files were downloaded.
6) Change the current directory and extract the archives:
$ cd source $ tar -jxvf gdb-7.8.2_rl78_v15.01.tar.bz2 $ tar -jxvf binutils-2.24-20150423_rl78_v15.02.tar.bz2 $ tar -jxvf newlib-2.1.0-20150423_rl78_v15.02.tar.bz2 $ tar -jxvf gcc-4.9.2-20150423_rl78_v15.02.tar.bz2
7) INSTALL GDB-RL78_V15.01
a) Change the current directory to build and create a new folder for gdb:
$ cd ../build $ mkdir gdb
b) Change the current directory to the gdb folder that you previously created:
$ cd gdb
c) Build and make:
$ /home/<username>/RL78-Toolchain/source/gdb-7.8.2/configure --target=rl78-elf --prefix=/home/<username>/RL78-Toolchain/prefix/ $ make $ make install
d) Return to the build directory
$ cd ..
8) INSTALL BINUTILS-RL78_V15.02
a) Create a new folder for binutils and change the current directory to it:
$ mkdir binutils $ cd binutils
b) Build and make:
$ /home/<username>/RL78-Toolchain/source/binutils-2.24-20150423/configure --target=rl78-elf --prefix=/home/<username>/RL78-Toolchain/prefix/ --enable-maintainer-mode --disable-nls --disable-werror $ make $ make install
c) Return to the build directory
$ cd ..
d) Export path
$ export PATH="/home/<username>/RL78-Toolchain/prefix/bin:$PATH"
9) INSTALL GCC-RL78-V15.02
a) Change the current directory to GCC source folder and run the following command :
$ cd ../source/gcc-4.9.2-20150423 $ ./contrib/download_prerequisites
OBS: if for some reason MPC,MPFR and GMP is not downloaded automatically when running the command ./contrib/download_prerequisites you have to download them manually and move the packages into GCC source folder.To do that follow the steps:
- Download the source code for GMP,MPFR,MPC:
https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2
ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.2.tar.gz
http://www.mpfr.org/mpfr-current/mpfr-3.1.4.tar.bz2
- Copy the packages into GCC source folder
$ cp ~/Downloads/gmp-6.1.0.tar.bz2 . $ cp ~/Downloads/mpfr-3.1.4.tar.bz2 . $ cp ~/Downloads/mpc-1.0.2.tar.gz .
- Extract the packages :
$ tar -jxvf gmp-6.1.0.tar.bz2 $ tar -jxvf mpfr-3.1.4.tar.bz2 $ tar -zxvf mpc-1.0.2.tar.gz
- Rename GMP,MPFR,MPC folders
$ mv gmp-6.1.0 gmp $ mv mpfr-3.1.4 mpfr $ mv mpc-1.0.2 mpc
b) Return to the build directory:
$ cd ../../build
c) Create a new folder for gcc and change the current directory to it:
$ mkdir gcc $ cd gcc
d) Build and make:
$ /home/<username>/RL78-Toolchain/source/gcc-4.9.2-20150423/configure --target=rl78-elf --prefix=/home/<username>/RL78-Toolchain/prefix/ --enable-languages=c,c++ --disable-shared --with-newlib --enable-lto --disable-werror $ make all-gcc $ make install-gcc
e) Return to the build directory
$ cd ..
f) Export path
$ export PATH="/home/<username>/RL78-Toolchain/prefix/bin:$PATH"
10) INSTALL Newlib-RL78_V15.02
OBS: Build Newlib only after you built Binutils and GCC.
a) Create a new folder for newlib and change the current directory to it:
$ mkdir newlib $ cd newlib
b) Build and make :
$ /home/<username>/RL78-Toolchain/source/newlib-2.1.0-20150423/configure --target=rl78-elf --prefix=/home/<username>/RL78-Toolchain/prefix/ $ make $ make install
c) Return to the build directory
$ cd ..
11) Build final GCC
a) Change the current directory to gcc:
$ cd gcc
b) Build :
$ sudo make $ sudo make install
OBSERVATIONS:
- /home/<username>/gcc/gcc-4.9.2 is the path to your gcc folder;
- if you save your gcc folder(the one in which you copy the archive) in another location than the default one your path will change;
- the configure command must end with gcc-version/configure;
- /home/<username>/newlib/newlib-2.1.0 is the path to your newlib folder;
- if you save your newlib folder(the one in which you copy the archive) in another location than the default one your path will change;
- the configure command must end with newlib-version/configure;
- /home/<username>/binutils/binutils-2.24-20150423 is the path to your configure file. binutils-2.24-20150423 is the folder that was created after extracting the package, and if your folder has a different name your path will become: /home/<username>/binutils/folderName;
- if you save your binutils folder(the one in which you copy the archive) in another location than the default one your path will change;
- /home/<username>/rl78/gdb-7.8.2 is the path to your rl78 folder;
- if you save your rl78 folder(the one in which you copy the archive) in another location than the default one your path will change;
- the configure command must end with rl78-version/configure.
- If one of this errors occurs :
1./usr/local/bin/ld - this linker was not configured to use sysroots collect2: error: ld returned 1 exit status 2.configure: error: '/home/<username>/gdb/build' : configure: error: C compiler cannot create executables
You will have to remove ld file from /usr/local/bin following the steps:
1. $ cd /usr/local/bin 2. $ rm -f ld 3. $ cd /home/<username>/RL78-Toolchain/build