Preparing an Image

Build for Unofficial RPi 4 ARM64 Ubuntu 18.04.3 server

This builds on the work of James Chambers and others begun in this blog post and codified at https://github.com/TheRemote/Ubuntu-Server-raspi4-unofficial.

Mr. Chambers work, in turn, builds on Sakaki’s automated 64-bit bcm2711 kernel config and tweaks.

The work consists of compiling and applying arm64 kernel, modules and RPi 4 firmware to a an official Ubuntu 18.04.3 preinstalled server image for RPi3+, tweaking slightly, then repackaging as a Pi4-compatible pre-installed image.

This is a refactoring of that work, splitting one monolithic script into four distinct phases. The original work was designed to only operate on a Raspberry Pi 3+ or 4, however with this refactoring the first three phases can be run on any linux machine (tested on Ubuntu amd64) and only the final phase with the chroot work must be run on a Pi.

There is an alternate fourth phase which will allow you to bootstrap a sub-optimal pi4 build so you can self-host and run the better 4th phase to produce a stable image.

There are a series of scripts in this directory, run them in the following sequence:

  1. toolchain.sh this will build an arm64 toolchain in the directory toolchains. This allows cross-compilation of an arm64 target on say X86 hardware
  2. kfetch.sh fetches firmware, linux kernel source (RPi version) and rpi-tools. This script also sets kernel compilation options above and beyond default bcm2711_defconfig, and pulls the preinstalled rpi3 arm64 ubuntu image from Canonical
  3. kbuild.sh compile the kernel and modules and prepare for installation
  4. pimagebuild.sh makes a copy of the rpi3 arm64 image from Canonical, mounts it and installs the kernel built by kbuild.sh and firmware downloaded by kfetch.sh, chroots into the image and updates initramfs amongst other minor tweaks. This script must be run from a Pi4

As an alternative to step 4, if bootstrapping cross-architecture, imagebuild.sh makes a copy of the rpi3 arm64 image from Canonical, mounts it and installs the kernel built by kbuild.sh and firmware downloaded by kfetch.sh but skips the final chroot work. This will be sufficient to bootstrap a Pi4 image where you can run pimagebuild.sh to produce the desired stable image.

The directory bootfiles contains Pi4 firmware, a config.txt (Pi4 firmware configuration), a cmdline.txt (linux kernel configuration) for installation onto our image.

The script clean.sh cleans (removes) built assets and downloaded software.

Images

The images below are ready to flash onto a microSD card and optionally a USB3 drive: