Using Mender Client 4.0 on Yocto

Introduction

The Mender Client 4.0 is a full rewrite in C++. This brings a number of benefits, such as

  • increased portability
  • reduced resource consumption
  • no additional language dependencies

You can find more details in the announcement: Mender to rewrite client using C++ and retain Go for its backend

This short tutorial will show you how to select it in a Yocto-based Linux distribution build.

Version notes

The tutorial has been verified on Debian 11, as of 2024-04-26

This tutorial uses kirkstone as the primary target, which is the current LTS release by the Yocto Project. You can find more infomation on releases here. Supported releases for following the tutorial are:

Yocto Project Tutorial applies Maintenance
scarthgap (5.0) :test_works: :test_works: development
nanbield (4.3) :test_works: :test_works: current stable
mickledore (4.2) :test_works: :test_fails: EOL
langdale (4.1) :test_works: :test_fails: EOL
kirkstone (4.0) :test_works: :test_works: LTS
honister (3.4) :test_fails: :test_fails: EOL
hardknott (3.3) :test_fails: :test_fails: EOL
gatesgarth (3.2) :test_fails: :test_fails: EOL
dunfell (3.1) :test_fails: :test_fails: EOL
zeus (3.0) :test_fails: :test_fails: EOL
warrior (2.7) :test_fails: :test_fails: EOL
thud (2.6) :test_fails: :test_fails: EOL
sumo (2.5) :test_fails: :test_fails: EOL
rocko (2.4) :test_fails: :test_fails: EOL

Please note: a failure in the “tutorial applies” column indicates that the instructions do not work without modification. Depending on the combination of release and host Linux distribution, installing other python versions or dependencies might provide a functional state.

Prerequisites

To follow this tutorial, you will need:

  • A prepared build setup We will be using an exisiting Yocto Project build setup. As the example for the instructions, the setup as described on the Mender Hub is used.
  • An initialized shell The commands assume that the shell has been initialized for the build setup, which is usually done by invoking source poky/oe-init-build-env. Given the linked setup, we start in the yocto directory

The meta-mender-core layer

The meta-mender-core layer is the main entry point to use the Yocto integration of Mender. Its concepts and details are described in the documentation. The following steps will show a generic setup of Mender with with Client 4.0 in a Yocto build without incorporating a specific board integration. For such, please refer to the respective article.

Getting the layer

Clone the repository into the sources directory. We are checking out the kirkstone branch here, adapt in case you are using a different release.

cd sources
git clone https://github.com/mendersoftware/meta-mender -b kirkstone
cd ..

Adding the layer

Change into the build directory:

cd build

Then add the Mender core integration layer, and check the layer listing:

bitbake-layer add-layer ../sources/meta-mender/meta-mender-core
bitbake-layer show-layers

Enabling Mender

systemd

The standard Mender setup requires systemd. This is a distribution wide setting, so it should be set in the DISTRO configuration file. If you do not have a custom distro yet, you can add it to your local.conf:

INIT_MANAGER = "systemd"

Enabling the Mender integration

Mender relies on a number of system and distribution wide settings being in effect, such as:

  • the A/B partitioning
  • the Client being installed
  • required settings being injected into the resulting image, specifically the device_type
  • IMAGE_FSTYPES being set accordingly.

The recommended way to do this is by enabling the mender-full class. Just as with systemd, this should be set on the distribution level, or local.conf:

INHERIT += "mender-full"

Note: if you are targetting a UBIFS-based image, set INHERIT += "mender-full-ubi" instead

Depending on your target board, you can adjust several features through the MENDER_FEATURES_ENABLE and MENDER_FEATURES_DISABLE variables. Please check the documentation for more details.

Select Mender Client 4.0

Depending on the release you are on, Mender Client 4.0 might not be selected as the default. By setting the following configuration variables, you can switch to 4.0:

PREFERRED_VERSION_mender = "4.0.4"
PREFERRED_PROVIDER_mender-native = "mender-native"
PREFERRED_RPROVIDER_mender-auth = "mender"
PREFERRED_RPROVIDER_mender-update = "mender"

If you have custom scripts that rely on invoking the mender command, you must revisit them to match the following change:

  • mender-auth provides the bootstrap functionality
  • mender-update provides the check-update, commit, install, rollback, send-inventory, show-artifact and show-provides functionalities

For migrating mender daemon, mender setup and mender snapshot, please consult the migration guide.

Building

The Mender integration works independent of the image to be built. So you can use an already existing image recipe, like

bitbake core-image-minimal

Conclusion

The Mender Client 4.0 can be easily brought into an existing Yocto build by adjusting the local respectively distribution configuration. Additional changes might be required in situations where custom scripting is being used.


If this tutorial was useful to you, please press like, or leave a thank you note to the contributor who put valuable time into this and made it available to you. It will be much appreciated!

2 Likes

Thanks @TheYoctoJester for the detailed steps.
I am trying to integrate meta mender layers (Scarthgap branch) into boundary-bsp-platform (boundary-imx-6.6.23-2.0.0 branch). However, I am getting below warnings and errors.

WARNING: preferred version 4.0.4 of mender-client not available (for item mender-client)
WARNING: versions of mender-client available: 3.5.0 3.5.1 3.5.2 3.5.3 master-git

ERROR: Multiple .bb files are due to be built which each provide mender:
sources/meta-mender/meta-mender-core/recipes-mender/mender-client/mender-client_3.5.3.bb
sources/meta-mender/meta-mender-core/recipes-mender/mender-client/mender_4.0.4.bb

As you suggested above, I have added below configuration variables into local.conf
PREFERRED_VERSION_mender = “4.0.4”
PREFERRED_PROVIDER_mender-native = “mender-native”
PREFERRED_RPROVIDER_mender-auth = “mender”
PREFERRED_RPROVIDER_mender-update = “mender”

Am I missing any changes?
What could be done to resolve this issue. Kindly suggest.

1 Like

I see these warnings in Kirkstone:

WARNING: preferred version 4.0 of mender-client not available (for item mender-auth)
WARNING: versions of mender-client available: 3.3.0 3.3.1 3.3.2 3.4.0 3.5.0 3.5.1 3.5.2 3.5.3 master-gitAUTOINC+f6ffa19089
WARNING: preferred version 4.0 of mender-client not available (for item mender-update)
WARNING: versions of mender-client available: 3.3.0 3.3.1 3.3.2 3.4.0 3.5.0 3.5.1 3.5.2 3.5.3 master-gitAUTOINC+f6ffa19089
WARNING: preferred version 4.0 of mender-client not available (for item mender-client-dev)
WARNING: versions of mender-client available: 3.3.0 3.3.1 3.3.2 3.4.0 3.5.0 3.5.1 3.5.2 3.5.3 master-gitAUTOINC+f6ffa19089
WARNING: preferred version 4.0 of mender-client not available (for item mender-client)
WARNING: versions of mender-client available: 3.3.0 3.3.1 3.3.2 3.4.0 3.5.0 3.5.1 3.5.2 3.5.3 master-gitAUTOINC+f6ffa19089

Hi @amrwld & @21sw-clayton,

Sorry for the late reply. Have you made sure you are on the latest state of the meta-mender kirkstone branch? If in doubt, feel free to drop the initial summary in here which bitbake provides upon startup. The layer revision SHAs are noted there, so we can check.

Greetz,
Josef

1 Like

Hi, Josef!

Yes, I believe I’m on a recent version.

Please note that @amrwld mentioned this in reference to Scarthgap.

Here’s a fresh build:

build/tmp-beaglebone-glibc/log/cooker/beaglebone$ grep -E 'WARNING|meta-mender.*=' console-latest.log 
WARNING: preferred version 4.0 of mender-client not available (for item mender-auth)
WARNING: versions of mender-client available: 3.3.0 3.3.1 3.3.2 3.4.0 3.5.0 3.5.1 3.5.2 3.5.3 master-gitAUTOINC+f6ffa19089
WARNING: preferred version 4.0 of mender-client not available (for item mender-update)
WARNING: versions of mender-client available: 3.3.0 3.3.1 3.3.2 3.4.0 3.5.0 3.5.1 3.5.2 3.5.3 master-gitAUTOINC+f6ffa19089
WARNING: preferred version 4.0 of mender-client not available (for item mender-client-dev)
WARNING: versions of mender-client available: 3.3.0 3.3.1 3.3.2 3.4.0 3.5.0 3.5.1 3.5.2 3.5.3 master-gitAUTOINC+f6ffa19089
WARNING: preferred version 4.0 of mender-client not available (for item mender-client)
WARNING: versions of mender-client available: 3.3.0 3.3.1 3.3.2 3.4.0 3.5.0 3.5.1 3.5.2 3.5.3 master-gitAUTOINC+f6ffa19089
meta-mender-raspberrypi = "HEAD:f12ece10685e70192190168ca708cd767f7c1a52"
meta-mender-core     = "HEAD:f12ece10685e70192190168ca708cd767f7c1a52"
meta-mender-beaglebone = "kirkstone:1d98cc9391e57a6f9cdf8df9cfc6f266b85dca6c"

Hi @amrwld and @21sw-clayton,

Sorry it took me so long to sit down and reproduce the behavior. Indeed there was an error in the snippet, fixed now. The corrected line is specifically

PREFERRED_VERSION_mender = "4.0.4"

with 4.0.4 being the current latest stable release.

Greetz,
Josef

1 Like

That seemed to do the trick. Thank you for looking at it!

1 Like