RTEMS is a Real Time Operating System (RTOS) created in 1980 that is still used nowadays, for example in the space industry.
Initially meaning "Real Time Executive for Missile Systems" it later changed into "Real Time Executive for Military Systems" and nowadays is "Real Time Executive for Multiprocessor Systems". RTEMS is open-source and free.
At the moment of writing, release 6.1 is the latest and release 7 is coming soon. This project uses RTEMS 6.1
RTEMS supports a range of CPUs and architectures, including ARM, SPARC, PowerPC, etc. The support for AARCH64 is relatively recent and due to the increasing usage of ZynqMP in space applications, I am interested in this development.
How to start with RTEMS?RTEMS site is rtems.org where one can find the documentation, links to repositories and a small but active forum to get answers. The main document to get started is the RTEMS User Manual.
To work with RTEMS, a number of folders are needed for the different sources and tools. I am using Ubuntu 22.04 and I created the folder structure below.
$HOME
└── dev
└── rtems
└── compTo do that, run this in the home folder:
mkdir -p dev/rtems/compOther folders will be created as we go, see list below.
In ~/dev/rtems folder:
git clone https://github.com/RTEMS/rtems-source-builder.gitThat will clone the repository into that folder, change into it and check out the release (branch) 6:
cd rtems-source-builder/
git checkout 6
source-builder/sb-checkThe environment can be checked with the following command
source-builder/sb-checkThat should return:
RTEMS Source Builder environment is OKStep 2. Build and install the toolchainGo to ~/dev/rtems/rtems-source-builder/rtems and run:
../source-builder/sb-set-builder --log=build-log.txt --prefix=$HOME/dev/rtems/comp/6 6/rtems-aarch64The parameters for this command are:
- -log: file name for build log
- -prefix: where the tools should be installed
last argument (6/rtems-aarch64): bsp and architecture to build for
Tools generated:
In the home folder do:
PATH=$HOME/dev/rtems/comp/6/bin:$PATH
aarch64-rtems6-gcc -vThat should return something like this:
Using built-in specs.
COLLECT_GCC=aarch64-rtems6-gcc
COLLECT_LTO_WRAPPER=/home/joan/dev/rtems/comp/6/libexec/gcc/aarch64-rtems6/13.3.0/lto-wrapperStep 4. Download and prepare RTEMS (kernel)In ~/dev/rtems, clone the rtems repository and check out release 6:
git clone https://github.com/RTEMS/rtems.git rtems-git
cd rtems-git
git checkout 6Now we can check all the bsp's available with waf:
./waf bsplistOne of them should be aarch64/zynqmp_apu and that is to be used in this project. Note that Zynq-7000 uses the arm architecture while ZynqMP uses aarch64. Also note that there are bsp for QEMU and APU as well as the ilp32 variant.
Step 5. Configure RTEMSIn ~/dev/rtems do:
mkdir build-rtems-zynqmp
cd rtems-git/
gedit config.iniOr edit config.ini with your favourite text editor. Add the following lines:
[aarch64/zynqmp_apu]
# Build the test programs
BUILD_TESTS = TrueThere are more options for the config file, one can see the whol list with the command ./waf bspdefaults
After saving and closing the file, do:
./waf configure --prefix=$HOME/dev/rtems/build-rtems-zynqmp
./waf
./waf installAnd that will install it in the indicated destination folder:
There is a number of test apps in the rtems-git folder, here I will use ticker
To build the image, in ~/dev/rtems do:
aarch64-rtems6-objcopy -Obinary $HOME/dev/rtems/rtems-git/build/aarch64/zynqmp_apu/testsuites/samples/ticker.exe ticker.bin
gzip -9 ticker.bin
mkimage -A arm64 -O rtems -T kernel -a 0x10000 -e 0x10000 -n RTEMS -d ticker.bin.gz rtems.imgIf mkimage is not available, install it with:
sudo apt install u-boot-toolsStep 7. Include the RTEMS image in the Zynq boot mediaNow this is a bit strange to me, it may be that some further development is needed to properly boot on ZynqMP board. Currently, the way to boot the RTEMS image we have just produced is to include it in the FAT partition of an SD card with u-boot and any Linux (petalinux, Ubuntu, etc) and stop u-boot at the prompt then load the image with fatload.
In a standard SDcard prepare to boot petalinux, copy the image rtems.img to the FAT partition as below. The other partition will be ext4 with a rootfilesystem (that won't be used)
Eject the card, insert it on the board (TE0802 in my case), connect a terminal to the USB port and power the board up. Stop the u-boot at the prompt by pressing any key:
On the terminal, type:
fatload mmc 0:1 0x1000 rtems.img
bootm0x1000And it will hand over to RTEMS running the ticker app:


Comments