Next Previous Contents

5. Getting started with picoTK for RTEMS

picoTK makes a compact and easy to integrate GUI add-on for the RTEMS real- time operating systems. RTEMS is an OpenSource POSIX compliant real-time kernel written and maintained by the Online Application Research Corporation, Huntsville, AL. RTEMS is available for many embedded 32-bit platforms, including the PC, the Motorola PowerPC and the 68K. The most current versions of RTEMS now support TCP/IP networking, making it suitable for internet connected appliances. RTEMS is for real-time world, what Linux is for the dektop/server OSses. The following describes how to install RTEMS for a Linux development host and a PC (i386) target. The required GNU C/C++ cross-compiler toolchains for other host/target pairs are available precompiled from OAR's site as well. I personally used a SuSE 7.0 Linux system - any other current Linux distribution shall do as well.

5.1 Getting started with RTEMS

The following steps summarize the installation of RTEMS 4.5, the required additional tools for creating PC bootable floppy disks and linking of the picoTK demo application.

Get the distribution files

Get the following files from

 (for i386 Linux host, i386-Target):
These are the precompiled toolchain packages for i386/i386 host/target combination.

This is the RTEMS source. We have to compile it using the above toolchain.

RTEMS Bootloader. Allows booting RTEMS from floppy disk.

Simple test program. Instructive for building your own Makefiles.

Install the RPMs

Become root. From the directory where you collected the RPMs type:

       rpm -i rtems-base*rpm i386-rtems*rpm

(Accidently the alphabetic order implied by the bash wildcards gets the RPMs installed in the right order)

Add RTEMS toolchain directory to your path

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

Assuming you use bash as your command shell. It is only needed for the following initial compilation of RTEMS itsel. Your own projects will find the compiler using a special environment variable as described in section "Set the environment"( set-rtems-environment ).

Install the RTEMS source

Become an ordinary user. Create directory "rtems" somewhere in your home, e.g. /home/thomas/rtems. The rtems directory shall be on the same level as the "picotk" directory, see 4.1.2. The directory structure looks at follows (after the installation of all packages):

           |      /emulators
           |      /demo/
           |           /rtems

Cd to the rtems directory and untar RTEMS:

       mkdir rtems
       cd rtems
       tar xzf <...>/rtems-4.5.0.tgz

Create empty directory in which the compilation results will be held during compilation. (See note below.)

       mkdir build

Up to now you shall have the following dir structure:


IMPORTANT NOTE (Just for a better understanding): This is very special with RTEMS and might cause some trouble to the RTEMS newbie: Source texts and compilation output (i.e. objects) are kept in different directory trees (.../rtems-4.5.0 and .../build respectively). Sometimes it is necessary to change the RTEMS source text (for doing configuration, tweaking drivers, etc.) Changing/Recompiling RTEMS requires these three steps:

  1. Change source in the source-tree .../rtems-4.5.0
  2. Compile in .../rtems/build directory using make RTEMS_BSP=pc386
  3. Install RTEMS in .../rtems/build directory using make install RTEMS_BSP=pc386. This copies things into the "public" installation directories. The default settings of RTEMS - which are wise to use nevertheless - spatter RTEMS around the /usr and /opt directories. Don't forget this step.

Configure, build and install RTEMS

   cd build
   ../rtems-4.5.0/configure --target=i386-rtems 
   make RTEMS_BSP=pc386
   su                    /* Become root */
   make install RTEMS_BSP=pc386
   chmod -R 777 /usr/local/pc386   

The chmod line is necessary since the RTEMS Makefiles insist on writing into that directory - causing write errors when being an ordinary user.

Compiling RTEMS might take a considerable amount of time (15-20 min on a K6-3/400).

Set the environment

RTEMS requires this additional setting in your environment:

   export RTEMS_MAKEFILE_PATH=/usr/local/pc386       (sic!)

Add this line to the end of your personal .bashrc file. Logout and login again for the settings to take effect.

(The RTEMS_MAKEFILE_PATH points to the directory where a "" file resides. )

Install pc386_lilo

As an ordinary user type:

   cd .../rtems
   tar xzf .../pc386_lilo.tgz

Install and Compile the Hello World demo

You can skip installation and test of the hello_world_demo and go straight to the picoTK RTEMS demo, ch. 5.2.

As ordinary user

   cd .../rtems
   tar xzf .../hello_world_c.tgz 
   cd hello_world_c

If you get an error about the not writable file in /usr/local/pc386/... you can either simply ignore this message or execute the chmod line from section "Configure, build and install RTEMS"( build-rtems ).

There shall be an RTEMS "executable" now named o-optimize/test.exe

Install pc386_lilo and generate hello_world boot disk

   cd ..
   cd rtems
   tar xzf .../pc386_lilo.tgz
   cd pc386_lilo

Edit Change the RTEMS_IMAGE=... line to include the hello world binary (it is required to enter the full path), e.g.:




This looks like the end of a Linux kernel compilation and yields a zImage file. Copy this file to a diskette and check the hello_world output. There is a bug in some versions of the GNU linker ld yielding in the following error:

     ld: cannot open binary: No such file or directory
If this is the case edit the Makefile and substitute all occurences of -oformat by --oformat.

5.2 Compile the picoTK RTEMS library and the RTEMS demo

Now you are ready to compile the picoTK RTEMS library. This uses the RTEMS cross tool chain and the RTEMS OS installation - i.e. you definitely need to have them installed at this point.

Compile the RTEMS library

Change directory to where you installed picoTK. Execute

   make rtems

This shall yield a file called "libPTKrtems.a" in the toolkit subdirectory. That is the statically linked picoTK library for RTEMS.

Compile RTEMS picoTK demo

   cd demo
   make rtems
   make zImage

Make sure that RTEMS_IMAGE is pointing to your actual demo.exe before executing make zImage. If you get an error from ld please refer to the section describing the hello_world demo. This yields a file bootable zImage which can be copied to a diskette using

   cp zImage /dev/fd0

(Depending on the permissions of /dev/fd0 you might have to do this as root. You can set permissions of /dev/fd0 to 666, i.e. chmod 666 /dev/fd0 and futurely execute the copy command as an ordinary user)

Simply boot this diskette on a PC.

Next Previous Contents