"Snappy" gateway application development with Ubuntu Core

Many of you have used at some point in your life, maybe to revive an old laptop that could not cope with the latest Windows update, or on your development machine, or, quite likely, if you’ve logged into a backend server. Lately, however, you might have heard of a new Ubuntu called (sometimes referred to as Snappy), and wondered what it is all about.

What is Ubuntu Core?

At first glance, Ubuntu Core seems to bear little resemblance to Ubuntu. The architecture of the Ubuntu Core operating system (OS) is completely different from traditional Ubuntu as the whole OS is made of packages called Snaps as opposed to the traditional deb packages. The image is just 200 MB, as it packages as few libraries as possible, allowing Snappy to run on platforms with as little as 500 MB of RAM. Also, installing packages via the traditional apt-get program is not possible.

But, when you look deeper, it actually has a lot of similarities. Ubuntu Core is also open source and shares a lot of code with Ubuntu. Further, all libraries you might need in your development work equally well across both platforms. So Snappy is similar, but different.

Ubuntu Core can surprise at first, as its emphasis on security and application isolation make it feel like a constrained environment. That’s until you understand that Ubuntu Core is more of a production OS than a development OS – it’s the OS you want to put on a box in the middle of nowhere so that even if someone has physical access to a device they’re limited as to what they can do with it.

The Snap effect

Looking under the hood, it’s hard to understand Ubuntu Core without understanding Snaps. Snaps are a new universal Linux packaging format launched in June 2016 that have three differentiated attributes compared to traditional Ubuntu’s current packaging format.

  1. First of all, each application is packaged with all of the libraries it needs to function correctly, so a web application, for example, could package its own database and a web server in the same Snap.
  2. Second, each application is completely isolated from other applications and from the OS itself within a Snap. By default, when an application is executed it only has access to its own data, and applications exists as read-only blobs in memory so that device owners can be certain of the code running on the device. This also allows each Snap to be upgraded individually in a failsafe manner through a transactional upgrade mechanism (more on this later).
  3. Finally, Snaps are available for download from a store, which makes discovery and installation simple. This means that each developer is not dependent on the choice of libraries made by other developers, and that each developer can manage his or her own application in their own rhythm. It also makes things much simpler for the end user, who can install complex pieces of as a single package in just a few seconds.

Once the concept of Snap is clear, understanding Ubuntu Core is a breeze. Each piece of software is a Snap. All the device drivers are packaged in a kernel Snap specific to a board. The OS is a Snap with minimal libraries that sits on top of the kernel Snap. Each application is a Snap, packaging all the libraries it needs. In order to get access to resources such as networking or I/O, applications can request access to an “interface,” which is authorized by the user or the device owner.

[Figure 1 | The isolated architecture of “Snappy” Ubuntu Core.]

As mentioned, Ubuntu Core is not a development platform. So, how do you create these Snaps? This is where an Ubuntu Desktop (or virtual machine (VM)) becomes handy. It is possible to build, run, and test Snaps directly in familiar Ubuntu 16.04 development environment before deploying them on the device. Some devices actually offer both an Ubuntu Core and Ubuntu Desktop images to facilitate this process.

Failsafe OTA updates

One of the key features of Ubuntu Core is its transactional update mechanism, or, to put it simply, the ability to perform failsafe over the air (OTA) updates. We’ve all been through bad upgrades on a desktop, but when talking about embedded devices, those bad upgrades can become horror stories, with technicians having to be deployed in the field to fix a system that has stopped working following an update.

Therefore, many developers working with embedded devices have taken refuge in the dangerous “no upgrade” zone, but that’s becoming less and less realistic given the number of denial of service (DoS) attacks on (IoT) devices, government legislation, and the positive drive towards more agile embedded development, which encourages frequent updates. For this reason, Ubuntu Core offers a failsafe upgrade mechanism out of the box that ensures that systems are fully updated and operational at the end of an upgrade, and otherwise reverts back to the original software version and application data, which is particularly useful when an update also includes a database schema. While similar features are available from software vendors, having it integrated directly at the OS level makes life much more simple and also means that any piece of software on a device can be updated securely, from the kernel to the OS to the applications.

Finding balance in IoT gateways

Choosing a board for a is always a tradeoff between cost, I/O, and power consumption. Finding the right balance, however, has proven more complex than ever with the number and complexity of sensors connected to gateways increasing. Is it worthwhile saving a few dollars on a cheaper processor just to be stuck with recurring cloud and connectivity fees since the local processing power is not sufficient to limit the amount of data transfer? Wherever you stand in the spectrum, there are options available.

Ubuntu Core images for the Raspberry Pi 2 and 3 make it simple to launch a commercial product in just a few months, as recently demonstrated by the launch of the NextCloud Box. For more powerful options, an official image is also available for Qualcomm’s DragonBoard 410c, a 96Boards-compatible development kit that serves as the 64-bit ARMv8 architecture (arm64) reference platform for Ubuntu Core. There are also a number of community images available for a variety of other 96Boards platforms. In addition, Samsung has also made images available for its Artik 5 and 10 boards.

[Figure | The Qualcomm DragonBoard 410c is the official 64-bit ARMv8 reference platform for Ubuntu Core development.]

On the Intel side, the choice is just as wide, from development board to Next Unit of Computing (NUC) form factors, as well as a number of pre-configured edge gateways. Development boards like the Intel Joule and Euclid, announced at this year’s Intel Developer Forum (IDF), will run both Ubuntu and Ubuntu Core with a strong focus on robotics development. For those looking for pre-configured gateways, Canonical has announced a certification program that guarantees the gateway chosen works out of the box with Ubuntu Core, with Dell and Advantech platforms already available.

IoT development in a Snap

Ubuntu Core provides a secure and stable environment for IoT developers looking to deploy applications and features quickly, and on the hardware of choice. Snappy enables easy and cost-effective updates and maintenance of connected embedded devices, which is critical to the deployment and success of the Internet of Things.

Thibaut Rouffineau is Head of Devices Marketing for IoT, Phone, and PC at Canonical Ltd.

Canonical Ltd.



Facebook: www.facebook.com/Canonical-125818784107695

Google+: plus.google.com/116469902245452284818