Veethree D7 SDK
Loading...
Searching...
No Matches
Creating software updates

Once you have built your application, in order to run it when the device powers on, you will need to have in place a few things:

  1. A systemd unit that launches your application as part of the graphical target
  2. A Software Update image (.swu file) that can be applied to the device.

There are two ways to create a software update:

  1. Copy the existing SWU generation example application as a starting point for your application.
  2. Add SWU capability to your existing application.

This page covers the latter: taking an existing application and making a SWU for it.

The next step after this page covers applying a software update to the device.

The application

Once again, we will use the QML application that reads resistances from the analog sensors, so the setup and test harness are the same as in Building a QML application using the D7 SDK.

For convenience, please delete the previous build directory used for the target build – if you have followed the example on that page, the directory to remove will be called target-build.

We will need to configure the project again for building on the target, but we will need to set a convenient install location.

Open a new terminal (on Linux) or CMD window (on Windows) and navigate to the D7 SDK installation directory.

Linux

# Activate the environment
cd $HOME/d7-sdk
source ./toolchain/environment-setup-armv8a-veethree-linux

Windows

:: Activate the environment
cd %USERPROFILE%\d7-sdk
.\toolchain\environment-setup-armv8a-veethree-linux.bat

Both

# Move to the example's source directory
cd examples/gui/qml-analog/
# Create the build directory
mkdir target-build
cd target-build/
# Configure, build and install the project
cmake -S.. -GNinja -DCMAKE_INSTALL_PREFIX=../target-install
cmake --build . --target install

The commands here should run without errors; then if you navigate to the target-install directory, you should see the following file structure:

target-install directory

The systemd unit

Note
This is subject to change. In future releases this step may be made part of building the application.

In target-install, at the same level as the bin directory, create a systemd unit file qml-analog-app.service:

[Unit]
Description=Run Resistance Sensor Reading App
PartOf=graphical.target
[Service]
ExecStart=/app/bin/qml-analog-app
Restart=always
EnvironmentFile=/etc/qt/qt-environment
[Install]
WantedBy=graphical.target

Please note the path of the executable is /app/bin/qml-analog-app since the directory structure will be replicated on the /app partition on the device.

Also of note, the Environment File being /etc/qt/qt-environment. That file contains a number of environment variables which are necessary for Qt QML applications.

The application will be run as root without sourcing the usual profile scripts, and so setting the environment file in the systemd unit is necessary.

Note
The application being run as root is subject to change in future releases.

The target-install directory should look like this now:

`target-install` directory structure

(Optional) Marking a service as non-critical

After applying an update, the operating system on the D7 will check to make sure that within 60 seconds of starting up all the critical services have succeeded.

If not, the board will automatically revert to the previous running image. See A/B update scheme for more information.

If your application has multiple services and some of them are allowed to fail, you will need to mark them as non-critical.

To do that, in the install folder of the application – in this case that would be examples/gui/qml-analog/target-install – you will need to run:

On Linux:

# Current working directory is target-install
mkdir -p sys/systemd/non-critical.d
echo "qml-analog-app" > sys/systemd/non-critical.d/app.conf # Replace qml-analog-app with the service that is allowed to fail

On Windows:

# Current working directory is target-install
mkdir sys/systemd/non-critical.d
echo "qml-analog-app" > sys\systemd\non-critical.d\app.conf # Replace qml-analog-app with the service that is allowed to fail

Add each non-critical service on a new line of the "app.conf" file.

After that, you will need to regenerate the software update file.

Creating the Software Update image

The software update image is created using the swugen utility, also from shortcuts in the D7 SDK installation directory. Run swugen --help for a list of all supported options. See more details swugen.

On Linux:

$HOME/d7-sdk/shortcuts/swugen \
-i target-install \
-k $HOME/d7-sdk/keys/default-key \
-o update-image.swu \
--development

On Windows:

%USERPROFILE%\d7-sdk\shortcuts\swugen.exe ^
-i target-install ^
-k %USERPROFILE%\d7-sdk\keys\default-key ^
-o update-image.swu ^
--development

The --development switch tells swugen to create a development image. Alternatively, the --release switch would create a release image.

Creating the software update image

Summary

On this page we have described the necessary steps to create a software update image that can be flashed onto the device which will run a compiled application on the device startup.

Please also check the software update details page for more information on the validation that takes place after a software update is applied.

Previous step

Setup the D7 SDK to use in Qt Creator

Next step

Applying a software update on a device