Skip to main content

Firmware Update State Machine

This diagram mirrors the firmware update sequence in src/kerrigan/services/fleet_manager/firmware_update.py. The colored groups show where Kerrigan can restart a failed or interrupted update without replaying every previous state.

Recovery Groups​

GroupStatesRetry entry pointWhy this is safe
Prepare netbootpending, preparing_uboot, rebooting_to_netbootpreparing_ubootRetry first checks /proc/cmdline. A running RAM netboot advances to verifying_netboot; otherwise U-Boot preparation is repeated. Late TFTP evidence moves a paused preparation checkpoint to waiting_for_netboot_ssh, followed by netboot verification.
Await netbootnetboot_started, waiting_for_netboot_sshwaiting_for_netboot_sshNetboot has already been requested or observed, so retry waits for the netboot OS to become reachable.
Restage and flash imageverifying_netboot, netboot_completed, transferring_troot, transferring_emmc, image_ready, updating_troot, flashing_emmcverifying_netbootKerrigan revalidates that the board is netbooted, then stages images again before flashing. If the board came back from eMMC during retry, recovery redoes U-Boot setup and netboots before transfer.
Await updated OSupdated_rebooting, waiting_for_updated_emmc_sshwaiting_for_updated_emmc_sshFlashing has already completed or reboot has begun, so retry waits for the updated eMMC OS to reconnect.
Post-flash configurationconfiguring_passwordless_sudo, configuring_dns, configuring_time, installing_sima_cli, remounting_nvme, installing_device_agentsame stateThese states are active update states but are not grouped into an earlier recovery checkpoint; retry resumes from the current configuration step.

Terminal states are completed, failed, and cancelled. In the current manager, ordinary runtime exceptions pause the job for retry instead of marking it failed. A cancelled or failed job can still be retried if Kerrigan recorded a resumable last_active_state in job metadata.

U-Boot preparation on Platform 2.1 and 3.0​

Recovery preserves the original /boot mount mode, temporarily remounting it writable when necessary. It saves the environment files before changes, detects the bootloader's single-file or redundant FAT environment format, and validates CRC data before updating boot settings. Legacy 2.1 images without u-boot.bin require the known redundant layout in /etc/fw_env.config.

The temporary configuration is created outside /boot. Failed preparation restores the saved environment and prevents reboot; a failed read-only remount also prevents reboot. Backups remain under /boot/kerrigan-netboot-backup.*. Kerrigan continues to use DHCP for recovery netboot.

eMMC preparation before recovery flashing​

Before writing a whole-device image, Kerrigan identifies mounted filesystems by block-device identity, including eLxr 3.x LVM volumes such as /data and legacy 2.1.x partition mounts. It unmounts nested mounts first, deactivates the eMMC's LVM volumes, and verifies that no mounts or device mappings remain. Unrelated storage such as NVMe is left alone.

Recovery stops before writing if the eMMC hosts the root filesystem, has active swap, or any preparation step fails. Busy mounts must be released before retrying; Kerrigan does not force or lazily unmount them. Both dd and bmaptool use these checks. Decompression and write errors fail the job, and dd flushes writes before completion. This preparation does not apply to A/B OTA updates.