Building the RTEMS toolset on Debian

From Milkymist Wiki

Jump to: navigation, search

This How-To documents the steps I followed to install the RTEMS 4.11 (as of 6 February 2011) toolset on Debian Squeeze Stable.

In this case, the host was a almost fresh install of Debian; immediately after rebooting into Debian after installation,

Contents

[edit] Build essentials

This single command was enough to install the missing pieces

sudo apt-get install m4 patch  build-essential texinfo cvs \
    libncurses5-dev libgmp3-dev libmpfr-dev libmpc-dev

[edit] texinfo

Attempting to build binutils will fail without makeinfo installed - even though only a warning will be reported. So we install texinfo (which includes makeinfo) first.

 $ sudo aptitude install texinfo

[edit] Build RTEMS Tools

[edit] Assumptions

Assume a root directory rtems. Under that, create two directories: archive and tools. For this How-To, You MUST use the Lattice Mico32 as the target. For each tool below, the examples assume you start in the ~/rtems/tools directory.

Note: This section very nearly duplicates what is contained in the "Getting Started with RTEMS" document, with the aforementioned "sudo" invocations added.

[edit] Tools needed

You will need to download the tarballs of the RTEMS Build Toolset which includes the following:

  • Binutils - 2.21
  • GCC (gcc-core) - 4.5.2-RC-20101208
  • GCC (gcc-g++) - 4.5.2-RC-20101208
  • GDB - 7.2
  • Newlib - 1.19
  • GMP (Multi-precision arithmetic library) - 4.3.2
  • MPC (Multi-precision complex floating-point library) - 0.8.1
  • MPFR (Multi-precision floating-point computation library) - 2.4.2

You can find the above mentioned tarballs in http://www.rtems.org/ftp/pub/rtems/SOURCES/4.11/ You can get it too trough ftp.rtems.com

[edit] Unpack archives

 tar xjf ../archive/binutils-2.21.tar.bz2
 tar xjf ../archive/gcc-core-4.5.2-RC-20101208.tar.bz2
 tar xjf ../archive/gcc-g++-4.5.2-RC-20101208.tar.bz2
 tar xzf ../archive/newlib-1.19.0.tar.gz
 tar xjf ../archive/gdb-7.2.tar.bz2
 tar xjf ../archive/gmp-4.3.2.tar.bz2
 tar xzf ../archive/mpc-0.8.1.tar.gz
 tar xjf ../archive/mpfr-2.4.2.tar.bz2

[edit] Applying RTEMS patches

The patches can be downloaded from http://www.rtems.org/ftp/pub/rtems/SOURCES/4.11/ for 4.11 version. You are required to download the following files.

 binutils-2.21-rtems4.11-20110107.diff
 gcc-core-4.5.2-RC-20101208-rtems4.11-20101210.diff
 newlib-1.19.0-rtems4.11-20110109.diff

Remember, RTEMS is an active project. the above mentioned toolset patches might have newer versions. Make sure you check the modified date and pick up the latest diff file.


 cd binutils-2.21
 cat ../../archive/binutils-2.21-rtems4.11-20110107.diff | patch -p1 --dry-run
 cat ../../archive/binutils-2.21-rtems4.11-20110107.diff | patch -p1
 cd ../gcc-4.5.2-RC-20101208/
 cat ../../archive/gcc-core-4.5.2-RC-20101208-rtems4.11-20101210.diff | patch -p1 --dry-run
 cat ../../archive/gcc-core-4.5.2-RC-20101208-rtems4.11-20101210.diff | patch -p1
 cd ../newlib-1.19.0/
 cat ../../archive/newlib-1.19.0-rtems4.11-20110109.diff | patch -p1 --dry-run
 cat ../../archive/newlib-1.19.0-rtems4.11-20110109.diff | patch -p1
 cd ..

At every step check for any errors.

[edit] Config and build binutils-2.20.1

 Target Processor --target=lm32-rtems4.11 
 Installation Point --prefix=/opt/rtems-4.11

Adjust these as you please.

 mkdir b-binutils
 cd b-binutils
 ../binutils-2.21/configure --target=lm32-rtems4.11 --prefix=/opt/rtems-4.11
 make all
 make info
 make install
 cd ..

Now, set the path to include the just-built executables

 export PATH=/opt/rtems-4.11/bin:${PATH}

[edit] Config and build gcc

 cd gcc-4.5.2-RC-20101208/
 ln -s ../newlib-1.19.0/newlib .
 cd ..
 mkdir b-gcc
 cd b-gcc/
 ../gcc-4.5.2-RC-20101208/configure --target=lm32-rtems4.11 --with-gnu-as --with-newlib --verbose --enable-threads --enable-languages="c,c++" --prefix=/opt/rtems-4.11
 make all
 make info
 make install
 cd ..

Notes:

  • Optionally you can build gdb also.
  • You can avoid install stuff as root/sudo, if you previously give permissions in your /opt folder to your user.
chown -R your_user:your_user /opt