Code Confidence technical note 0003 - Building GNU tools for use with eCos

This technical note describes the configuration and building of GNU toolchain components for use in the development of eCos® applications. It is intended for developers who are familiar with the process of building GNU software and require specific guidance on configuration of the tools for use with the eCos real-time operating system. The Code Confidence Tools include pre-built GNU tools for all validated target architectures and use of these tools is recommended where available. In cases where the complilation of eCos for another architecture is required or the use of a specific version of a GNU tool is mandated, the following steps (based on eCos 3.0 and GCC 4.3.2) may be used to generate an appropriate toolchain.

The building of eCos and eCos applications requires GNU tools provided by the following packages:

binutilsThe GNU binary utilities - including assembler and linker tools
gcc-coreThe GNU compiler collection - core components
gcc-g++The GNU compiler collection - C++ language component
gdbThe GNU debugger

These packages may be downloaded from a local GNU mirror site. The following sections assume that the source code of each package has been extracted into the /var/local/src directory hierarchy and that the tools will be built in the /var/local/build directory hierarchy. If any patches are required, these should be applied to the source code at this stage.

Before proceeding, the required target identifier for the toolchain must be determined. Appropriate target identifiers for the more popular eCos target architectures are shown in the following table:

Target architectureGNU target identifier
ARM® (ARM7, ARM9®, Cortex™-M, XScale®)arm-eabi
H8 (H8/300H, H8S)h8300-elf
Intel® x86 (IA32)i386-elf
Nios® IInios2-elf

The following build steps assume that the developer is working at a bash prompt and that the required target identifier has been assigned to the TARGET variable. For example:


Building binutils

There is no specific procedure required in configuring binutils for use with eCos. The package may be configured, built and installed from an empty build directory as follows:

    mkdir -p /var/local/build/binutils
    cd /var/local/build/binutils
    /var/local/src/binutils-version/configure --target=$TARGET --prefix=/opt/ecos/gnutools/$TARGET
    make && make install

Once the binutils have been installed, the location of the bin directory within the installation directory hierarchy should be added to the PATH before proceeding to build the compiler. The bin directory will be located at:


Building gcc

The gmp and mpfr libraries and corresponding development header files are required for building gcc. When building gcc 4.5 and later versions, the mpc library and development header files are also required. Ensure that all these libraries and headers are installed before proceeding. The gcc build system also requires access to system header files which are specific to both the target operating system and the target architecture. When using the Code Confidence Tools for eCos, these headers may be generated by first creating an eCos Configuration project based on the default Packages Template and a Hardware Template of the appropriate architecture. The precise hardware template used is not important. The eCos File IO package (CYGPKG_IO_FILEIO) should be added to the new configuration. A new Make Target named headers should then be created for the new project and built. On completion of the build, the required headers will be located in the include directory hierarchy within the project (eg /home/myuserid/myworkspace/myproject/include). This directory hierarchy must be copied into the GNU tools installation directory hierarchy as part of the configuration procedure. The include directory becomes the sys-include directory within the GNU tools installation:

    mkdir -p /opt/ecos/gnutools/$TARGET/$TARGET
    cp -r /home/myuserid/myworkspace/myproject/include /opt/ecos/gnutools/$TARGET/$TARGET/sys-include

The gcc package may then be configured, built and installed from an empty build directory as follows:

    mkdir -p /var/local/build/gcc
    cd /var/local/build/gcc
    /var/local/src/gcc-version/configure --target=$TARGET --prefix=/opt/ecos/gnutools/$TARGET --with-newlib --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --enable-threads --disable-hosted-libstdcxx --disable-__cxa_atexit
    make && make install

Note: The newlib package is not required and should not be used when building gcc for use with eCos. The --with-newlib configuration switch is specified to ensure that the eCos header files are referenced in a similar manner to newlib headers.

Building gdb

To ensure full functionality, the expat library and corresponding development header files are required for building gdb. Ensure that this library and headers are installed before proceeding. The gdb package may then be configured, built and installed from an empty build directory as follows:

    mkdir -p /var/local/build/gdb
    cd /var/local/build/gdb
    /var/local/src/gdb-version/configure --target=$TARGET --prefix=/opt/ecos/gnutools/$TARGET --with-expat
    make && make install

Once gdb has been installed, generation of the toolchain is complete. Back…


2021-07-26 : Code Confidence Tools for FreeRTOS updated for Eclipse 2021-06 IDE. More…
2020-12-04 : Code Confidence Tools for eCos updated for Eclipse 2020-09 IDE. More…
2015-10-02 : Hard fault exception decoding added to Code Confidence Tools for FreeRTOS. More…
2012-11-19 : Lauterbach TRACE32 PowerTools validation with Code Confidence Tools for eCos. More…