Mender Guide

From Variscite Wiki




Mender Introduction

Mender is an open-source OTA update manager for embedded Linux, providing secure, reliable, and flexible update mechanisms. It supports seamless over-the-air rollouts, simplified local provisioning, and both self-hosted and cloud-hosted server options. Key features include:

  • A/B atomic updates & rollback: Switch between two rootfs partitions and automatically revert to the last known-good image on failure.
  • Local updates: Install artifacts manually via USB stick, SD card or command-line interface for offline or on-site provisioning.
  • Self-hosted: Deploy and manage updates on your own infrastructure for full control over scheduling, security and integrations.
  • Mender Hosted: Cloud-managed SaaS offering with built-in scalability, monitoring and simplified device grouping.

For more information, see the Mender website and the Technical documentation.

Mender Integration with VAR-SOM-MX93

This reference guide shows how to integrate Mender on the VAR-SOM-MX93 platform. It covers three common update workflows:

  1. Build: Create a Mender-enabled disk image that can be flashed directly to eMMC.
  2. Serverless updates: Copy the update artifact to the board over an Ethernet link and apply it locally.
  3. Server-based update: Upload the artifact to a self-hosted Mender server and trigger a remote update.

Note: This example is provided for demonstration only. It omits or disables certain security features—such as TLS authentication, image signing, and verification, to simplify the walkthrough. Before deploying in production, review and harden all configurations to meet your product’s security requirements.

Building Mender Image and Artifacts

This guide assumes the user is familiar with how to Build Yocto from source code.

First, add meta-mender-core and meta-mender-demo to conf/bblayers.conf:

$ bitbake-layers add-layer ../sources/meta-mender/meta-mender-core
$ bitbake-layers add-layer ../sources/meta-mender/meta-mender-demo

Next, build your image:

$ bitbake fsl-image-gui

This will generate the following files:

# Partitioned image to be flashed directly to eMMC:
tmp/deploy/images/imx93-var-som/fsl-image-gui-imx93-var-som.sdimg

# Artifact for updating an image that's already flashed to eMMC:
tmp/deploy/images/imx93-var-som/fsl-image-gui-imx93-var-som.mender

Flash a Mender Image

Mender creates a partitioned image that must be written directly to the eMMC. Booting from an SD card is not supported unless you modify the hardcoded values in imx93-var-som.conf.

One common method to flash the image is via USB OTG using UMS (USB Mass Storage Gadget).

Steps:

1. Connect the USB OTG port on the Variscite Evaluation Kit (EVK) to a Linux host computer using a USB cable.

2. On the target device, in U-Boot, start UMS:

u-boot> ums 0 mmc $mmcdev

3. On the host computer, a disk unit will be mounted. Unmount the respective disk unit with:

$ umount /dev/sdX

4. On the host computer, flash the image using bmaptool. This is preferred over dd because it is faster and verifies blocks:

$ sudo bmaptool copy tmp/deploy/images/imx93-var-som/fsl-image-gui-imx93-var-som.sdimg /dev/sdX

Replace /dev/sdX with the device node that appears when the board is in UMS mode (e.g., /dev/sdb). Be careful to select the correct device to avoid overwriting your host system.

Deploy a Mender Artifact Locally

Once the Mender-enabled image is booted on the target device, you can deploy a `.mender` artifact directly from your development machine without a Mender server.

Steps:

1. Copy the artifact from the host to the target over SSH:

$ scp tmp/deploy/images/imx93-var-som/fsl-image-gui-imx93-var-som.mender root@TARGET_IP_ADDR:

Replace TARGET_IP_ADDR with the actual IP address of the target device.

2. On the target device, install the update:

root@imx93-var-som:~# mender-update install fsl-image-gui-imx93-var-som.mender

3. Reboot the device to apply the update:

root@imx93-var-som:~# reboot

4. After reboot, commit the update to make it permanent:

root@imx93-var-som:~# mender-update commit

If the update is not committed, the system will automatically roll back to the previous version on the next reboot.

Deploy a Mender Artifact using a self hosted server

Configuring the self hosted server

Mender provides a hosted server to manage deployments. For more information, see: https://hosted.mender.io/ui/

Mender also providers a docker container to self host your own server. For more information, see: https://docs.mender.io/server-installation/evaluation-with-docker-compose

Clone the mender-server repository which contains everything that is need to start the demo server:

git clone -b v4.0.0 https://github.com/mendersoftware/mender-server.git mender-server

Change directory to the cloned repository:

cd mender-server

Set the MENDER_IMAGE_TAG environment variable (defines which Mender Server version to start, read by XYZ in command below):

export MENDER_IMAGE_TAG=v4.0.0

Start the demo server:

docker compose up -d

Once the server is running, you can create the admin user:

MENDER_USERNAME=admin@docker.mender.io
MENDER_PASSWORD=PleaseReplaceWithASecurePassword
docker compose run --name create-user useradm create-user --username "$MENDER_USERNAME" --password "$MENDER_PASSWORD"

Open the browser and visit https://localhost to log in using the credentials configured in the above snippet.

Adding a new device to the server

Configure your image to use the demo server by setting MENDER_DEMO_HOST_IP_ADDRESS in variscite-mender.inc

After programming a VAR-SOM-MX93 with the updated image, it will try to authenticate with the server and appear under the 'pending devices' list:

Mender-pending.png

Uploading new Mender Releases

After installing the original mender image, new images can be built, uploaded to the server, and deployed to the device.

First, change MENDER_ARTIFACT_NAME in variscite-mender.inc to give your image a new name.

Then, rebuild the image:

bitbake fsl-image-gui

And, upload tmp/deploy/images/imx93-var-som/fsl-image-gui-imx93-var-som.mender to the RELEASES tab:

Mender-releases.png

Deploying a new Mender Release

Releases are deployed to devices using the DEPLOYMENTS tab. Configure the release by selecting the devices, the release, and when to run the deployment:

Mender-create-deployment.png

The status of the deployment can be monitored by selecting the deployment in the DEPLOYMENTS tab.