Friday, March 29, 2013

Setting up an RTEMS development environment for the Raspberry Pi

Setting up an RTEMS development environment for the Raspberry Pi

For this tutorial, I’m going to use Ubuntu 12.10 64 bit (updated to 14.10 LTS on April 2014). It is possible to do RTEMS development on almost any recent version of Linux, OS X, FreeBSD, and Windows. The RTEMS project provides pre-built compilers for all RTEMS architectures for a number of different development hosts including Fedora, CentOS, Suse, and Windows.

In addition to the pre-built compilers provided, there is a tool called RTEMS Source Builder that can download, patch, build, and install the compiler for you. This is what we will use for our Ubuntu setup.

  1. You will need a RTEMS compiler, an ARM bare metal GCC will not do.

  2. I have posted some instructions for setting up the environment for Windows 7 here

  3. The following instructions start with a fresh install of Ubuntu 14.10 LTS 64 bit, with all updates applied.

Install Ubuntu prerequisites:

$ sudo apt-get install build-essential
$ sudo apt-get install git
$ sudo apt-get install python-dev
$ sudo apt-get build-dep binutils gcc g++ gdb unzip git

Decide where the RTEMS tools and projects will reside

Here is the directory structure we will be using:

Path Description


The base directory for all RTEMS work


Where the compiler is installed


Where the RTEMS source code is checked out


Where the RTEMS board support packages/libs are installed


The RTEMS source builder tool

Table 1. Directory Structure

Lets get started on this:

$ cd $HOME
$ mkdir development
$ cd development
$ mkdir rtems
$ cd rtems
$ mkdir compiler

Build the RTEMS ARM cross compiler

The RTEMS Source builder documentation is located here:

1. Check out the RTEMS source builder tool

$ cd $HOME/development/rtems
$ git clone git://

2. Double check that all source builder dependencies are present:

$ cd rtems-source-builder
$ source-builder/sb-check

This command should return the following:

RTEMS Source Builder environment is OK
Note The separate autotools build is no longer needed. The source builder will install them for you.

3. Build and install the toolchain

$ cd $HOME/development/rtems/rtems-source-builder/rtems
$ ../source-builder/sb-set-builder \
         --log=build-log.txt \
         --prefix=$HOME/development/rtems/compiler/4.11 \

After the full download and build process, the toolchain is installed in:

Tip This whole process can take about 10 to 30 minutes depending on your computer specs. This has been run on a Raspberry Pi: Expect that to take all day!

4. Add the toolchain bin directory to your path, and you are ready to download and build RTEMS:

$ cd $HOME

Using your favorite editor, edit the .profile file and add the following line at the end of the file


5. Now, logout and log back in. Open a terminal and type:

$ arm-rtems4.11-gcc -v

You should see the compiler version message. The compiler is installed and ready to use!

Next: How to download and build RTEMS


  1. Hi, alan
    I'm try to build on debian (fresh installation into a VMWare machine).
    $ ../source-builder/sb-set-builder --log=build-log.txt --prefix=$HOME/development/rtems/compiler/4.11 4.11/rtems-arm

    shell returned:
    Traceback (most recent call last):
    File " ../source-builder/sb-set-builder", line 26, in
    File " ../source-builder/sb/", line 364, in run
    log.default = log.log(opt.logfiles())
    File " ../source-builder/sb/", line 594, in logfiles
    return self.opts['log'].split(',')
    AttributeError: 'NoneType' object has no attribute 'split'
    You know how to fix it.
    Thank you.

    1. try running ../source-builder/sb-check
      This will let you know if all of the required tools are installed

      Also, what version of debian are you running? And what version of python?

    2. Also, the RTEMS project has debian packages for the tools:

      If you use these, you will have to change the arm-rtems4.11 prefix to arm-rtemseabi4.11 when configuring and building rtems.

  2. -the debian mount 2.6.32-5-amd64 kernel;
    -the python version is 2.6;
    -I made the check after git cloning and the result was ok;

  3. Ok ... may be I fix it.
    Under Debian the requirements are:
    $ sudo apt-get install autoconf automake bison flex binutils gcc g++ gdb \
    texinfo unzip ncurses-dev python-dev git.

    Then we must add autoconf automake bison flex texinfo ncurses-dev python-dev to the list above!

    I hope the build will finish without error.

  4. The build was gone fine!
    in my macbookpro 5.5 and the Debian VM the time elapsed was 1h 17min;

    In this moment I'm doing the same thing on my macBookPro the requirements for building process:
    from official chrisj reference:
    MacOS X:
    The RTEMS Source Builder has been tested on Mountain Lion. You will need to install the Xcode app using the App Store tool, run Xcode and install the Developers Tools package within Xcode.

    But I've tryed ...and not work. Then I installed the Debian requirements on MacOS using homebrew.
    I've used others tool-chains, in past, in my system then installing packages listed below (that I have installed throught homebrew) worked fine for me:
    $ brew install autoconf automake binutils texinfo xz

    In general I suppose that in a fresh install we need of Xcode, DevelopesTools and all Debian requirements.

    The time elapsed for this building was 1 hour and 08 minutes.
    A bit surprisly, the time in DebVM is similar for both building process...
    The VM was created using only one of the two processor present in the laptop.....
    Yes Debian have a fresh install, and yes Debian is Debian... ( :) ) but ..... o_O

  5. Question:
    In ypur opinion, can I install in this way also RTEMS running in MacOSX (i386 for a MBPro5.5)??

    if yes can I follow this tutorial modifying it in this way:

    1:SettingUp RTEMS dev-env for MacOsX:
    satisfy requirements;

    $ cd $HOME
    $ mkdir -p development/rtems/compiler
    $ cd development/rtems/compiler
    (skip this point if another RTEMS build is present in the sys.
    and jump to point e)

    $ cd $HOME/development/rtems
    $ git clone git://

    $ cd rtems-source-builder
    $ source-builder/sb-check

    $ cd rtems (you should be in $HOME/development/rtems/rtems-source-builder/rtems )
    $ ../source-builder/sb-set-builder --log=build-log.txt \
    --prefix=$HOME/development/rtems/compiler/4.11 \

    $ ../source-builder/sb-set-builder \
    --log=autotools-log.txt \
    --prefix=$HOME/development/rtems/compiler/4.11 \

    I think that I can skip this point if another build is present.
    Is true???

    $ cd $HOME
    and set the path with a persistent environment system variable.
    I think that I can skip this point if another build is present.
    Is true???

    after logout & login I will find i386-rtems4.11-gcc ???

    then I can move to the next step….

    1. Yes, it should work as you describe. The same PATH will work for any number of RTEMS architecture toolchains. I often have m68k, sparc, and arm on one system.

  6. While I'm tryng to port to powerpc G3 lombard I read that there is the
    GDB ARM Simulator -- gdbarmsim support.
    You think that including this in the building of gdb I can debugg into RaspPi & into MacOS ??

  7. Step 3 in the instructions is missing the following as the first line:

    $ cd $HOME/development/rtems/rtems-source-builder/rtems

  8. Hi,
    I see that this blog is about rtems-raspberry, but a have an issue with arm-rtems same arhitecture .
    I am trying to build the rtems for arm and I have an issue on the asm part in file armv7m-context-restore.c in function:
    void __attribute__((naked)) _CPU_Context_restore(
    Context_Control *heir
    the error is : rtems_stm32f4/cpukit/score/cpu/arm/armv7m-context-restore.c:29:3: error: impossible constraint in ‘asm’

    I'm using gcc-4.8.0-rtems4.11-20130502
    Has someone a good idea how to solve this ?
    I'm using gcc-4.8.0-rtems4.11-20130502
    Have someone a good idea how to solve this ?

    1. Hi, I'm not quite sure how to solve this one..
      A couple of days ago, I installed arm-rtems4.11 4.8.1 20130531 ( for windows ) and compiled the latest rtems git head for the raspberry pi.

      I have not tried building a armv7 target for RTEMS. I suspect you might need a more recent GCC/newlib combination.

      I would try posting the question on the RTEMS users mailing list, or perhaps asking on the RTEMS IRC.

      hope this helps,

  9. New to git, and the operation generated the following:
    ~/development/rtems> git clone git://
    Cloning into 'rtems-source-builder'...
    fatal: remote error: access denied or repository not exported: /chrisj/rtems-source-builder.git


    1. Sorry, the directions are getting old. I really need to update.
      git clone git://

      When you build the tools using RSB, make sure you substitute 4.12 for 4.11 in my instructions. The RTEMS git repository defaults to RTEMS 4.12 now and you need to build the 4.12 tools to make RTEMS compile correctly. I recently did this and tested it on my Raspberry Pi ( Model A+ and Zero )

      Same applies to building RTEMS itself, substitute 4.11 with 4.12 like this:
      ../rtems-git/configure --target=arm-rtems4.12 \
      --enable-rtemsbsp="raspberrypi2 raspberrypi" \
      --enable-tests=samples \
      --enable-networking \
      --enable-posix \

      I'm going to try to work on updating all of the instructions soon.

  10. hello sir
    The above link to the source builder documentation you provided is not working.It would be great help if u provide the source builder documentation link.

    1. Hi,
      Sorry my instructions are out of date. The new RTEMS master is now called 5 instead of 4.12, and here is the link to the RSB docs:

      Also, note that the latest Raspberry Pi firmware on the SD card is not compatible with RTEMS. I had to use a tag of the RPI firmware that is about 1 year old. I'll try to dig up the exact tag, but you can try this one:

  11. hello sir,
    I am new to rtems RTOS but very much interested in learning about rtems and how to port it onto raspberry pi board. If you could guide me with steps for building a rtems kernel image for pi board, it would be a great help for me.

    Thank you

  12. This comment has been removed by a blog administrator.

  13. I like your blog, I read this blog please update more content on python, further check it once at python online training

  14. This comment has been removed by a blog administrator.

  15. This comment has been removed by the author.

    1. Sorry I missed your question. I had been meaning to get back to you. The best way to build for windows is to follow the latest guide:

      They have Windows specific info here:

      But I have just been trying Windows Subsystem For Linux 2 (WSL2) on Windows 10 and other than fixing the PATH environment variable, it builds the RTEMS tools just like Ubuntu.

  16. This comment has been removed by a blog administrator.

  17. This comment has been removed by a blog administrator.

  18. This comment has been removed by a blog administrator.

  19. This comment has been removed by a blog administrator.

  20. This comment has been removed by a blog administrator.

  21. This comment has been removed by a blog administrator.

  22. This comment has been removed by a blog administrator.