beaglebone black, rtems,

Getting started with RTEMS on Beaglebone black - part II

Vijay K. Banerjee (thelunatic) Vijay K. Banerjee (thelunatic) May 10, 2019 · 4 mins read
Getting started with RTEMS on Beaglebone black - part II
Share this

In the part I of this Getting started walkthrough, we have seen the steps of building the rtems source for the beagleboneblack Board Support Package (BSP). In this part we’ll use the hello.exe from the testsuite, make it into an SD card image and run it in original BBB hardware.

Generating the RTEMS image

Firstly, we’ll need u-boot to boot the image into the hardware. We’ll be using a recent version of U-Boot for the process. We need to use the mkimage from u-boot to create the bootable image.

Once we have the hello.exe from beagleboneblack/arm-rtems5/c/beagleboneblack/testsuite/samples/hello.exe

we’ll make an image from it in the following steps.

arm-rtems5-objcopy hello.exe -O binary app.bin
gzip -9 app.bin
mkimage -A arm -O linux -T kernel -a 0x80000000 -e 0x80000000 -n RTEMS
-d app.bin.gz rtems-app.img

The options are for :

  • -A : Architecture
  • -O : OS
  • -T : Type of image
  • -a : load address
  • -e : entry point
  • -n : image name
  • -d : The image data file and finally the rtems-app.img is the name of the image

The uEnv.txt file

After this we can copy this img file to the Fat formatted SD card and include a uEnv.txt in the root directory with the following content

setenv bootdelay 5
uenvcmd=run boot
boot=fatload mmc 0 0x80800000 rtems-app.img ; fatload mmc 0 0x88000000
am335x-boneblack.dtb ; bootm 0x80800000 - 0x88000000

The uEnv.txt file sets any variable BEFORE the image boots, so this is the right place to tell the bootloader which files to load and the memory addr of the boot image.

The Device Tree file

It is now compulsory to use a device tree blob (dtb) file to load the device tree during bootin. So we need the am335x-boneblack.dtb file.

We’ll use a mirror to the official device-tree rebasing. We can use this link device-tree-rebasing there’s a makefile provided, we’ll just build the am335x-boneblack.dtb the command will look something like this

We will use the freebsd sources to build the required device tree blob, i.e., am335x-boneblack.dtb:

git clone
MACHINE='arm' freebsd/sys/tools/fdt/ \
freebsd/sys \
freebsd/sys/gnu/dts/arm/am335x-boneblack.dts \

Note for RTEMS libbsd users : The dtb from the following commit has been tested with libbsd: 19a6ceb89dbacf74697d493e48c388767126d418, the latest master from FreeBSD is known to have some issues with the RTEMS-libbsd apps. RTEMS apps without libbsd CAN use the latest master of freebsd.

Once we have the dtb file, we’ll again copy it into the root of the SD card that we have.

Running it in BBB

Now that we have everything set, our final step is to run it in a REAl hardware. I’m using a USB TO UART TTL 3.3V FT232RL breakout board to connect it to my computer. This, I found was the cheapest option available, you just need a few jumper cables and it’s as good as an FTDI adapter cable.

rev C of the beaglebone black tries to read uEnv.txt from microSD card using internal, factory-flashed uBoot instance on eMMC. You can follow this guide (assuming you want to prepare the microSD directly from the factory-flashed debian instance of your beaglebone black), then copy 3 files to the boot partition created: uEnv.txt, am335x-boneblack.dtb and rtems-app.img (no MLO needed).

Then we’ll install the SD card and power up everything. To access the console from computer, we’ll use screen tool for linux environment like this …

sudo screen /dev/ttyUSB0 115200

Running RTEMS hello world on BBB

And Voila! It’s running !!!

Note: If you want to flash the eMMC with new uBoot instansce, you can follow the following guide with slight modification:

alias armmake='make CROSS_COMPILE=arm-rtems5- '
armmake distclean
armmake am335x_evm_config

And then add the u-boot.img and MLO files to the SD card. That’s the end of the Getting started tutorial, I hope that I have stated the steps clearly. In case of any doubt, or if you’d like to add or discuss some point. Please do comment below.

Thanks for stopping by!