Building the RTEMS toolset on Ubuntu

From RTEMSWiki

Jump to: navigation, search

Contents

This How-To documents the steps I followed to install the RTEMS 4.9 (as of 12 September 2008) toolset on Ubuntu 8.04 LTS.

In this case, the host was a fresh install of Ubuntu; immediately after rebooting into Ubuntu after installation, I began the RTEMS toolset installation. The Ubuntu installation was extremely simple, as I simply let the installer to its work, accepting all defaults.

Bringing the host from virgin installation to a working RTEMS environment can be described as a multi-phase process. Here are the Phases I followed:

   Phase 1. Install Ubuntu & GNU Tools
   Phase 2. Build RTEMS Tools
   Phase 3. Build RTEMS
   Phase 4. Build and Test Applications

Details of each Phase follow.

Phase 1. Install Ubuntu & GNU Tools

The purpose of this phase is to set up the host to be able to build the RTEMS toolset. This mainly consists of installing common Linux development tools required to build the RTEMS tools or RTEMS itself.

Install Ubuntu 10.10

This single command was enough to install the missing pieces

sudo aptitude install m4 patch  build-essential texinfo cvs \
    libncurses5-dev libgmp3-dev libmpfr-dev libmpc-dev autoconf \
    autotools-dev automake

Install Ubuntu 10.04 LTS

This single command was enough to install the missing pieces

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

And if you like gvim, also load vim-gnome

Install Ubuntu 9.04 LTS

This single command was enough to install the missing pieces

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

And if you like gvim, also load vim-gnome

Install Ubuntu 8.04 LTS

Sorry, I'm not going to get into this, because I am not qualified, and besides, my two installation attempts were so idiot-proof that they both went off without a single hitch. In both cases, the hardest part was creating the bootable installation CD! Vist http://www.ubuntu.com/ to get started.

One note before we begin. The Ubuntu philosophy appears to be not having a user-accessible root account (i.e. you cannot log in as root). Rather than fight city hall, I simply logged in as a regular user with sudo rights. The impact is requiring sudo for most tasks that actually installed software.

autoconf-2.62

NOTE: If using Ubuntu 10.10 this step is not needed.

RTEMS uses both autoconf and automake heavily, and require newer versions than what are provided by Ubuntu (as of 12 September 2008, anyway). Given that many problems in building RTEMS are traced to incorrect versions of these tools, I installed the versions available at /ftp/pub/rtems/SOURCES/4.9 tools on the RTEMS ftp site.

Note: FWIW, these tools could have been classified as RTEMS tools, and for the developers of RTEMS, they are indeed that. However, from an applications developer, you generally don't use these except when building RTEMS, which is not a common event. So, while I classify them part of the host environment, I won't argue with anyone who considers them part of the RTEMS toolset. For purposes of this How-To, the distinction really doesn't matter.

 $ tar xjf ../archive/autoconf-2.62.tar.bz2 
 $ mkdir b-autoconf
 $ cd b-autoconf/
 $ ../autoconf-2.62/configure
 $ make
 $ sudo make install
 $ cd ..
 $ rm -fr b-autoconf/

automake-1.10.1

NOTE : If using Ubuntu 10.10 this step is not needed

 $ tar xjf ../archive/automake-1.10.1.tar.bz2 
 $ mkdir b-automake
 $ cd b-automake/
 $ ../automake-1.10.1/configure
 $ make
 $ sudo make install
 $ cd ..
 $ rm -fr b-automake/

Working gcc!

I don't know what happened, but my Ubuntu installation ended up with a broken gcc compiler. It apparently was installed (i.e. the command "gcc" existed), it didn't work. I tested it with a simple program:

 int main() {
   return 0;
 }

Attempting to build this with "gcc f.c" failed with a "Can't create executable" error message. The fix is simply to install "build-essential" which gives us a working gcc toolchain on the host.

 $ sudo apt-get install build-essential

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

Phase 2. Build RTEMS Tools

Assumptions

Assume a root directory rtems. Under that, create two directories: archive and tools. For this How-To, I used PowerPC as the target, for purely selfish reasons. 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.

Tools needed

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

  • Binutils - 2.20
  • GCC (gcc-core) - 4.5.0
  • GCC (gcc-g++) - 4.5.0
  • GDB - 7.1
  • Newlib - 1.18.0
  • GMP (Multi-precision arithmetic library) - 4.3.2
  • MPC (Multi-precision complex floating-point library) - 0.8.2
  • 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/

Unpack archives

 $ tar xjf ../archive/binutils-2.20.tar.bz2 
 $ tar xjf ../archive/gcc-core-4.5.0.tar.bz2 
 $ tar xjf ../archive/gcc-g++-4.5.0.tar.bz2 
 $ tar xzf ../archive/newlib-1.18.0.tar.gz
 $ tar xjf ../archive/gdb-7.1.tar.bz2
 $ tar xjf ../archive/gmp-4.3.2.tar.bz2
 $ tar xjf ../archive/mpc-0.8.2.tar.bz2
 $ tar xjf ../archive/mpfr-2.4.2.tar.bz2

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.20.1-rtems4.11-20100826.diff
 gcc-core-4.5.1-rtems4.11-20100818.diff
 newlib-1.18.0-rtems4.11-20101126.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.20/
 $ cat ../../archive/binutils-2.20.1-rtems4.11-20100826.diff | patch -p1 --dry-run
 $ cat ../../archive/binutils-2.20.1-rtems4.11-20100826.diff | patch -p1
 $ cd ../gcc-4.5.1/
 $ cat ../../archive/gcc-core-4.5.1-rtems4.11-20100818.diff | patch -p1 --dry-run
 $ cat ../../archive/gcc-core-4.5.1-rtems4.11-20100818.diff | patch -p1
 $ cd ../newlib-1.18.0/
 $ cat ../../archive/newlib-1.18.0-rtems4.11-20101126.diff| patch -p1 --dry-run
 $ cat ../../archive/newlib-1.18.0-rtems4.11-20101126.diff | patch -p1
 $ cd ..

At every step check for any errors.

Config and build binutils-2.18

Note here my choices:

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

Adjust these as you please.

 $ mkdir b-binutils
 $ cd b-binutils
 $ ../binutils-2.18/configure --target=powerpc-rtems4.11 --prefix=/opt/rtems-4.11
 $ make all
 $ make info
 $ sudo make install
 $ cd ..

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

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

Config and build gcc

 $ cd gcc-4.5.1/
 $ ln -s ../newlib-1.18.0/newlib .
 $ cd ..
 $ mkdir b-gcc
 $ cd b-gcc/
 $ ../gcc-4.5.1/configure --target=powerpc-rtems4.11 --with-gnu-as --with-newlib --verbose --enable-threads --enable-languages="c,c++" --prefix=/opt/rtems-4.11
 $ make all
 $ make info
 $ sudo make install
 $ cd ..

Phase 3. Build RTEMS

At this moment you can follow GSoC_Getting_Started#Configure_and_Build_RTEMS_for_SPARC.2FSIS and build RTEMS. A quick overview is given below (does not have all the necessary steps).


Get the source

 $ tar xjf ../archive/rtems-cvs-20080911.tar.bz2

Run bootstrap

 $ cd rtems-cvs-20080911/
 $ ./bootstrap

It may take a few minutes to complete.

Configure and build

 $ cd ..
 $ mkdir b-rtems-4.9-testing
 $ cd b-rtems-4.9-testing/
 $ ../rtems-cvs-20080911/configure --enable-rtems-debug \
   --target=powerpc-rtems4.9 --enable-posix --prefix=/opt/rtems-4.9 \
   --enable-networking --enable-cxx --enable-rtemsbsp="virtex" --enable-maintainer-mode
 $ make all

Install

This is a tiny bit tricky on Ubuntu, and maybe others. We need to install as root, but so far, only our personal account has access (via the PATH environmental variable) to the tools. So, we need to set the variable when we install.

 $ sudo PATH=/opt/rtems-4.11/bin:${PATH} make install

Phase 4. Build and Test Applications

User supplied!

Personal tools