Revision as of 21:01, 4 August 2017 by Ttsiodras (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To be able to build RTEMS applications, you need to build a cross-development toolchain as well as RTEMS itself. Other tools might also be useful, especially for debugging purposes. Hopefully, we provide scripts that automate the installation of both cross-development toolchain and RTEMS itself. The following tools would be installed: automake/autoconf (configuration tools), binutils and GCC with newlib (compiler), GDB (for debugging).

The following sections provide guidance to build everything and use RTEMS.

Getting our scripts

You can get the scripts on our current subversion repository at the following address : https://tecsw.estec.esa.int/svn/taste/trunk/misc/rtems-scripts

To checkout the scripts, issue the following command

svn co https://tecsw.estec.esa.int/svn/taste/trunk/misc/rtems-scripts

The README file in the repository is a good start to get information about the build process.

Configuring your environment

Then, edit the env file related to your environment. Change the following variables in the file: - BUILD_DIR - INSTALL_DIR - INSTALL_DIR - ARCH - BUILD_ARCH - BUILD_BSP - USE_BSP

Once it is done, source the files in your environment to define the variables. You have to do that for each shell that will use your cross-compilation toolchain later.

Building the toolchain

Then, you have to invoke the scripts in the following order:

  • fetch_rtems_source.sh
  • build_autoconf.sh
  • build_automake.sh
  • build_binutils_rtems.sh
  • build_gmp.sh
  • build_mpfr.sh
  • build_mpc.sh
  • build_gcc_native.sh
  • build_gcc_rtems_c_only.sh
  • build_rtems.sh
  • build_gcc_rtems.sh
  • build_gdb.sh

Example: build RTEMS 4.11 for the i386 target

  1. Edit the rtems_4.11.env file and change the INSTALL_DIR and BUILD_DIR variables to match your system configuration
  2. Edit the rtems_4.11.env file and set the variable values: ARCH="i386" ; BUILD_BSP="pc386" ; USE_BSP="pc386" ; BUILD_ARCH=i386
  3. Source the file
    source rtems_4.11.env
  4. Make a checkout of the current RTEMS revision in BUILD_DIR/rtems-4.11/rtems:
    cd $BUILD_DIR/rtems-$RTEMS_VERSION/ && git clone http://git.rtems.org/rtems rtems
  5. Invoke the scripts

Finally, you should have the directory INSTALL_DIR with the toolchain. You should at least have a file called $INSTALL_DIR/i386-rtems4.11/pc386/Makefile.inc.

To use RTEMS, you should first set the RTEMS_MAKEFILE_PATH to $INSTALL_DIR/i386-rtems4.11/pc386/Makefile.inc. You can do that using the following command :

export RTEMS_MAKEFILE_PATH=$INSTALL_DIR/i386-rtems4.11/pc386/Makefile.inc

Testing your installation

You can test your installation by compiling a small example from the RTEMS tests. To do so, please perform the following procedure:

  1. Checkout RTEMS examples from RTEMS repository
    git clone http://git.rtems.org/examples-v2 examples
  2. Make sure the RTEMS_MAKEFILE_PATH variable is defined. For example, for the pc386 BSP, this can be set by performing the following command:
    export RTEMS_MAKEFILE_PATH=$INSTALL_DIR/i386-rtems4.11/pc386/Makefile.inc
  3. Go to the hello/hello_world_c directory and invoke make. If successful, the build process would produce an o-optimize directory with files called hello.exe and hello.bin. This corresponds to the complete application code with RTEMS.

[julien@minerva]/home/julien/tmp/examples/hello/hello_world_c#make     20:49:36
test -d o-optimize || mkdir o-optimize
i386-rtems4.11-gcc --pipe -B/home/julien/local/packages/rtems-4.11/i386-rtems4.11/pc386/lib/ -specs bsp_specs -qrtems   -g -Wall  -O2 -g -g    -mtune=i386     -c   -o o-optimize/test.o test.c
i386-rtems4.11-gcc --pipe -B/home/julien/local/packages/rtems-4.11/i386-rtems4.11/pc386/lib/ -specs bsp_specs -qrtems   -g -Wall  -O2 -g -g    -mtune=i386     -Wl,-Ttext,0x00100000   -mtune=i386   -o o-optimize/hello.exe  o-optimize/test.o       
i386-rtems4.11-nm -g -n o-optimize/hello.exe > o-optimize/hello.num
i386-rtems4.11-size o-optimize/hello.exe
   text    data     bss     dec     hex filename
 182341   10288   10692  203321   31a39 o-optimize/hello.exe
i386-rtems4.11-objcopy -O elf32-i386 --remove-section=.comment --remove-section=.note --strip-unneeded o-optimize/hello.exe o-optimize/hello.nxe
i386-rtems4.11-objcopy -O binary o-optimize/hello.nxe o-optimize/hello.bin
/home/julien/local/packages/rtems-4.11/i386-rtems4.11/pc386/build-tools/bin2boot -v o-optimize/hello.ralf 0x00097E00 /home/julien/local/packages/rtems-4.11/i386-rtems4.11/pc386/lib/start16.bin 0x00097C00 0 o-optimize/hello.bin 0x00100000 0
header address       0x00097e00, its memory size 0x00000200
first  image address 0x00097c00, its memory size 0x00000200
second image address 0x00100000, its memory size 0x00030200
rm -f o-optimize/hello.nxe

Other resources