RTEMS workflow on a STM32F4 Nucleo board

This post describes the workflow I use to build RTEMS applications for a STM32F429ZI Nucleo board. I am using RTEMS 5 with the included stm32f4 BSP.

Obtaining the sources and building the ARM architecture toolchain

We are using the RTEMS source builder (RSB) and RTEMS kernel version 5, i.e. branch 5 needs to be checked out on both the rsb and rtems repos:

mkdir -p $HOME/dev_rtems/bsps
mkdir -p $HOME/dev_rtems/tools
mkdir -p $HOME/dev_rtems/src
cd $HOME/dev_rtems/src
git clone git://git.rtems.org/rtems-source-builder.git rsb
git clone git://git.rtems.org/rtems.git rtems

# Verify the RSB
cd $HOME/dev_rtems/src/rsb
git checkout 5

# Build the toolchain for the ARM architecture
cd $HOME/dev_rtems/src/rtems
git checkout 5
../source_builder/sb-set-builder --prefix=$HOME/dev_rtems/tools/5 5/rtems-arm

Bootstrapping and building the stm32f4 bsp

The bases for the F4 bsp is the STM32F407VGT6. Our STM32F429ZI has more RAM and its flash is located at 0x08000000. These changes need to be added to the linker configuration file, $HOME/dev_rtems/src/rtems/bsps/arm/stm32f4/start/linkcmds.stm32f4:

RAM_INT : ORIGIN = 0x20000000, LENGTH = 192k
ROM_INT : ORIGIN = 0x08000000, LENGTH = 2048k

Furthemore, we want to use UART2 for console output instead of the default UART3. This needs to be set within $HOME/dev_rtems/src/rtems/bsps/arm/stm32f4/start/start-config-io.c and $HOME/dev_rtems/src/rtems/c/src/lib/libbsp/arm/stm32f4/configure.ac. Now we are ready to build our bsp:

cd $HOME/dev_rtems/src/rtems
export PATH=$HOME/dev_rtems/tools/5/bin:"$PATH"
cd $HOME/dev_rtems/src/rtems
./bootstrap -c && ./rtems-bootstrap

# Build the stm32f4 bsp
cd $HOME/dev_rtems/bsps/5
$HOME/dev_rtems/src/rtems/configure --prefix=$HOME/dev_rtems/tools/5 --target=arm-rtems5 --enable-rtemsbsp=stm32f4 --enable-posix --disable-networking --enable-tests=samples --enable-maintainer-mode
make all
make install

Compiling an application

We are using the example programs from the rtems-examples repository. It is easy to start with one of the examples as a base for building our own RTEMS application.

cd $HOME/dev_rtems/src
git clone https://git.rtems.org/rtems-examples/ rtems-examples
cd rtems-examples
export RTEMS_MAKEFILE_PATH=$HOME/dev_rtems/bsps/5/arm-rtems5/c/stm32f4/make

We are flashing our Nucleo board using gdb through a Black Magic probe. The examples work producing printf output through UART2. Time to start experimenting with RTEMS!

Leave a Comment