Packaging Applications for Embedded Devices Using Ubuntu Frame and Snaps

Packaging your own application

Before following this how-to, Packaging and Deploying Ubuntu Frame Snaps on the Desktop serves as a useful primer on creating snaps.

This how-to is as an introduction to packaging Snaps for use with Ubuntu Frame on embedded devices . We can’t go into all the possibilities and tools in this guide. There are helpful docs and forums on the Snapcraft website.

Building for and installing on a device

So far you explored the process for testing if your snapped application will work on Ubuntu Frame only using your desktop. While this accelerates the development process, you still need to consider the final board for your edge device. A lot of edge devices don’t use the amd64 architecture that is typical of development machines. Therefore, in this section, you will see how to build for and install on a device if your device uses a different architecture, using the SDL2 Neverputt application as an example. You will also see how to troubleshoot some common issues.

Leveraging Snapcraft remote build tool

The simplest way to build your snap for other architectures is:

snapcraft remote-build

This uses the Launchpad build farm to build each of the architectures supported by the snap. This requires you to have a Launchpad account and to be okay uploading your snap source to a public location.

Once the build is complete, you can scp the .snap file to your IoT device and install using --dangerous.

For the sake of this guide, we are using a VM set up using the approach described in Ubuntu Core: Preparing a virtual machine with graphics support. Apart from the address used for scp and ssh this is the same as any other device and makes showing screenshots easier.

scp -P 10022 *.snap <username>@localhost:~
ssh -p 10022  <username>@localhost

snap install ubuntu-frame
snap install --dangerous *.snap

You’ll see the Ubuntu Frame grayscale background once that instals, but (if you’ve been following the steps precisely) you won’t see Neverputt start:

$ snap logs -n 30 iot-example-graphical-snap

...

2021-11-16T16:10:24Z iot-example-graphical-snap.iot-example-graphical-snap[3388]: WARNING: hardware-observe interface not connected! Please run: /snap/iot-example-graphical-snap/current/bin/setup.sh

2021-11-16T16:10:24Z iot-example-graphical-snap.iot-example-graphical-snap[3388]: WARNING: audio-playback interface not connected! Please run: /snap/iot-example-graphical-snap/current/bin/setup.sh

2021-11-16T16:10:24Z iot-example-graphical-snap.iot-example-graphical-snap[3388]: WARNING: joystick interface not connected! Please run: /snap/iot-example-graphical-snap/current/bin/setup.sh

2021-11-16T16:10:24Z iot-example-graphical-snap.iot-example-graphical-snap[3388]: ALSA lib conf.c:4120:(snd_config_update_r) Cannot access file /usr/share/alsa/alsa.conf

2021-11-16T16:10:24Z iot-example-graphical-snap.iot-example-graphical-snap[3388]: Failure to initialize SDL (Could not initialize UDEV)

2021-11-16T16:10:24Z systemd[1]: snap.iot-example-graphical-snap.iot-example-graphical-snap.service: Succeeded.

2021-11-16T16:10:24Z systemd[1]: snap.iot-example-graphical-snap.iot-example-graphical-snap.service: Scheduled restart job, restart counter is at 5.

2021-11-16T16:10:24Z systemd[1]: Stopped Service for snap application iot-example-graphical-snap.iot-example-graphical-snap.

2021-11-16T16:10:24Z systemd[1]: snap.iot-example-graphical-snap.iot-example-graphical-snap.service: Start request repeated too quickly.

2021-11-16T16:10:24Z systemd[1]: snap.iot-example-graphical-snap.iot-example-graphical-snap.service: Failed with result 'start-limit-hit'.

2021-11-16T16:10:24Z systemd[1]: Failed to start Service for snap application iot-example-graphical-snap.iot-example-graphical-snap.

...

All these WARNING messages give the clue: you’re still developing the snap and interfaces are not yet being connected automatically. So, connect the missing interfaces and manually start the daemon:

/snap/iot-example-graphical-snap/current/bin/setup.sh
snap start iot-example-graphical-snap

You should see your snap starting.

Conclusion

From testing to deployment, this guide shows you how to use Ubuntu Frame to deploy your graphic applications. It covers topics as seting up the tools and environment on your desktop, testing if an application works with Ubuntu Frame, and packaging the application as a snap for an IoT device. It also included some issues you can encounter working with your applications and how to troubleshoot them.

We have also shown all the steps needed to get your snap running on a device. The rest of your development process is the same as for any other snap: uploading the snap to the store and installing on devices from there. There are just a few parting things to note:

Now that the Snap interfaces are configured, the application will automatically start when the system (re)starts.

Once you’ve uploaded the snap to the store, you can request store assertions to auto-connect any required interfaces. Alternatively, if you are building a Snap Appliance, then you can connect the interfaces in the “Gadget Snap”.

Learn more

For more information about Ubuntu Frame please visit our website.

You may also consider reading the following materials:

1 Like