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.

Another approach is to follow the directions for using the rtems-source-builder, which was created and is maintained by Chris Johns. Using the source builder abstracts away many of the problems encountered by people just getting started with RTEMS.

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++ libalgorithm-diff-perl libalgorithm-diff-xs-perl \
  libalgorithm-merge-perl libdpkg-perl libgmp-dev libgmp3-dev libgmpxx4ldbl \
  libltdl-dev libmpc-dev libmpfr-dev libtimedate-perl \
  libtool texinfo flex libncurses5-dev

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.

Installing updated Autotools

RTEMS uses both autoconf and automake heavily, and often require newer versions than what are provided by Ubuntu. Given that many problems in building RTEMS are traced to incorrect versions of these tools, please install the versions available at http://www.rtems.org/ftp/pub/rtems/SOURCES/4.11/ 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, many applications developers don't use these except when building RTEMS, which is not a common event. So, while the updated autotools might be classified as part of the host environment (because RTEMS does not patch these, or use rtems-specific configurations), the updated autotools could also be considered part of the RTEMS toolset. For purposes of this How-To, the distinction really doesn't matter.

autoconf

 ~$                  mkdir ~/tools
 ~/tools$            tar xjf ../archive/autoconf-2.xx.tar.bz2      # NOTE: point to the location of your downloaded autoconf-2.xx.tar.bz2
 ~/tools$            mkdir b-autoconf
 ~/tools$            cd b-autoconf/
 ~/tools/b-autoconf$ ../autoconf-2.xx/configure --prefix=/home/$USER
 ~/tools/b-autoconf$ make
 ~/tools/b-autoconf$ sudo make install
 ~/tools/b-autoconf$ cd ..
 ~/tools$            rm -fr b-autoconf

automake

 ~/tools$            tar xf ../archive/automake-1.xx.y.tar.bz2 
 ~/tools$            mkdir b-automake
 ~/tools$            cd b-automake/
 ~/tools/b-automake$ ../automake-1.10.1/configure
 ~/tools/b-automake$ make
 ~/tools/b-automake$ sudo make install
 ~/tools/b-automake$ cd ..
 ~/tools$            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

Preparing the Build Environment

Failure to complete this step will result in many mysterious problems...

The standard install point is /opt/rtems-4.11 In Ubuntu, this comes with some issues: the PATH and the permissions of the /opt/rtems-4.11 directory.

To fix the PATH problem thoroughly, export /opt/rtems-4.11/bin to the PATH using ./bashrc

 $ echo export PATH=$PATH:/opt/rtems-4.11/bin >> ~/.bashrc

To avoid permissions problems you need to make the user the owner of the install point

 $ sudo mkdir /opt/rtems-4.11

Change the ownership of /opt/rtems-4.11 to the user. Using the -R option make the changes apply to the subdirectories

 $ sudo chown -R joel /opt/rtems-4.11

You are now ready to build the tools on RTEMS

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

Inspired by Milky Mist [1]...

We start with installing the dependencies:

$ sudo apt-get build-dep qemu

As of June 19, 2012 the development version of Qemu worked on Ubuntu... To get the development version:

  $ git clone git://git.qemu.org/qemu.git

You'll want to select the appropriate target for your hardware. As of June 2012, some targets of that may be of interest are:

  1. i386-softmmu
  2. arm-softmmu
  3. lm32-softmmu
  4. m68k-softmmu
  5. mips-softmmu
  6. sparc-softmmu

For a more complete listing of what qemu emulates: http://wiki.qemu.org/Documentation/ISAManuals To build on Ubuntu, I had to enable the sdl library...

$ mkdir b-qemu
$ cd b-qemu
$ CFLAGS='-DAT_EMPTY_PATH=0x1000' \
../qemu/configure \
--target-list="i386-softmmu" \
--enable-sdl && make && sudo make install

The CFLAGS='-DAT_EMPTY_PATH=0x1000' defines the behavior of an empty relative path name [2].

Set-up Qemu Hard-Drive

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

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

Configure RTEMS for QEMU

To configure RTEMS for use with QEMU:

../rtems/configure --target=i386-rtems4.11 \
   --prefix=/opt/rtems-4.11 \
   --enable-maintainer-mode --enable-tests \
   --enable-networking --enable-posix \
   --disable-itron \
   --enable-rtemsbsp=pc386
make all
sudo PATH=/opt/rtems-4.11/bin:${PATH} make install

Launch Qemu

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

~/$ qemu-system-i386 \
    -hda rtems-boot.img \
    -hdb fat:b-i386/i386-rtems4.11/c/pc386/testsuites/samples/fileio \
    -kernel fileio.exe

See, http://www.rtems.org/wiki/index.php/QEMU for details

Find and load executable

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]

Additional Resources

  1. Scripts to build the RTEMS toolset
Personal tools
Namespaces

Variants
Actions
Navigation
Gedare's Special Help
Toolbox