Raspberry Pi 5 QNX 8 CTI preview

The official Mender documentation explains how Mender works. This is a board-specific complement to the official documentation.

Device description

A Raspberry Pi 5 (tested on the 2GB variant) with a uSD card with at least 16 GB of capacity.

Support level

Just like in case of the QNX Quick Start Target Image Mender integration, only basic functionality of the Mender Client was tested, in particular generation of an authentication key, connection and authentication to a Mender Server (hosted.mender.io), inventory reporting, and deployment of single-file and directory Mender Artifacts.

Getting started

The QNX Custom Target Image toolset allows developers to build customized images similar to the pre-built Quick Start Target Images. One such possible customization can be integration of the Mender Client resulting in images that, when booted, even for the very first time, automatically run the Mender Client and connect to the chosen Mender Server.

Please follow the QNX Custom Target Image documentation to get a working setup locally.

Customization

There are multiple steps utilizing various CTI customization mechanisms requried to integrate the Mender Client into the images. They are all available as commits in a fork of the CTI repo, but let’s briefly go through the individual bits here.

The Mender Client is available in the QNX Open-Source Software repository so it can be easily installed into the images by adding the following two lines into the targets/rpi5/world.preinstall_aarch64 file:

mender=5.2.0-r0
mender-doc=5.2.0-r0

The mender package pulls all the required dependencies and provides all executables and default configuration files. The mender-doc package contains the /usr/share/doc/mender/README_setup.md file with setup instructions that can be followed to set the device up for Mender Client and do basic configuration. And while it’s nice to have the guide in the image for reference, the goal here is to do the basic setup and configuration as part of the image building process, i.e. to get “batteries included” images.

Next step is to make sure there is /var/lib/mender as a symlink to /data/mender (i.e. to space on the persistent /data partition) and that it contains the device_type file. This can be achieved by adding a snippets/data_files.custom.mender file with the following content:

# Mender data directory and device type
[type=dir uid=0 gid=0 dperms=0755] mender
[type=file uid=0 gid=0 perms=644]  mender/device_type={
device_type=qnx-rpi5
}
[type=link uid=0 gid=0 perms=0755] var/lib/mender=/data/mender

Of course, the qnx-rpi5 value can be replaced by any valid device type string.

A similar approach can be used to provide the default /etc/mender/mender.conf, this time adding a snippets/system_files.custom.mender snippet file:

# Mender configuration
[type=dir uid=0 gid=0 dperms=755] etc/mender=etc/mender
[type=file uid=0 gid=0 perms=600] etc/mender/mender.conf=etc/mender/mender.conf

The mender.conf contents are not part of the snippet itself, they are in a separate system/etc/mender/mender.conf file instead (to make the snippet small and clean). Being the major part of the customization, the contents of the config file are, well…, custom, but they must at least provide the "ServerURL" field and, if required by the chosen Mender Server, the "TenantToken" field. See the Mender Client Configuration docs for full documentation of the config file.[1]

Last but not least, the snippets/slm.~60.custom.network snippet needs to be extended with an extra mender component for the QNX System Launch and Monitor (the QNX’s “systemd”, so to speak) making sure that the Mender Client is started during boot and restarted in case of a failure:

<SLM:component name="mender">
  <SLM:depend state="stateless">network-init</SLM:depend>
  <SLM:command>/usr/bin/mender-update</SLM:command>
  <SLM:args>--log-file /var/log/mender.log daemon</SLM:args>
  <SLM:repair backoff="30">restart</SLM:repair>
</SLM:component>

So far, so good. Unfortunately, things are a bit more complicated. The issue with the above nice and clean solution is that the mender package from the QNX OSS repo ships default /var/lib/mender/device_type and /etc/mender/mender.conf files (and the respective directories) and the customization snippets can only add files to the image, with duplicates/redefinitions being ignored. Since the APKs are installed early in the image building process, a workaround has to be used to delete those default files to make room for the customized variants. This can be achieved by adding a so-called EXTRAS script that can do the required cleanup, in the right phase. This is an undocumented mechanism of the CTI process, but there doesn’t seem to be any other way to make sure the custom configuration gets into the resulting image. See the full script for details. It can be hooked up by adding $MKQNXIMAGE_EXTRAS/mender to the EXTRA_DIRS variable in the targets/rpi5/mkqnximage.config file.

With all of the above in place, running make TARGET=rpi5 produces a customized QNX image for Raspberry Pi 5 with Mender Client fully set up and configured. Flashing such image to an uSD card (or multiple uSD cards, of course!) and booting it in an RPi5 results in the device showing up at the selected Mender Server, asking to be accepted.

References

The QNX CTI toolset requires a QNX Everywhere license.

Known issues

Just like in case of the QNX Quick Start Target Image Mender integration, the image only contains one Mender binary – mender-update, with the authentication functionality built-in. There is no mender-auth and thus no DBus API and no HTTP proxy functionality for connections to a Mender Server.

Likewise, there is no rootfs-image Update Module, no boot loader integration and thus no full-system OTA updates functionality.


  1. There is currently no rootfs-image Update Module for QNX and no support for A/B OTA updates, so the options related to A/B partitioning have no effect. ↩︎

2 Likes