Skip to content
Gustavo Niemeyer edited this page Oct 6, 2016 · 21 revisions

Introduction

The gadget snap is responsible for defining and manipulating the system properties which are specific to one or more devices that will usually look similar to one another from an implementation perspective. This snap must necessarily be produced and signed by the device brand, which is defined via the model assertion. The brand knows where and how that device will be used, and designs the gadget snap accordingly.

For example, the brand may know that the device is actually a special VM to be used on a particular cloud, or it may know that it is going to be manufactured in a particular factory. The gadget snap may encode the mechanisms for device initialization - key generation and identity certification - as well as particular processes for the lifecycle of the device, such as factory resets. It is perfectly possible for different models to share a gadget snap.

Canonical publishes some reference gadget snaps as well as gadget snaps for main Canonical models such as official Ubuntu Core VMs on various certified public clouds, as well as general purpose computing images for popular physical devices like the 64-bit x86 PC and Raspberry Pi 2 and 3.

Defining a gadget snap

The gadget snap has a meta/snap.yaml which may have the same metadata as application snaps, but must be defined with type: gadget explicitly. It must also hold an additional meta/gadget.yaml file with the following content:

# Default configuration options for other snaps, applied on installation.
defaults:
    <snap-id>:
        <key>: <value>

# If device-tree is specified, `dtbs/<filename>` must exist in kernel or
# gadget snap (depends on origin) and `snap_device_tree_origin` and
# and `snap_device_tree` are made available for u-boot and grub .
device-tree: <filename>
device-tree-origin: kernel


# Volumes defining the structure and content for the images to be written
# into one ore more block devices of the gadget device.
volumes:
    <volume-id>:
        bootloader: grub | u-boot
        (WRITE ME)
        structure:
            (WRITE ME)

Bootloader configuration

The bootloader configuration is expected to be at the toplevel of the gadget snap. The filename must be either grub.conf or u-boot.conf, depending on which bootloader was specified in the respective gadget.yaml field.

A cloud-init configuration may also be provided at the top level of the gadget snap as cloud.conf.

Sample configuration files may be found in the reference gadget snaps.

The prepare-device hook

WRITE ME

Clone this wiki locally