This repository contains the source for an Ubuntu Core gadget snap that runs universally on all the Raspberry Pi boards currently supported by Ubuntu Core (Raspberry Pi 2B, 3B, 3A+, 3B+, 4B, Pi Zero 2 W, Compute Module 3, Compute Module 3+ and Compute Module 4).
Building with snapcraft(see below) will obtain various components from the bionic-updates archive, including:
On core builds, a silent boot with a splash screen is included. The splash
screen binary comes from
git://git.yoctoproject.org/psplash.
Please see the psplash/
sub directory for patches and adjustments in use.
Gadget snaps are a special type of snaps that contain device specific support code and data. You can read more about them in the snapcraft forum:
https://forum.snapcraft.io/t/the-gadget-snap/
Please report all issues here on the github page via: https://github.com/snapcore/pi-gadget/issues
This gadget snap comes with a boot splash. To change the logo you can add a new
png file to the psplash subdirectory of this tree, adjust the "SPLASH=" option
in psplash/config
to point to this file and rebuild the gadget.
To turn off the splash screen completely please edit configs/core/cmdline.txt
and remove the splash
and the vt.handoff=2
keywords from the default kernel
command line.
This repository contains the following branches for Ubuntu Core versions and the two Raspberry Pi architectures(armhf and arm64):
There are two general approaches to building the pi-gadget snap: managed and manual managed.
The easiest managed approach is to simply run snapcraft
within the root of
this repository on a classic Ubuntu installation, such as an amd64-based Ubuntu
server or desktop, or even an arm64-based Ubuntu running on a Raspberry Pi.
Snapcraft will create either a Multipass or
LXD build environment and
produce the gadget snap automatically.
Another managed option is to run snapcraft remote-build
. This command
offloads the snap build process to the Launchpad build
farm, pushing the potentially foreign
architecture snap back to your machine when the build completes. See Remote
build for further details.
Managed build environments will mirror the distro series declared in the base
setting of the gadget's snapcraft.yaml, such as core20 or core18.
Manually managed builds include building the gadget snap on Ubuntu Core running
on a Raspberry Pi, for example, and systems where you want to first manually
isolate a build from the host system. In both cases, you first manually
create an LXD instance from which you can run snapcraft --destructive-mode
to
use the instance as the build environment.
Examples of both a managed build and a manually managed build are outlined below.
This is likely the most convenient build method as the gadget is automatically built within a container on the host machine.
To build the gadget snap, switch to the appropriate branch and simply
run the snapcraft
command:
$ git clone https://github.com/snapcore/pi-gadget
$ cd pi-gadget
$ git checkout 20-armhf
$ snapcraft
[...]
Snapped pi_20-1_armhf.snap
By default, snapcraft attempts to build the gadget snap in a Multipass container, isolating the host system from the build system. Building on LXD is another option that can be faster, especially when iterating over builds.
If Multipass or LXD is not already installed, Snapcraft will install the appropriate packages and run through their setup before building the gadget.
Both Multipass and LXD allow for the build architecture to differ from the
run-on architecture, as defined by the architecture
stanza in the
snapcraft.yaml for the gadget snap:
architecture
- build-on: [amd64, armhf]
run-on: armhf
See Architectures for more details on defining architectures and Image building for instructions on how to build a bootable image that includes the gadget snap.
This method allows for the gadget snap to be built on the same hardware the gadget is intended for.
To build the gadget snap:
Running the following commands on the Raspberry Pi will perform the above process:
$ sudo snap install lxd
$ sudo lxd init --auto
$ sudo lxc launch ubuntu:20.04 focal
$ sudo lxc shell focal
# snap install snapcraft --classic
# git clone https://github.com/snapcore/pi-gadget/
# cd pi-gadget
# snapcraft --destructive-mode
[...]
Snapped pi_20-1_arm64.snap
# exit
$ lxc file pull focal/root/pi-gadget/pi_20-1_arm64.snap .
See Image building for instructions on how to build a bootable image that includes the gadget snap.