Hardware interfaces

Hardware IO (input/output) interfaces, including the serial-port, gpio, gpio-chardev and i2c interfaces, are designed to be used on devices running Ubuntu Core. These interfaces are exposed as slots from a device’s gadget snap which is used to define and configure a device’s system properties.

This approach is more robust because it allows the gadget snap providing the slot to centralise and arbitrate the connection conditions. These conditions include which other snaps, identified by their snap ID, can connect to the slots the gadget offers and, consequently, gain privileged access to the hardware. For the application snap, usually no change is required other than to declare and use an appropriately-configured plug.

The following are exeptions to the above, and can be used without being declared in the gadget snap:

See Supported interfaces for a complete list of interfaces.

The extent of access an interface has is granted through both connection permissions and the specifics of the interface connections being requested.

  1. Connection permissions: auto-connect | privileged | super-privileged
    Connection requirements are dependent on which store a developer is using.
    • Global Snap Store: privileged and super-privileged interfaces require store approval because of the level of trust and permissiveness these interfaces have, which is also why certain interfaces need certain oversight. See Permission requests for further details.
    • Dedicated Snap Store: trust and permissiveness are now the responsibility of the store owner, and many privileged interface connections can be self-served and defined within the dedicated snap store and the device context.
  2. Interface connections: hardware IO interfaces | app-provided interfaces | other interfaces
    • Hardware IO interfaces: These require either a slot to be defined by a device’s gadget snap or an interface with Hotplug support, in which case the slot appears from the system snap.
      • An unconstrained auto-connection cannot be used because there may be many slots of a given interface, resulting in ambiguity that requires an extensive set of store rules to manage and maintain.
      • Each plug should therefore be connected to a slot, for example:
        • green led plug on app => green led slot on gadget
        • red led plug on app => red led slot on gadget
    • App-provided interfaces: slots are defined by apps, or occasionally from the gadget snap,
    • Other interfaces: For more system level access, slots are provided by the system snap.

Code examples

The gadget snap definition for the reference Raspberry Pi Ubuntu Core image contains interface definitions for various hardware IO interfaces on the system, including slots for each specific GPIO pin, i2c connections, the Bluetooth serial port, and the generic serial ports:

slots:
  bcm-gpio-0:
    interface: gpio
    number: 0
  bcm-gpio-1:
    interface: gpio
    number: 1
  bcm-gpio-2:
    interface: gpio
    number: 2
[...]
  i2c-0:
    interface: i2c
    path: /dev/i2c-0
[...]
  bt-serial:
    interface: serial-port
    path: /dev/ttyAMA0
[...]
  serial0:
    interface: serial-port
    path: /dev/ttyS0
  serial1:
    interface: serial-port
    path: /dev/ttyS1

On a Raspberry Pi, the above hardware IO interfaces are accessible to apps from the system snap without requiring any further configuration.

InterfaceDescriptionCategoriesAuto-connect
device-buttonsuse any device-buttonsHardware, Developerno
dspenables the control of digital signal processors (DSPs)Hardware, Developerno
dvballows access to all DVB devices and APIsHardware, Developer, Mediano
fpgapermits access to an FPGA subsystemHardware, Developerno
framebufferaccess to universal framebuffer devicesHardware, Developerno
gpioaccess specific GPIO pinsGPIO, Hardware, Developerno
gpio-chardevaccess specific GPIO chardev lines.GPIO, Hardware, Developerno
gpio-memory-controlallows write access to all GPIO memoryGPIO, Hardware, Developerno
hardware-observeaccess hardware informationSystem, Hardwareno
hardware-random-controlprovide entropy to hardware random number generatorSystem, Hardwareno
hardware-random-observeuse hardware-generated random numbersSystem, Hardwareno
i2caccess i²c devicesSystem, Hardwareno
iioaccess IIO devicesSystem, Hardwareno
intel_qatprovides permissions for Intel QAT devicesHardwareno
joystickuse any connected joystickHardware, Developerno
media-controlaccess media control devices and Video4Linux (V4L) devicesHardware, Developer, Media, Videono
optical-driveread/write access to CD/DVD drivesStorage, Hardware, Developeryes, unless drive can write
pwmaccess specific PWM channelsSystem, Developer, Hardware, WIPno
raw-inputaccess raw input devices directlySystem, Developer, Hardwareno
raw-usbaccess USB hardware directlySystem, Developer, Hardwareno
serial-portaccess serial port hardwareSystem, Developer, Hardwareno by default, yes with snaps from the same publisher
spiaccess specific SPI devicesSystem, Developer, Hardwareno
u2f-devicesuse any U2F devicesSecurity, Hardware, Developerno
uhidcreate kernel UID devices from user-spaceHardware, Kernel, Systemno
uinputallows write access to /dev/uinputSuper privileged, Hardwareno
uioaccess uio devicesHardware, Systemno

Last updated a month ago.