Friday, March 29, 2013

Compiling and installing RTEMS for the Raspberry Pi

Compiling and installing RTEMS for the Raspberry Pi

OK, The RTEMS compiler is ready to go on your Ubuntu machine, so it’s time to download and build RTEMS for the Raspberry Pi.

If you have not installed the compiler, then go back and follow that step


Step 1: Download and Prepare RTEMS:

Start by check out the RTEMS head build from the git repository

$ cd $HOME/development/rtems
$ git clone git://git.rtems.org/rtems.git rtems-git

Before RTEMS can be built, the autotools scripts must be generated ( Don’t forget the ./ in front of bootstrap )

$ cd rtems-git
$ ./bootstrap

Now, RTEMS is ready to build for the Pi. When you compile RTEMS, you choose the architecture, Board Support Package (BSP) and a few other options such as POSIX API, networking, etc. When you compile RTEMS in this next step, you are not really compiling something you run on the Pi just yet. You are compiling all of the operating system libraries, drivers, and installing them along with the headers. When you build your own RTEMS application, you will then use these headers and libraries.


Step 2: Configure RTEMS:

$ cd $HOME/development/rtems
$ mkdir build-rtems-rpi
$ cd build-rtems-rpi

To build RTEMS for the Raspberry Pi use the following command:

$ ../rtems-git/configure --target=arm-rtems4.11 \
--enable-rtemsbsp=raspberrypi \
--enable-tests=samples \
--enable-networking \
--enable-posix \
--prefix=$HOME/development/rtems/bsps/4.11

When this step is is complete you should see something like this:

target architecture: arm.
available BSPs: raspberrypi.
'make all' will build the following BSPs: raspberrypi.
other BSPs can be built with 'make RTEMS_BSP="bsp1 bsp2 ..."'

config.status: creating Makefile

Step 3: Now, build and install:

$ make install

When the make and make install is complete, the RTEMS libraries, headers, and some sample programs are in:

$HOME/development/rtems/bsps/4.11/arm-rtems4.11/raspberrypi

All of these directories may seem a little complicated, but it starts to make sense when you want to have different RTEMS versions, different architectures, and different BSPs all on the same development machine, without getting anything mixed up.

So now you have a cross compiler, and have RTEMS compiled and installed, so what about getting an RTEMS program to actually run on the Pi ?

Next: Run an RTEMS program on the Raspberry Pi

18 comments:

  1. I blocked here:
    To build RTEMS for the Raspberry Pi use the following command:
    $ ../rtems-git/configure --target=arm-rtems4.11 \
    --enable-rtemsbsp=raspberrypi \
    --enable-tests=samples \
    --enable-networking \
    --enable-posix \
    --prefix=$HOME/development/rtems/bsps/4.11

    because in the building process for MacOSX on a MBpro5.5 (and not for raspi!!!) I'm not shure for one parameter:
    To build RTEMS for the mac use the following command:
    $ ../rtems-git/configure --target=i386-rtems4.11 \
    --enable-rtemsbsp=??? \
    --enable-tests=samples \
    --enable-networking \
    --enable-posix \
    --prefix=$HOME/development/rtems/bsps/4.11

    I read
    http://www.rtems.org/ftp/pub/rtems/people/chrisj/source-builder/source-builder.html
    and there is no reference for i386 or similia
    Can suggest me ?
    Thanks

    ReplyDelete
    Replies
    1. It depends on your target board:
      The 386 has a number of BSPs available:
      http://wiki.rtems.org/wiki/index.php/BoardSupportPackageInformation#Intel_i386.2C_Pentium.2C_and_Clone_CPUs_BSPs

      Most likely if you want to run on QEMU, then choose pc386

      Also, if you leave off the --enable-rtemsbsp parameter, you will be given a list of all available BSPs for that architecture. If you just typed make, it would build them all!

      Delete
  2. the configure step apparently works fine...but unfortunatly not the make install.
    the std_out:
    Making install in i386-rtems4.11/c
    Making install in .
    Configuring RTEMS_BSP=pc386
    checking for gmake... no
    checking for make... make
    checking build system type... x86_64-apple-darwin11.4.2
    checking host system type... i386-pc-rtems4.11
    checking rtems target cpu... i386
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for i386-rtems4.11-strip... i386-rtems4.11-strip
    checking for a thread-safe mkdir -p... ../../../../rtems-git/c/src/../../install-sh -c -d
    checking for gawk... no
    checking for mawk... no
    checking for nawk... no
    checking for awk... awk
    checking whether make sets $(MAKE)... yes
    checking whether to enable maintainer-specific portions of Makefiles... no
    checking for RTEMS_BSP... pc386
    checking whether BSP supports networking... yes
    checking whether CPU supports libposix... yes
    configure: setting up make/custom
    configure: creating make/pc386.cache
    checking for RTEMS_CPU_MODEL... i386_fp
    checking for RTEMS_BSP_FAMILY... pc386
    checking for CPU_CFLAGS... (cached) -mtune=i386
    checking for CFLAGS_OPTIMIZE_V... (cached) -O2 -g
    checking for style of include used by make... GNU
    checking for i386-rtems4.11-gcc... i386-rtems4.11-gcc
    checking for i386-rtems4.11-gcc... (cached) i386-rtems4.11-gcc
    checking whether the C compiler works... no
    configure: error: in `/Users/saro/development/rtems/build-rtems-i386/i386-rtems4.11/c/pc386':
    configure: error: C compiler cannot create executables
    See `config.log' for more details
    make[2]: *** [pc386] Error 1
    make[1]: *** [install-recursive] Error 1
    make: *** [install-recursive] Error 1

    You believe that trying i386ex or ts_i386 the result is different ? :)

    ReplyDelete
  3. I think that the git address for download rtems is changed.
    I can't download rtems today from it!!!

    ReplyDelete
  4. I'm cloning from:
    http://git.rtems.org/amar/rtems.git/

    but I think It's intersting also:
    http://git.rtems.org/chrisj/rtems.git/

    ReplyDelete
    Replies
    1. Some of the RTEMS members maintain their own test or experimental git repositories. I would not use either one of those as the RTEMS source release.

      Also, it you have any trouble with the RTEMS projects or want to ask general questions, feel free to join and use the RTEMS mailing list:
      http://rtems.org/wiki/index.php/RTEMSMailingLists

      You can find help there for just about any RTEMS issue.

      Delete
  5. Hi!

    According to instructions I built and installed RTEMS for Raspberry Pi on CentOS.
    All steps seem to work fine but at the final step when I want to "make install" following errors occurs:

    In function 'newlib_create_hook':
    ../../../../../../rtems-git/c/src/../../cpukit/libcsupport/src/newlibc_reent.c:44:12: error: lvalue required as left operand of assignment
    _REENT = _GLOBAL_REENT;
    ^
    ../../../../../../rtems-git/c/src/../../cpukit/libcsupport/src/newlibc_reent.c:46:29: error: lvalue required as unary '&' operand
    _Thread_Set_libc_reent (&_REENT);
    ^
    gmake[4]: *** [src/libcsupport_a-newlibc_reent.o] Error 1
    gmake[4]: Leaving directory `/home/rtems/development/rtems/build-rtems-rpi/arm-rtems4.11/c/raspberrypi/cpukit/libcsupport'
    gmake[3]: *** [install-recursive] Error 1
    gmake[3]: Leaving directory `/home/rtems/development/rtems/build-rtems-rpi/arm-rtems4.11/c/raspberrypi/cpukit'
    gmake[2]: *** [install-recursive] Error 1
    gmake[2]: Leaving directory `/home/rtems/development/rtems/build-rtems-rpi/arm-rtems4.11/c/raspberrypi'
    gmake[1]: *** [install-recursive] Error 1
    gmake[1]: Leaving directory `/home/rtems/development/rtems/build-rtems-rpi/arm-rtems4.11/c'
    make: *** [install-recursive] Error 1
    [root@localhost build-rtems-rpi]# make install -> OUTPUT.txt
    ../../../../../../rtems-git/c/src/../../cpukit/libcsupport/src/newlibc_reent.c: In function 'newlib_create_hook':
    ../../../../../../rtems-git/c/src/../../cpukit/libcsupport/src/newlibc_reent.c:44:12: error: lvalue required as left operand of assignment
    _REENT = _GLOBAL_REENT;
    ^
    ../../../../../../rtems-git/c/src/../../cpukit/libcsupport/src/newlibc_reent.c:46:29: error: lvalue required as unary '&' operand
    _Thread_Set_libc_reent (&_REENT);
    ^
    gmake[4]: *** [src/libcsupport_a-newlibc_reent.o] Error 1
    gmake[3]: *** [install-recursive] Error 1
    gmake[2]: *** [install-recursive] Error 1
    gmake[1]: *** [install-recursive] Error 1
    make: *** [install-recursive] Error 1

    please help me!

    ReplyDelete
    Replies
    1. Same error here. Do you have some advices?

      Delete
    2. I will take a look and see if I can duplicate the problem.
      My instructions are due for updates anyway!

      Delete
  6. This comment has been removed by the author.

    ReplyDelete
  7. I try to make this


    $ make install

    but I have a error..
    Please, help me ...

    fatal error: sys/select.h: No such file or directory



    In file included from ../../../../cpukit/../../../raspberrypi/lib/include/rpc/rpc.h:62:0,
    from ../../../../../../../../rtems-git/c/src/../../cpukit/libfs/src/nfsclient/src/rpcio.c:77:
    ../../../../cpukit/../../../raspberrypi/lib/include/rpc/svc.h:46:37: fatal error: sys/select.h: No such file or directory
    #include /* fd_set */
    ^
    compilation terminated.
    Makefile:547: recipe for target 'src/libnfs_a-rpcio.o' failed
    make[5]: *** [src/libnfs_a-rpcio.o] Error 1
    make[5]: Leaving directory '/home/wmlab/development/rtems/build-rtems-rpi/arm-rtems4.11/c/raspberrypi/cpukit/libfs/src/nfsclient'
    Makefile:1450: recipe for target 'install-recursive' failed
    make[4]: *** [install-recursive] Error 1
    make[4]: Leaving directory '/home/wmlab/development/rtems/build-rtems-rpi/arm-rtems4.11/c/raspberrypi/cpukit/libfs'
    Makefile:969: recipe for target 'install-recursive' failed
    make[3]: *** [install-recursive] Error 1
    make[3]: Leaving directory '/home/wmlab/development/rtems/build-rtems-rpi/arm-rtems4.11/c/raspberrypi/cpukit'
    Makefile:425: recipe for target 'install-recursive' failed
    make[2]: *** [install-recursive] Error 1
    make[2]: Leaving directory '/home/wmlab/development/rtems/build-rtems-rpi/arm-rtems4.11/c/raspberrypi'
    Makefile:286: recipe for target 'install-recursive' failed
    make[1]: *** [install-recursive] Error 1
    make[1]: Leaving directory '/home/wmlab/development/rtems/build-rtems-rpi/arm-rtems4.11/c'
    Makefile:410: recipe for target 'install-recursive' failed
    make: *** [install-recursive] Error 1
    wmlab@ubuntu:~/development/rtems/build-rtems-rpi$ ls

    ReplyDelete
    Replies
    1. I have figured this out.. These instructions are getting old and need to be updated.

      Now the default RTEMS git head is 4.12, not 4.11.

      RTEMS 4.11 is a branch on the git repository.

      So to work with these instructions and the 4.11 tools built with the RSB, just go into the RTEMS git repository, and run :
      git checkout origin/4.11
      You may have to do a ./bootstrap -c first to clean out the autoconf files.

      If you want to move to the latest 4.12 work ( which I am doing ), you need to rebuild a set of tools using RSB, substituting 4.12 for the 4.11 in the source builder command.

      I hope to update these instructions soon to make it clearer.

      Delete
  8. I've the same problem as Two Star

    ReplyDelete
  9. I've the same problem as TwoStar, have you found a solution?

    ReplyDelete
    Replies
    1. Yes, please see my comment above.

      Delete
    2. Hi Alan, thank you it seems working.

      I've generated the ticker kernel image file. Now I tried to build the rki but I've this error
      I I'm trying to build rki but I've this error:

      ubuntu@ubuntu-VirtualBox:~/development/rki$ make
      arm-rtems4.11-gcc -Wa,-a=legacy-build/arm-rtems4.11-raspberrypi/init.lis -mcpu=arm1176jzf-s -D__ARM__ -Wall -I. -Iinclude/ -I. -g -O2 -c -o legacy-build/arm-rtems4.11-raspberrypi/init.o init.c
      init.c:23:24: fatal error: netinet/in.h: No such file or directory
      #include
      ^
      compilation terminated.
      make: *** [init.o] Errore 1

      Coul you, please, help me?

      Delete
    3. I was able to build the rki image by changing the makefile to refer to 4.12 instead of 4.11

      RTEMS_TOOL_BASE ?= /Users/alan/rtems/4.12
      RTEMS_BSP_BASE ?= /Users/alan/rtems/4.12

      ARCH ?= arm-rtems4.12

      --
      I'll try to push these changes to the git repository soon.

      Delete
    4. Hi Alan , I did the whole instruction with 4.12 and also i got the same error. I thought it was a prefix problem i changed it and then no problem but the make instruction dont do anything it enters and leaves directories :
      Making all in tools/build
      gmake[1]: Entering directory `/mnt/D/development/rtems/kernel/zynq/tools/build'
      gmake all-am
      gmake[2]: Entering directory `/mnt/D/development/rtems/kernel/zynq/tools/build'
      gmake[2]: Leaving directory `/mnt/D/development/rtems/kernel/zynq/tools/build'
      gmake[1]: Leaving directory `/mnt/D/development/rtems/kernel/zynq/tools/build'
      Making all in tools/cpu
      gmake[1]: Entering directory `/mnt/D/development/rtems/kernel/zynq/tools/cpu'
      Making all in generic
      gmake[2]: Entering directory `/mnt/D/development/rtems/kernel/zynq/tools/cpu/generic'
      gmake[2]: Nothing to be done for `all'.
      gmake[2]: Leaving directory `/mnt/D/development/rtems/kernel/zynq/tools/cpu/generic'
      gmake[2]: Entering directory `/mnt/D/development/rtems/kernel/zynq/tools/cpu'
      gmake[2]: Nothing to be done for `all-am'.
      gmake[2]: Leaving directory `/mnt/D/development/rtems/kernel/zynq/tools/cpu'
      gmake[1]: Leaving directory `/mnt/D/development/rtems/kernel/zynq/tools/cpu'
      Making all in testsuites/tools
      gmake[1]: Entering directory `/mnt/D/development/rtems/kernel/zynq/testsuites/tools'
      Making all in generic
      gmake[2]: Entering directory `/mnt/D/development/rtems/kernel/zynq/testsuites/tools/generic'
      gmake[2]: Nothing to be done for `all'.
      gmake[2]: Leaving directory `/mnt/D/development/rtems/kernel/zynq/testsuites/tools/generic'
      gmake[2]: Entering directory `/mnt/D/development/rtems/kernel/zynq/testsuites/tools'
      gmake[2]: Nothing to be done for `all-am'.
      gmake[2]: Leaving directory `/mnt/D/development/rtems/kernel/zynq/testsuites/tools'
      gmake[1]: Leaving directory `/mnt/D/development/rtems/kernel/zynq/testsuites/tools'
      Making all in c
      gmake[1]: Entering directory `/mnt/D/development/rtems/kernel/zynq/c'
      Making all in .
      gmake[2]: Entering directory `/mnt/D/development/rtems/kernel/zynq/c'
      gmake[2]: Nothing to be done for `all-am'.
      gmake[2]: Leaving directory `/mnt/D/development/rtems/kernel/zynq/c'
      gmake[1]: Leaving directory `/mnt/D/development/rtems/kernel/zynq/c'
      gmake[1]: Entering directory `/mnt/D/development/rtems/kernel/zynq'
      gmake[1]: Nothing to be done for `all-am'.
      gmake[1]: Leaving directory `/mnt/D/development/rtems/kernel/zynq'

      Have you a solution for this thanks

      Delete