#1 Getting started with RTEMS for i386

To learn our way around RTEMS, an easy step is to play with the i386 target under a linux host machine.

[R1] - Toolchain for Linux

I. Installation / BSP compilation

From [R1], download and install the required packages for the i386 architecture:

List of Packages
rtems-4.11-gdb-common
rtems-4.11-gcc-common
rtems-4.11-newlib-common
rtems-4.11-binutils-common
rtems-4.11-rtems4.11-autoconf
rtems-4.11-rtems4.11-automake
rtems-4.11-i386-rtems4.11-binutils
rtems-4.11-i386-rtems4.11-gcc
rtems-4.11-i386-rtems4.11-newlib
rtems-4.11-i386-rtems4.11-gcc-libgcc
rtems-4.11-i386-rtems4.11-gcc-c++
rtems-4.11-i386-rtems4.11-libstdc++
rtems-4.11-i386-rtems4.11-gdb

Once all packages are downloaded and installed (rpm -i *.rpm for OpenSuse), add RTEMS compiler to the PATH from a terminal window (exact location depends on RTEMS toolchain version):

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

Download and extract RTEMS ( latest stable release from www.rtems.org/ftp/pub/rtems/ or a fresh checkout from git ):

$ mkdir $HOME/rtos
$ cd $HOME/rtos
$ git clone git://git.rtems.org/rtems.git

The next step is to prepare RTEMS by running the bootstrap script:

$ cd rtems
$ ./bootstrap
$ cd ..

Now comes the time to compile RTEMS and BSP for the wanted target (pc386). RTEMS is compiled outside the source tree. In the current configuration, the RTEMS test applications are included to the build process:

$ mkdir pc386
$ mkdir pc386/install
$ cd pc386

$ ../rtems/configure --target=i386-rtems4.11 --enable-rtemsbsp=pc386 --enable-tests=samples --disable-posix --prefix=$HOME/rtos/pc386/install

Configuration options are detailed in the README.configure from RTEMS source tree, some options are:

--disable-rtems-inlines
--disable-posix
--disable-networking
--enable-cxx
--enable-multiprocessing
--enable-rtemsbsp="bsp1 bsp2 ..."
--enable-tests
--enable-rdbg (only valid for i386 and some PowerPC BSPs)
--enable-docs

Finally, compile and install with the regular:

$ make
$ make install

The example executables are available from the $HOME/rtos/pc386/install/i386-rtems4.11/pc386/lib/rtems-4.11/tests directory. Most test applications are delivered with a short description (.doc). Some of the applications are:

- fileio.exe
- hello.exe
- loopback.exe
- minimum.exe
- nsecs.exe
- paranoia.exe
- ticker.exe
- unlimited.exe

We will focus on the fileio.exe application that starts up the RTEMS shell. Source code for this application is located under: rtems/testsuites/samples/fileio/*

II. Running RTEMS under QEMU

To run the i386 test application, an emulator such as QEMU is an obvious solution. Fetch the latest source code from GIT repository and compile QEMU for the targeted architecture. The relevant result is the program qemu/i386-softmmu/qemu-system-i386 and will be used to emulate the target board.

$ git clone git://github.com/qemu/QEMU.git
$ ../configure --enable-system --target-list=x86_64-softmmu,i386-softmmu
$ make
$ cd i386-softmmu

Everything is now in place to fire up our RTEMS based application. The particularity of the fileio.exe application outside its primarly role of testing the fileio layer is that it brings up the RTEMS shell, giving the user access to all general and RTEMS specific commands described in the RTEMS Shell User's Guide

$ ./qemu-system-i386 -kernel $HOME/rtos/pc386/i386-rtems4.11/c/pc386/testsuites/samples/fileio/fileio.exe

Et voila! we have now access to the QEMU console. Type 's' to start RTEMS shell.



Here is a list of RTEMS specific commands that gives insight to the kernel:



We can see that the fileio application starts 4 differents threads + the IDLE thread.