This is a quick tutorial for building ARM Toolchain, RTEMS and RTEMS LibBSD for Beaglebone Black.

If your host computer is setup as mentioned here you can continue.

Select a project directory

First choose a project root directory where you want all the RTEMS related files to go.

$ROOT=$HOME/workspace/rtems-root

This is my project root. I’ll be using $ROOT as a placeholder throughout the tutorial for convenience. Make sure to replace it with your own project root.

There are 3 main sources.

1) The RTEMS Source Builder

2) RTEMS itself

3) RTEMS LibBSD

Create a directory called src inside $ROOT to place all the source files.

1) Preparing the Toolchain

Beaglebone Black has an ARM CPU core. So we need all the tools to build an application for ARM. We can easily build these tools with RTEMS Source Builder (RSB). Let’s first clone the RSB

Get RSB

cd $ROOT/src
git clone git://git.rtems.org/rtems-source-builder.git rsb

Now select a directory where you want to build these toolchains. You can specify this directory with the --prefix option.

I’ll use $ROOT/rtems/6 as the prefix path.

$PREFIX = $HOME/workspace/rtems-root/rtems/6

Another placeholder ;)

Build ARM Toolchain

cd $ROOT/src/rsb/rtems
../source-builder/sb-set-builder --prefix=$PREFIX 6/rtems-arm

The last argument 6/rtems-arm says that we want to build the tools for the RTMES relase 6(This is the master branch version at the time of writing this post).

This wiil take some time to complete. We only have to build this ones. After the build is successfulll we can test it with the following commnad.

Test the toolsuit build

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

If you see something like the following, then the build is successfull.

arm-rtems6-gcc (GCC) 10.3.1 20210409 (RTEMS 6, RSB 4e6dc6431435821a534da6307e72ecbd7e42b82a, Newlib 0c0f3df)
Copyright (C) 2020 Free Software Foundation, Inc.
...

To add toolsuit to PATH you can add the following line in the end of .bashrc file in the home directory.

# RTEMS Toolsuite
export PATH="$PREFIX/bin:$PATH"

Make sure to add the correct value to the $PREFIX

2) Building RTEMS

Toolsuit PATH should be in the environment before building RTEMS.

To test toolsuit path

command -v arm-rtems6-gcc && echo "found" || echo "not found"

If the toolsuit is not found, check the lines you added to the .bashrc. Verify that you have added the correct path value there.

Clone the source files

cd $ROOT/src
git clone git://git.rtems.org/rtems.git

Configure the BBB BSP

cd $PREFIX/src/rtems

echo "[arm/beagleboneblack]" > config.ini
echo "BUILD_TESTS = True" >> config.ini
echo "RTEMS_POSIX_API = True" >> config.ini

./waf configure --prefix=$HOME/workspace/rtems-root/rtems/6

RTEMS_POSIX_API should be enabled to build the LibBSD later. See here for more Waf configuration options.

Build the BSP

./waf

All built files will be in $PREFIX/src/rtems/build/ directory.

Install the BSP

./waf install

Installing RTEMS copies the API headers and architecture specific libraries to a locaiton under the prefix you provide.[1]

At this point you have applications which can run on the Beaglbone Black. (Ex: hello.exe) See the $PREFIX/src/rtems/build/arm/beagleboneblack/testsuites/samples directory.

3) Building RTEMS BSD Library (LibBSD)

To build rtems-libbsd first we must have built the RTEMS with RTEMS_POSIX_API enabled and installed it to the $PREFIX as shown above.

Clone RTEMS LibBSD

cd $ROOT/src
git clone git://git.rtems.org/rtems-libbsd.git

Change directory into cloned repository and initialize only the rtems_waf if not the FreeBSD kernel source will be cloned.

cd $ROOT/src/rtems-libbsd
git submodule init
git submodule update rtems_waf

Configure Waf build

./waf configure --prefix="$ROOT/rtems/6" --rtems-bsps=arm/beagleboneblack --buildset=buildset/default.ini

If you didn’t enable the RTEMS kernel POSIX support earlier when building RTEMS, the LibBSD won’t build.

Build and install.

./waf
./waf install

The LibBSD package will be installed into the prefix provided to configure.

That’s it! Now you have successfully built the RTEMS LibBSD for Beaglebone Black.

Try running a testsuit on BBB.
Ex: telnet01.exe
See the $PREFIX/src/rtems-libbsd/build/arm-rtems6-beagleboneblack-default directory.

Following is the directory structure we now have.

$ROOT
├── rtems
│   └── 6
│       ├── arm-rtems6
│       ├── bin
│       ├── include
│       ├── lib
│       ├── libexec
│       ├── make
│       └── share
├── src
│   ├── rsb
│   │   ├── rtems
│   │   └── source-builder
│   ├── rtems
│   ├── rtems-libbsd

Resource

RTEMS LibBSD README

Getting started with RTEMS on Beaglebone black - part I

  • NOTE: This guide builds rtems-5 with the Autoconf/Automake based build system. RTEMS now uses Waf as it’s new build system.

You might need the master branch if you intend to develop and contribute. At the time of writing this post, the master is on rtmes 6.

You can refer the official RTEMS Quick Start Gudie which is for SPARC architecture. Mostly you only have to replace SPARC with ARM.
Ex: 6/rtems-sparc to 6/rtems-arm So the toolchain build command using RSB will be as follows(prefix will differ for you),

../source-builder/sb-set-builder --prefix=$ROOT/rtems/6 6/rtems-arm