Skip to content

pi: switch to flash-kernel-piboot for A/B tryboot rollback#44

Merged
passcod merged 7 commits into
mainfrom
pi-flash-kernel-piboot
Jun 21, 2026
Merged

pi: switch to flash-kernel-piboot for A/B tryboot rollback#44
passcod merged 7 commits into
mainfrom
pi-flash-kernel-piboot

Conversation

@passcod

@passcod passcod commented May 14, 2026

Copy link
Copy Markdown
Member

Summary

Replaces the hand-rolled bes-pi-firmware-update + zz-bes-pi-firmware kernel postinst hook on the pi variant with Ubuntu's own flash-kernel-piboot. That package (resolute-only, which we already require for pi) brings:

  • the upstream /usr/sbin/flash-kernel with Method: pi-try for the Pi 5B, replacing our custom kernel→/boot/firmware copy logic,
  • an A/B current/+new/+old/ layout under /boot/firmware/, with piboot-try-reboot.service triggering trial boots and piboot-try-validate.service promoting them on success,
  • automatic rollback when a kernel update boots badly: the EEPROM falls back to current/ and piboot-try-reboot marks the new assets bad to inhibit retries.

This closes the one rollback gap in the image — btrfs + snapper cover the root subvolume but the FAT firmware partition wasn't covered before.

Spec

  • r[image.boot.pi-firmware] reworded — drops "selecting vmlinuz as the kernel" since flash-kernel chooses its own filenames and the bootloader resolves them via os_prefix.
  • r[image.boot.pi-firmware-update] reworded from "must ship a script" to a behavioural requirement (kernel updates propagate to the firmware partition and must not overwrite known-good assets).
  • New r[image.boot.pi-tryboot-rollback] covers the A/B rollback requirement and the Pi 5 EEPROM ≥ 2025-02-11 firmware floor.

Build changes

  • image/packages.sh: drop the stale "no flash-kernel" rationale comment.
  • image/configure.sh: install flash-kernel-piboot inside the pi branch right after writing config.txt (the awk-based migrator in flash-kernel reads from config.txt, so the file must exist when the postinst runs). The explicit invocation after dracut --force now calls flash-kernel instead of the deleted helper.
  • image/files/pi/config.txt: drops the redundant kernel= / initramfs lines (flash-kernel populates /boot/firmware/current/vmlinuz and /boot/firmware/current/initrd.img and the os_prefix=current/ directive added by migrate-config resolves them).
  • image/files/pi/bes-pi-firmware-update and image/files/pi/zz-bes-pi-firmware deleted.
  • tests/test-image-structure.sh asserts the new layout and the absence of legacy paths.

Migration

scripts/migrate-pi-to-piboot.sh is a one-shot, idempotent migration for already-flashed images: pre-flights the variant, mount and EEPROM date (via vcgencmd bootloader_version); installs flash-kernel-piboot; removes the legacy helper; runs flash-kernel to trigger the package's own migrate() (which moves existing assets into current/, rewrites config.txt with os_prefix=, and writes autoboot.txt with tryboot_a_b=1); then verifies the new layout. A subsection in docs/GUIDE-IMAGES.md points operators at it.

@passcod passcod mentioned this pull request May 14, 2026
…kernel

flash-kernel's main() bails out inside a chroot (the qemu-aarch64
build environment), and its migrate() only copies what's at
/boot/firmware/ root into current/ -- nothing on a fresh image. The
postinst and the explicit invocation after dracut were both silent
no-ops, so the A/B layout never landed and test-image-structure.sh
failed seven assertions.

Build the layout ourselves instead: ship config.txt in its post-migrate
form (os_prefix= keys, dtparam=watchdog=on for the tryboot fallback
watchdog), and after dracut populate /boot/firmware/current/ with the
kernel, initramfs, DTB, overlays and GPU firmware blobs, mark
current/state=good, and write autoboot.txt with tryboot_a_b=1.

flash-kernel-piboot stays installed for the runtime mechanism --
/etc/kernel/postinst.d/zz-flash-kernel handles future kernel upgrades
on the running device, where machine detection and the chroot guard
are no longer in the way.
@passcod passcod force-pushed the pi-flash-kernel-piboot branch from 27e8d29 to bd32968 Compare June 21, 2026 11:44
@passcod passcod merged commit 741deb3 into main Jun 21, 2026
64 of 67 checks passed
@passcod passcod deleted the pi-flash-kernel-piboot branch June 21, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant