Link Search Menu Expand Document

Waf Based Build System for RTEMS (June 24 2020 Week 4)

RTEMS 5 which is currently the version of the master branch as of writing this post uses a GNU Autotools based build system. Autotools is suite of the following softwares that help in configuring, building and installing a software

  • automake
  • autoconf
  • make

Most of us who have been contributing to open source based on languages like C and C++ must definitely be familiar with Make.

Make (GNU Make) is a tool which controls the generation of executables and other non-source files of a program from the program’s source files.

Make gets its knowledge of how to build your program from a file called the makefile, which lists each of the non-source files and how to compute it from other files.

For a project like RTEMS writing Makefile is not easy since it has to support multiple BSPs, different configuration for the same BSPs and soon this will require the user to edit the Makefiles or in a bad case have duplicates for different configurations of the same BSP.

To avoid this clutter people have come up with the complementary tools automake and autoconf.

Autoconf allows us to specify configuration files(configure.ac) which it then uses to configure the software, generate header files, makefiles etc. Eg for configuration files can be found under $RTEMS/c. These files have a file extension ac.

Automake uses information from Makefile.am to generate Makefile.in which is then used by the scripts generated by Autoconf to generate the Makefile.

Though these tools make building, configuring and installing software easy they tend to get complex with large softwares and this is the case with RTEMS and thus we are moving to a more modern build system.

Waf is modern python based build system that is going to replace the autotools based build system in RTEMS. Though this build system is almost ready to be merged with the master branch it is not yet done as of writing this.

The following steps will build RTEMS Beaglebone BSP using the waf build system

Building the toolchain

To use the new build we will have to build the RTEMS6 toolchain since the new build system is planned to be merged with RTEMS6. We will using RSB to build the toolchain. And since we are building the Beaglebone BSP we will be building the ARM toolchain.

$RSB: The directory where RSB is cloned to. $PREFIX: The prefix directory. $RTEMS: The directory where RTEMS source exists.

$ cd $RSB/rtems
$ ../source-builder/sb-set-builder --prefix=$PREFIX/rtems/6 6/rtems-arm

You can confirm that the toolchain is built properly by running the following command.

$ $PREFIX/rtems/6/bin/arm-rtems6-gcc --version

If this above command results in a valid GCC version output then it means you have configured your toolchain properly. An invalid configuration will result in something like Command not found.

Cloning the RTEMS source

As of writing this post, the new build system is not yet merged upstream hence we will be checking out a branch from Sebastian’s (Created the new build system) private RTEMS repo.

You can follow the below commands to pull in the private branch.

$ cd $RTEMS
$ git remote add sebh git://git.rtems.org/sebh/rtems.git
$ git pull sebh build
$ git checkout build

This will pull the build branch from Sebastian’s private repo which contains the new build system.

Building the BSP

Once you are done pulling the build branch we continue with building the BSP of choice in our case it is the Beaglebone Black BSP.

In the RTEMS source directory make sure you are checked out with the build branch.

To build the BSP follow the below commands

$ ./waf bsp_defaults --rtems-bsps=beagleboneblack
$ ./waf configure --prefix=$PREFIX
$ ./waf
$ ./waf install

This will build the BSP and install it into the prefix. Unlike the previous build system which builds the BSP outside the RTEMS source, this build system places the built BSP under $RTEMS/build

You can refer to the following documents for more information about the build system