ATS Garage lets you easily manage OTA updates to embedded devices running custom-built Yocto images. This is a guide for building a simple Yocto image that you can run in Virtualbox or QEMU. This is a good way to get started if you don’t know yet what hardware your project will use, or if you just want to try out the features of ATS Garage without worrying about physical devices.

0. Prerequisites

You’ll need a build machine with the following:

  • A x86-64 Linux distro supported by the Yocto project with the required packages installed. (On a Debian-based system, you should be able to install all the required packages with sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib default-jre build-essential chrpath parted socat libsdl1.2-dev xterm repo libpython2.7-dev.)

    • Many/most distros that aren’t on the officially supported list will still work just fine—​feel free to give it a try with whatever you’re running.

    • Although the Yocto project as a whole does support architectures other than x86-64 for the build machine, one of the layers we’ll be using only supports x86-64.

    • You can run this all inside a VM, but a Yocto build is a pretty resource-intensive process, so generally we don’t recommend it. If you do, make sure there’s plenty of ram and disk space available to the VM.

  • 100GB of free disk space

  • repo

1. Generate provisioning credentials

Device Provisioning is the process of attaching individual credentials and certificates to a device. ATS Garage automates this process for you, allowing you to use the same unmodified disk image on many different devices and registering each one with ATS Garage the first time it boots.

Go to the Provisioning Keys tab of your profile.

screenshot provisioning key 1

Create a new key, select its period of validity, and then download it.

screenshot provisioning key 2

It comes as a zip file containing a provisioning key and credentials for your build system to publish images. You don’t need to unzip it; just save it somewhere. You’ll need it when you set up your Yocto build.

2. Create your Yocto build environment

First, clone a manifest file for the quickstart project:

mkdir myproject
cd myproject
repo init -u
repo sync

This will download the basic Yocto layers you need.

What is this actually doing?

Yocto is a set of tools, templates and methods for building Linux systems from scratch. Most Yocto-built systems use a common set of base layers. The Yocto project maintains a reference distribution called Poky; we include that as a base layer, then add layers containing hardware support for specific boards (in this case the QEMU VM). Finally, we include the meta-updater layer, which contains the platform-independent software the device and build system need to work with ATS Garage, and meta-updater-qemux86-64 for the device-specific code—​mostly the specialized bootloader code.

All of these layers are assembled into a built Linux system by Bitbake, the build tool of the Yocto Project, based on the instructions in the recipes inside the layers.

Now you can run the following script to get the environment set up:

source meta-updater/scripts/ qemux86-64

3. Customize your build

The environment setup script will have created a build directory and placed you in it. It also generates a configuration file, located at conf/local.conf. This file is where we’ll make our modifications to the base config.

To connect with your ATS Garage account, you’ll need the provisioning credentials bundle you downloaded earlier. Add the following line to your local.conf to supply those credentials to the build:

SOTA_PACKED_CREDENTIALS = "/path/to/your/"

3.1 Optional configuration keys

  • Set image name

When you build a filesystem image, it gets automatically uploaded to ATS Garage. By default, the image will be named qemux86-64-ota, and you’ll see the various versions of the image under that name. You can also choose to set your own name as follows:

OSTREE_BRANCHNAME = "my-super-great-project"
  • Persistent Yocto shared state cache and download directory

Yocto caches its build artefacts to speed up future builds. By default, these are stored under the build directory of the current project. However, if you’re planning to build several different projects that have some shared base files, you might want them to share their cache directories, both to save space and speed up your builds. You can do that as follows:

SSTATE_DIR = "/path/to/your/shared-sstate"
DL_DIR = "/path/to/your/shared-download"
  • Add extra packages

There are quite a lot of packages available to install that aren’t installed by default. You can add extra packages to your image with IMAGE_INSTALL_append; for example, this will install vim:

IMAGE_INSTALL_append = " vim " (1)
1 Note the spaces before and after the package name. This option dumbly appends a string to an install list, so we wrap it in spaces to make sure we don’t alter the list in unexpected ways.

You can get a list of all the available packages in the layers you have configured with bitbake-layers show-recipes

4. Bitbake

Now you’re ready to build an image.

bitbake core-image-minimal

This step will take a while. If you used the build mirror, it might be as little as 10-15 minutes. Building everything from scratch, it will likely take a few hours.

5. Run the built image with QEMU

The build process creates disk images as an artefact. You can then directly run them with QEMU. (If you don’t already have it installed, install it with apt-get install qemu or similar.) The meta-updater layer contains a helper script to launch the images:

../meta-updater/scripts/run-qemu-ota [image name] [mac address]

Both arguments are optional; image name defaults to core-image-minimal, and if a mac address isn’t specified, a random one is generated.

Persistent storage

By default, QEMU will run your image in snapshot mode, discarding any changes you made to the disk image as soon as it exits. If you want to have a persistent VM, you need to create an overlay storage image in qcow2 format. The helper script can also manage this for you, making it easy to create an emulated fleet of devices:

../meta-updater/scripts/run-qemu-ota --overlay mydevice.cow

If the specified overlay image doesn’t yet exist, it will be created first, or launched directly if it does exist.

You should see your new device appear in ATS Garage shortly after it boots. It will generate a random name for itself during autoprovisioning; you can change the name later.

Next: Pushing your first update >>