# Using Mender Client 4.0 on Yocto

**URL:** <https://hub.mender.io/t/using-mender-client-4-0-on-yocto/6767>\
**Category:** Yocto Project\
**Created:** [April 26, 2024, 11:18am UTC](https://hub.mender.io/t/using-mender-client-4-0-on-yocto/6767 "2024-04-26T11:18:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [April 26, 2024, 11:18am UTC](https://hub.mender.io/t/using-mender-client-4-0-on-yocto/6767/1 "2024-04-26T11:18:52Z")

</div>

## 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](https://hub.mender.io/t/mender-to-rewrite-client-using-c-and-retain-go-for-its-backend/5332)

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

 ![LF_17_02_Yocto-Badge-Update_Participant_Final](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/1X/758c60e0e8309c4dc2519392b78668e7396c15bd.png)

## 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](https://wiki.yoctoproject.org/wiki/Releases). 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](https://hub.mender.io/t/preparing-the-yocto-project-environment-from-scratch/801) 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`](https://github.com/mendersoftware/meta-mender) layer is the main entry point to use the Yocto integration of Mender. Its concepts and details are described in the [documentation](https://docs.mender.io/operating-system-updates-yocto-project/overview). 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.

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

```

### Adding the layer

Change into the build directory:

```auto
cd build

```

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

```auto
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`:

```auto
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`:

```auto
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](https://docs.mender.io/operating-system-updates-yocto-project/image-customization/features) 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:

```auto
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](https://docs.mender.io/client-installation/install-with-debian-package/upgrading#upgrade-using-yocto).

## Building

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

```auto
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!_

---

<div class="post-metadata">

**Author:** ![amrwld](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/amrwld/32/2276_2.png) [@amrwld](https://hub.mender.io/u/amrwld)\
**Post date:** [September 4, 2024, 4:43pm UTC](https://hub.mender.io/t/using-mender-client-4-0-on-yocto/6767/2 "2024-09-04T16:43:10Z")

</div>

Thanks @TheYoctoJester for the detailed steps.  
I am trying to integrate [meta mender layers](https://github.com/mendersoftware/meta-mender/tree/scarthgap) (Scarthgap branch) into [boundary-bsp-platform](https://github.com/boundarydevices/boundary-bsp-platform/tree/boundary-imx-6.6.23-2.0.0) (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.

---

<div class="post-metadata">

**Author:** ![21sw-clayton](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/21sw-clayton/32/2305_2.png) [@21sw-clayton](https://hub.mender.io/u/21sw-clayton)\
**Post date:** [September 24, 2024, 2:06am UTC](https://hub.mender.io/t/using-mender-client-4-0-on-yocto/6767/3 "2024-09-24T02:06:50Z")

</div>

I see these warnings in Kirkstone:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [October 1, 2024, 3:04pm UTC](https://hub.mender.io/t/using-mender-client-4-0-on-yocto/6767/4 "2024-10-01T15:04:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![21sw-clayton](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/21sw-clayton/32/2305_2.png) [@21sw-clayton](https://hub.mender.io/u/21sw-clayton)\
**Post date:** [October 1, 2024, 5:00pm UTC](https://hub.mender.io/t/using-mender-client-4-0-on-yocto/6767/5 "2024-10-01T17:00:02Z")

</div>

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:

```auto
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"

```

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [October 14, 2024, 1:23pm UTC](https://hub.mender.io/t/using-mender-client-4-0-on-yocto/6767/6 "2024-10-14T13:23:59Z")

</div>

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

```auto
PREFERRED_VERSION_mender = "4.0.4"

```

with 4.0.4 being the current latest stable release.

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![21sw-clayton](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/21sw-clayton/32/2305_2.png) [@21sw-clayton](https://hub.mender.io/u/21sw-clayton)\
**Post date:** [October 18, 2024, 7:58pm UTC](https://hub.mender.io/t/using-mender-client-4-0-on-yocto/6767/7 "2024-10-18T19:58:49Z")

</div>

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