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.

We will need to configure the project for the target with a convenient install location set. Any folders named target-build from earlier step should be deleted because the build configuration files are written to target-build in this step.

  1. Activate the development environment shell to prepare the development shell for building the application

    Linux

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

    Windows

    cd %USERPROFILE%\d7-sdk
    .\toolchain\environment-setup-armv8a-veethree-linux.bat
  2. Navigate to application source directory to create build directory

    cd examples/gui/qml-analog/
    # Create the build directory
    mkdir target-build
    cd target-build/
  3. Configure and build with the install location set to target-install

    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.

Navigate to examples/gui/qml-analog/target-install, created from the previous section. In that folder, create a systemd unit file qml-analog-app.service with the contents:

[Unit]
Description=Run Resistance Sensor Reading App
DefaultDependencies=no
PartOf=graphical.target
After=local-fs.target
[Service]
Type=simple
ExecStart=/app/bin/qml-analog-app
Restart=always
EnvironmentFile=/etc/qt/qt-environment
[Install]
WantedBy=sysinit.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 so, run:

On Linux:

cd $HOME/d7-sdk/examples/gui/qml-analog/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:

cd %USERPROFILE%\d7-sdk\examples\gui\qml-analog\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.

Creating the Software Update image

The software update image is created using the swugen utility, also from tools in the D7 SDK installation directory. See more details swugen.

On Linux:

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

On Windows:

%USERPROFILE%\d7-sdk\tools\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. Run swugen --help for a list of all supported options.

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

Building a QML application using the D7 SDK

Next step

Applying a software update on a device