wiki:TBR/UserManual/RTEMSAda

Version 45 (modified by Guerby, on Jul 8, 2007 at 6:27:00 PM) (diff)

/* Autotools (1 minute) */ add links to autoconf/make GNU sources

RTEMSAda

GNAT/RTEMS is used to refer to the configuration of the GNU Ada compiler (GNAT) when used with RTEMS as the run-time environment. GNAT/RTEMS provides a very full featured Ada programming and run-time environment. An early version of GNAT/RTEMS was validated (http://sw-eng.falls-church.va.us/ajpo_databases/ada95_validated_compilers.html#67) on the SPARC/ERC32. RTEMS has long had support for the Ada programming languages with the earliest work done against gnat 2.x. In fact, the GNAT/RTEMS port predates the other ports of GNAT to embedded RTOS environments.

These instructions have been used to build GNAT/RTEMS with GCC 4.2.0 for the following target/bsp combinations with the indicated level of testing

  • arm-rtems4.8 - Ada hello world ran on edb7312 simulator
  • bfin-rtems4.8 - nothing ran
  • i386-rtems4.8 - Ada hello world ran on qemu with pc386 BSP
  • m68k-rtems4.8 - nothing ran
  • mips-rtems4.8 - Ada hello world ran on jmr3904
  • powerpc-rtems4.8 - Ada hello world and ACATS ran on psim
  • sparc-rtems4.8 - Ada hello world and ACATS ran on erc32

Laurent Guerby originally wrote these instructions using the sparc-rtems4.7 target and erc32 BSP. His times are based on a Pentium M 1.7 GHz SuSE 9.3 machine.

JoelSherrill updated these instructions on 6 July 2007. My times are based on a 2.00 Ghz T2500 Centrino Duo running Fedora Core 7. I used the RTEMS RPMs as much as possible and ONLY built the packages that were absolutely necessary. In all cases, you should use the latest patches available which correspond to shipping RPMs. These should always be in the RTEMS source code at rtems/contrib/crossrpms/patches and at ftp://ftp.rtems.com/pub/rtems/SOURCES.

As of 7 July 2007, there is a single technical issue which prevents Ada from being included in the standard RTEMS RPMs. The Ada run-time libraries are NOT built multilib. If this is resolved, then it is expected that Ada will be included in the RTEMS RPMs.

Ada Programming/ RTEMS Build Instructions

These instructions assume the following:

  • $INSTALL is the prefix for the toolchain installation
  • $TARGET is the target code (tested with TARGET=sparc-rtems4.7)
  • $BSP the RTEMS BSP (tested with BSP=erc32)

It is critical that you have a recent enough C/Ada native GCC in your $PATH. It is usually necessary to build a native C/Ada native GCC of EXACTLY the same version as the version you are building cross to target RTEMS.

Please perform each configure/make/make install in a separate empty build directory. Also set PATH=$INSTALL/bin:$PATH

Patches

Please use the latest patches available for the tool versions you are using. These should always be in the RTEMS source code at rtems/contrib/crossrpms/patches and at ftp://ftp.rtems.com/pub/rtems/SOURCES.

Autotools (1 minute)

If possible, please use the latest prebuilt autoconf and automake tools for your host and RTEMS version. As of 7 July 2007, for Fedora 7, this corresponded to:

  • rtems-4.8-automake-1.10-5.fc7
    • No Patch
  • rtems-4.8-autoconf-2.61-5.fc7
    • No Patch

The versions above may be superceded at any time. If they are not the latest when you are reading this, please be sure to check for a patch and USE it. If you are unable or unwilling to use a prebuilt binary, then follow the following instructions to build your own binaries.

mkdir b-autoconf
cd b-autoconf
../autoconf-2.61/configure --prefix=$INSTALL
make 
make install
mkdir b-automake
cd b-automake
../automake-1.19/configure --prefix=$INSTALL
make 
make install

Building binutils (3 minutes)

binutils-2.17.tar.bz2 (12MB)

Apply any patches needed. As of 7 July 2007, this was:

  • binutils-2.17-rtems4.8-20061021.diff
mkdir b-bin
cd b-bin
.../binutils-2.17/configure  --verbose --disable-nls \
--target=$TARGET --prefix=$INSTALL
make
make install

Note: It is also possible to install the binutils RPMs in a non-default location using rpm2cpio and mv.

GCC and newlib Setup

gcc-4.2.0.tar.bz2 (44MB) newlib-1.15.0.tar.gz (7.4MB)

Apply any patches needed. As of 7 July 2007, this was:

  • gcc-core-4.2.0-rtems4.8-20070613.diff
  • newlib-1.15.0-rtems4.8-20070413.diff

Be sure to patch your gcc newlib with the latest RTEMS newlib patch mentioned BEFORE linking newlib and libgloss into the gcc tree.

Add newlib and libgloss links in the gcc source top level directory.

cd .../gcc-4.2.0/
ln -s ../newlib-1.15.0/newlib ../newlib-1.15.0/libgloss .

First Build of non-multilib C Only (12 minutes)

Building GNAT is a bit idiosyncratic. You must build and install a toolset WITHOUT Ada first since building the GNAT run-time depends on at least an installed C Library. In addition, as mentioned earlier, the Ada run-time libraries are not built multilib so you must compile them with CPU dependent CFLAGS which match those required by your intended target CPU.

mkdir b-gcc1
cd b-gcc1
../gcc-4.2.0/configure --enable-threads=rtems  --with-gnu-as --disable-multilib \
  --with-gnu-ld --with-newlib  --verbose --with-system-zlib --disable-nls \
  --enable-version-specific-runtime-libs \
  --enable-languages=c --target=$TARGET --prefix=$INSTALL
make
make install

NOTE: Be sure to have a native GCC Ada compiler of the same of similar version. Otherwise, it is possibly the cross-GNAT will fail to compile with a mysterious looking error.

Build of non-multilib C and Ada (21 minutes)

mkdir b-gcc2
cd b-gcc2
../gcc-4.2.0/configure --enable-threads=rtems  --with-gnu-as --disable-multilib \
  --with-gnu-ld --with-newlib  --verbose --with-system-zlib --disable-nls \
  --enable-version-specific-runtime-libs \
  --enable-languages=c,ada --target=$TARGET --prefix=$INSTALL
make
make install

You can include c++ in the list of languages if you wish.

Or Slower Build of multilibed C, C++, and Ada (XX minutes)

Note: untested,

../gcc-4.2.0/configure --enable-threads=rtems  --with-gnu-as \
  --with-gnu-ld --with-newlib  --verbose --with-system-zlib --disable-nls \
  --enable-version-specific-runtime-libs --enable-libada \
  --enable-languages=c,c++,ada --target=$TARGET --prefix=$INSTALL
make
make install

Build RTEMS from CVS (4 minutes)

cvs -z3 -d :pserver:anoncvs@www.rtems.com:/usr1/CVS login
cvs -z3 -d :pserver:anoncvs@www.rtems.com:/usr1/CVS co rtems
cd rtems
./bootstrap
autoconf
cd .../build
.../rtems/configure --disable-multilib --disable-cxx --enable-posix \
  --enable-networking \
  --target=$TARGET --prefix=$INSTALL --enable-rtemsbsp=$BSP
make
make install

Note: autoconf must be recent and include RTEMS patches.

Build GDB (4 minutes)

gdb-6.6.tar.bz2 (13MB)

Apply latest RTEMS patch for gdb version (see above)

.../gdb-6.3/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --verbose --disable-nls \
  --enable-sim --enable-sim-timebase --enable-sim-hardware \
  --target=$TARGET --prefix=$INSTALL
make
make install

Compile and Test

$ cat t.adb
with Ada.Text_IO;
procedure T is
begin
   Ada.Text''IO.Put''Line ("Hello RTEMS Ada");
end T;
$ powerpc-rtems-gnatmake -f -g t -largs -B$INSTALL/$TARGET/$BSP -specs bsp_specs -qrtems
...
$ INSTALL/powerpc-rtems/psim/tests/runtest ./t

Then look in log/t.

Note1: It appears that gnat (gcc 4.2.0) is mangling target names with periods in them. CPU-rtems4.7 is turning into CPU-rtems4.

Note2: It appears that gnat (gcc 4.1 CVS) is always looking for the cross tools in /usr/bin. Unchecked in 4.2.0.

Old Build Instructions with GCC 3.2

make
make -C gcc cross-gnattools
make -C gcc ada.all.cross
make -C gcc GNATLIBCFLAGS="${GNATLIBCFLAGS}" gnatlib
make install