Building the RTEMS toolset on Ubuntu

From RTEMSWiki

Jump to: navigation, search

Contents

This How-To documents the steps taken to install the RTEMS toolset on various releases of Ubuntu assuming a fresh install of Ubuntu immediately after rebooting into Ubuntu after installation. The Ubuntu installation was extremely simple, and in most cases you can simply let the installer do its work accepting all defaults. Be sure to match the RTEMS tools versions with the version of RTEMS you will be using.

Installing a working RTEMS environment can be described as a multi-phase process:

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

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 12.04

This single command was enough to install the missing pieces

sudo apt-get install autoconf automake autotools-dev build-essential git \
  dpkg-dev g++ g++-4.6 libalgorithm-diff-perl libalgorithm-diff-xs-perl \
  libalgorithm-merge-perl libdpkg-perl libgmp-dev libgmp3-dev libgmpxx4ldbl \
  libltdl-dev libmpc-dev libmpfr-dev libstdc++6-4.6-dev libtimedate-perl \
  libtool texinfo flex yacc

Install Ubuntu 11.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 libtool

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 (or later) 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

Build RTEMS Tools

See the Building Tools page for instructions on how to build from source. You may also try the prebuilt tools route.

Build RTEMS

At this moment you can follow GSoC_Getting_Started#Configure_and_Build_RTEMS_for_SPARC.2FSIS and build RTEMS.

Install

You can get the RTEMS source code from the Git Repository

git clone git://git.rtems.org/rtems.git rtems

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

Another option is to add

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

to the end of your /home/ubuntu/.bashrc

Next follow the installation directions at http://www.rtems.org/wiki/index.php/Quick_Start

Build Qemu

Install the dependencies:

$ sudo apt-get install libasound2-dev libavahi-client-dev libavahi-common-dev libcaca-dev \
  libdbus-1-dev libdrm-dev libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev \
  libice-dev libkms1 libncurses5-dev libpcre3-dev libpcrecpp0 libpng12-dev \
  libpthread-stubs0 libpthread-stubs0-dev libpulse-dev libsdl1.2-dev \
  libslang2-dev libsm-dev libtinfo-dev libx11-dev libx11-doc libxau-dev \
  libxcb1-dev libxdmcp-dev libxext-dev libxt-dev mesa-common-dev \
  x11proto-core-dev x11proto-input-dev x11proto-kb-dev x11proto-xext-dev \
  xorg-sgml-doctools xtrans-dev zlib1g-dev

Download the source-code http://wiki.qemu.org/Download Currently, building version 1.0.1 gives an error, so I used version 0.15.1

$ mkdir b-qemu
$ cd b-qemu
$ ../qemu-0.15.1/configure --target-list=i386-softmmu && make && sudo make install

Get the rtems-boot.img from [1] make a hard drive image:

dd if=/dev/zero of=hda.img count=1000

To configure RTEMS for use with QEMU:

../rtems/configure --target=i386-rtems4.11 \
   --prefix=$INSTALL --disable-multiprocessing \
   --disable-cxx --disable-rdbg \
   --enable-maintainer-mode --enable-tests \
   --enable-networking --enable-posix \
   --disable-itron --disable-deprecated \
   --disable-ada --disable-expada \
   --enable-rtemsbsp=pc386 \
   USE_COM1_AS_CONSOLE=1 BSP_PRESS_KEY_FOR_RESET=0

Start qemu, make sure to change the paths to the rtems-boot.img, hda.img, and samples to your set-up

$ qemu -m 128 -boot a -fda rtems-boot.img -hda hda.img \
-hdb fat:b-i386/i386-rtems4.11/c/pc386/testsuites/samples/ \
-serial stdio -no-reboot -s

See, http://www.rtems.org/wiki/index.php/QEMU for details Once in qemu look for the file you want to boot:

grub> ls (hd1,1)/
grub> ls (hd1,1)/hello
etc.

Next set the directory as the root directory

grub> root=(hd1,1)

Then, load the file into the bootloader, and boot it!

grub> multiboot (hd1,1)/hello/hello.exe
grub> boot

Build and Test Applications

User supplied! Some example applications can be found by following the directions at http://www.rtems.org/wiki/index.php/Example_Application_Compiling

Examples-v2

These are just some additional examples of how to get started with existing RTEMS applications. 1. Use git to get the examples-v2 2. Navigate to the examples-v2 3. Tell Bash where to find the RTEMS_MAKEFILE_PATH 4. Build the examples-v2 execuatbles

$ git clone git://git.rtems.org/examples-v2.git examples-v2
$ cd examples-v2
$ export RTEMS_MAKEFILE_PATH=/opt/rtems-4.11/i386-rtems4.11/pc386/
$ make

Load the examples-v2 executables into Qemu's virtual filesystem.

$ qemu -m 128 -boot a -fda rtems-boot.img -hda hda.img -hdb \
       fat:examples-v2/hello/both_hello/o-optimize/ \
       -serial stdio -no-reboot 

-m 128: set the memory to 128

-boot a: boot from the a drive

-fda rtems-boot.img: load the rtems-boot.img into the a drive

-hda hda.img: use hda.img as the virtual hard-drive

-hdb fat:examples-v2/hello/both_hello/o-optimize/: use examples-v2/hello/both_hello/o-optimize as the root of the (FAT) virtual filesystem

To navigate while in grub:

1. find the executable in the virtual filesystem

2. set the root of the virtual filesystem as the root

3. load (multiboot) the executable

4. boot the executable

grub> ls (hd1,1)/
grub> root=(hd1,1)/
grub> multiboot (hd1,1)/both_hello.exe
grub> boot

Network Demos

Now to try network-demos!

$ git clone git://git.rtems.org/network-demos.git
$ cd network-demos
$ export RTEMS_MAKEFILE_PATH=/opt/rtems-4.11/i386-rtems4.11/pc386/
$ make
$ cd ..
$ qemu -m 128 -boot a -fda rtems-boot.img -hda hda.img \
       -hdb fat:network-demos/http/o-optimize/ \
       -serial stdio -no-reboot \
       -redir tcp:5555:80
grub> ls (hd1,1)/
grub> root=(hd1,1)
grub> multiboot (hd1,1)/http.exe
grub> boot

Without closing qemu, in Ubuntu, open Firefox, navigate to http://localhost:5555/

Additional applications can be found at: [http://git.rtems.org/] Information about these applications is provided at [http://wiki.rtems.org/wiki/index.php/RTEMS_GIT_Repository]

Personal tools