How to do delta updates with Raspberry Pi 3

Introduction

Using binary deltas for applying updates is a more efficient mechanism for updating software over-the-air (OTA) which enables faster downloads and bandwidth cost saving for metered networks. When using cellular networks (e.g. 4G/LTE) or other bandwidth constrained networks, the impact is even greater. Mender offers the ability to generate and only deploy the binary difference (delta) between the software version already on the devices and the new version.

Mender offers binary delta updates as a commercial feature, using dual A/B partitions, providing the same robust update and atomic rollbacks that have been available with Mender since our initial release.

This tutorial will illustrate how to do a binary delta update with Raspberry Pi 3 utilizing the Yocto Project.

Prerequisites

  • A Raspberry Pi 3 Model B or B+ with 8 GB of microSD as a storage medium.
  • A supported Linux distribution and dependencies installed on your workstation/laptop as described in the Yocto Mega Manual
    • NOTE. Instructions depend on which Yocto version you intend to use.
  • Google repo tool installed and in your PATH.

Step 1 Initial setup of the Yocto Project environment

Set the Yocto Project branch you are building for:

export BRANCH="warrior"

Create a directory for your mender-raspberrypi setup to live in and clone the meta information.

mkdir mender-raspberrypi && cd mender-raspberrypi

Initialize repo manifest:

repo init \
    -u https://github.com/mendersoftware/meta-mender-community \
    -m meta-mender-raspberrypi/scripts/manifest-raspberrypi.xml \
    -b ${BRANCH}

Fetch layers in manifest:

repo sync

Setup the build environment:

source setup-environment raspberrypi

Step 2 Unpacking mender-binary-delta

You should have received a tar archive named mender-binary-delta-1.0.tar.xz which contains the binaries needed to generate and apply deltas. The content of the archive should be:

β”œβ”€β”€ aarch64
β”‚   β”œβ”€β”€ mender-binary-delta
β”‚   └── mender-binary-delta-generator
β”œβ”€β”€ arm
β”‚   β”œβ”€β”€ mender-binary-delta
β”‚   └── mender-binary-delta-generator
└── x86_64
    β”œβ”€β”€ mender-binary-delta
    └── mender-binary-delta-generator

Change directory to $HOME:

cd ${HOME}

Unpack the mender-binary-delta-1.0.0b1.tar.xz in your home directory:

tar xvf mender-binary-delta-1.0.0b1.tar.xz

Step 3 Integrating mender-binary-delta into the Yocto Project environment

Add the meta-mender-commerical layer to your Yocto environment:

bitbake-layers add-layer ../sources/meta-mender/meta-mender-commercial

Run the following to modify local.conf to include mender-binary-delta in your build:

cat <<EOF >> conf/local.conf
# Customizations for Mender delta-update support
# This will not impact your image if you already have this enabled
IMAGE_FEATURES_append = " read-only-rootfs"
IMAGE_INSTALL_append = " mender-binary-delta"
LICENSE_FLAGS_WHITELIST = "commercial_mender-binary-delta"
FILESEXTRAPATHS_prepend_pn-mender-binary-delta := "${HOME}/mender-binary-delta-1.0.0b1/:"
EOF

Step 4 Generating images, artifacts and deltas

For the purpose of this tutorial you can set the MENDER_ARTIFACT_NAME to the following:

MENDER_ARTIFACT_NAME = "release-v.1.0"

Set helper variables:

TARGET_IMAGE="core-image-base"
MACHINE="raspberrypi3"

Build an image (target image might differ in your environment):

bitbake ${TARGET_IMAGE}

Use the output of the build to provision your device with e.g with the provided disk image (e.g .sdimg) file. The result should be that you have a device that has booted and has the following file installed:

# ls /usr/share/mender/modules/v3/mender-binary-delta -alh
-rwxr-xr-x    1 root     root       98.2K Aug 19 08:52 /usr/share/mender/modules/v3/mender-binary-delta

Please verify this before proceeding. Save the generated Mender Artifact for later as it will be used to generate the delta:

cp tmp/deploy/images/${MACHINE}/${TARGET_IMAGE}-${MACHINE}.mender ${HOME}/mender-binary-delta-0.1.0/x86_64/release-v.1.0.mender

Generate a second Mender Artifact which can be used to test deploying delta updates. Start off by making a change to the image content, e.g add an application:

cat <<EOF >> conf/local.conf
IMAGE_INSTALL_append = " vim"
EOF

Update the MENDER_ARTIFACT_NAME to the following:

MENDER_ARTIFACT_NAME = "release-v.2.0"

Build the new image:

bitbake ${TARGET_IMAGE}

Save the generated Mender Artifact for later (will be used to generate a delta):

cp tmp/deploy/images/${MACHINE}/${TARGET_IMAGE}-${MACHINE}.mender ${HOME}/mender-binary-delta-0.1.0/x86_64/release-v.2.0.mender

Change directory mender-binary-delta:

cd ${HOME}/mender-binary-delta-0.1.0/x86_64/

The content of this directory should be the following:

$ ls
mender-binary-delta mender-binary-delta-generator release-v.1.0.mender release-v.2.0.mender

Generate delta for v1.0 -> v2.0 update path:

./mender-binary-delta-generator -n v2.0-deltafrom-v1.0 -o v2.0-deltafrom-v1.0.mender release-v.1.0.mender release-v.2.0.mender

Generate delta for v2.0 -> v1.0 update path:

./mender-binary-delta-generator -n v1.0-deltafrom-v2.0 -o v1.0-deltafrom-v2.0.mender release-v.2.0.mender release-v.1.0.mender

We now have the Mender Artifacts ready to be uploaded to the Mender server. The uploaded files are:

  • release-v.1.0.mender (rootfs-image)
  • release-v.2.0.mender (rootfs-image)
  • v1.0-deltafrom-v2.0.mender (mender-binary-delta)
  • v2.0-deltafrom-v1.0.mender (mender-binary-delta)

If you have followed this tutorial your provisioned device should be running release-v1.0 which was provisioned using a disk image (e.g sdimg).

Step 5 Deploy delta updates

Now, you can deploy either of the mender-binary-delta updates to your target system. Take careful note of the version currently running on your Raspberry Pi 3 device to ensure you select the appropriate image for installation.

  • v1.0-deltafrom-v2.0.mender
  • v2.0-deltafrom-v1.0.mender

Conclusion

In this tutorial we covered building and configuring a Raspberry Pi 3 board to deploy a robust delta update with rootfs rollback capability.


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!

1 Like

I’ve been following this tutorial with my jetson tx2. But I had my own image and mender artifacts.
I have created delta using this tutorial but while updating I’ve ended up with an error No compatible artifact found.

Hi @anishmonachan have you seen the troubleshooting steps here?

Most likely you are seeing a known issue that is discussed here.

Thanks for your reply.

Robust delta update rootfs?

from the tutorial above, I understood following points

  1. first update must always be an full rootfs update
  2. I’m using Mender v2.2.0 which doesn’t support delta update.