Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
567f901
docs: record the boot baseline for beaglebone_black
Oct 27, 2026
8a5e862
specs: specify A/B atomic OTA updates with automatic rollback
Oct 27, 2026
74ece96
specs: plan A/B OTA, with a two-tier development CA
Oct 28, 2026
07b06ca
specs: break A/B OTA into 45 dependency-ordered tasks
Oct 28, 2026
894b8e4
build: add the development signing material and its make target
Oct 28, 2026
0af248a
board: move the U-Boot environment to raw MMC and arm the watchdog
Oct 28, 2026
87667f1
board: lay out the SD card for two OS slots
Oct 28, 2026
d455767
docs: record the T016 hardware evidence, and what it did not prove
Oct 28, 2026
cef0a6b
board: make the running slot read-only and give the device its /data
Oct 28, 2026
2ac5f5c
board: seed the factory image with only slot A eligible
Oct 28, 2026
a3ce015
board: keep the random seed on /data, and record the second US1 capture
Oct 28, 2026
0728e12
docs: User Story 1 passes its boot-time budget, at 10.51 s
Oct 28, 2026
91a0996
specs: confirm a last-resort boot like any other, and say that it was…
Oct 28, 2026
86f2085
specs: record the bundle delivery path and the clock that rejects the…
Oct 28, 2026
e87c28a
board: raise the clock to the image build time at boot
Oct 28, 2026
3937fdc
specs: make the target clock a requirement, and leave a note for late…
Oct 28, 2026
53edd6a
board: build the signed update bundle with the image
Oct 28, 2026
bbb2f49
board: confirm the booted slot good only when four local conditions hold
Oct 28, 2026
3ac276e
board: build the RTC driver in so the clock floor is the last writer
Oct 28, 2026
520f1aa
docs: record the first hardware boot, and what it corrected
Oct 28, 2026
308c00a
docs: T046 and T027 confirmed on hardware, second boot
Oct 28, 2026
30c48e9
board: give eth0 a static address for the development bench
Oct 29, 2026
d6cfccb
specs: deliver the bundle over a static address, and record the first…
Oct 29, 2026
148947a
docs: the bundle crosses the cable intact, and lands in /data
Oct 29, 2026
f95075c
board: check the bundle's signing certificate for the code-signing pu…
Oct 29, 2026
44b167e
docs: the first install failed on certificate purpose, and what it sh…
Oct 29, 2026
4ae0c69
board: let RAUC mount a bundle on this image
Oct 29, 2026
40a54ec
docs: the second install attempt, and what rauc install needs from th…
Oct 29, 2026
500cd0d
board: refuse an installation while an update is pending or another o…
Oct 29, 2026
1c7e147
docs: the first install and slot switch, and the check that was not e…
Oct 29, 2026
bc41cc3
docs: FR-009 holds on hardware, and the handler arrived over the air
Oct 29, 2026
40f5569
docs: power loss before the first boot passes, and the procedure for …
Oct 29, 2026
92e82b4
docs: T030 trial 1 passes, and says how early it was cut
Oct 29, 2026
d2b6c1a
docs: T030 trial 2 passes, cut a second into the write
Oct 29, 2026
4686f1c
docs: T030 trial 5 passes, cut in the pause at 99%
Oct 29, 2026
c06c6e8
docs: close T030 with three trials run and two waived by the user
Oct 29, 2026
80f7af5
docs: a slot left bad by the cut trials takes the next install (FR-015)
Oct 29, 2026
fb19ed4
board: arm the watchdog at probe and hand it to a feeder only once co…
Oct 29, 2026
bfed9fb
docs: do not point the watchdog check at a sysfs file this kernel doe…
Oct 29, 2026
261208a
docs: the feeder holds /dev/watchdog, as seen on the board
Oct 29, 2026
c468d98
docs: the watchdog resets a board whose feeder died, and the command …
Oct 29, 2026
561f8c8
docs: a hung kernel is reset in 24 s, and the table of reset times is…
Oct 29, 2026
d7c4fb8
docs: scenario B reported by the user, with only the last boot captured
Oct 29, 2026
2544cfb
docs: a slot that never confirms is retired in three resets of 49 s each
Oct 29, 2026
ca79941
docs: close T032 and T034 with the trials waived, and flag T031's mis…
Oct 29, 2026
48b7c3e
build: make check lints overlay scripts and the card layout's agreement
Oct 29, 2026
edd8d25
build: script the bundles that scenario 7 must be refused, and docume…
Oct 29, 2026
b1c0217
board: make the health failure record readable on its own
Oct 29, 2026
6d5dbc6
docs: bring README and CLAUDE.md up to the A/B image
Oct 29, 2026
0153247
docs: record the A/B image's footprint, and verify a clean checkout
Oct 29, 2026
3c851e8
build: a board-side helper that turns each refusal check into one com…
Oct 30, 2026
2c5c050
docs: five untrusted bundles refused on the board, each for its own r…
Oct 30, 2026
d6a8e38
docs: status reporting on the board, and what it does not say
Oct 30, 2026
005bca6
board: add ota-status, one command that says where an A/B device stands
Oct 30, 2026
aac6c0e
docs: ota-status read on the board in four states, T039 closed
Oct 30, 2026
5447d90
board: last resort boots slot A, with ota_fallback_slot as the workar…
Oct 30, 2026
54eaf72
docs: T031 last-resort path reported working on the board
Oct 30, 2026
a3814ce
docs: T035 run on the board, a slot that cannot write the boot state …
Oct 31, 2026
8f2448a
docs: boot time of the A/B image measured, 11.61 s against a 12.65 s …
Oct 31, 2026
7ba1a14
docs: T033 run on the board, a kernel that cannot boot is retired and…
Oct 31, 2026
0ea1e81
docs: index of the hardware evidence for feature 002, T044 closed
Oct 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The Dockerfile only installs packages: it never COPYs anything from the repo,
# which is bind-mounted at /workspace when the container runs. Everything here is
# therefore context the daemon would upload and never read.
/output/
/dl/
/keys/
/.git/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Board selected by the last `make <board>_defconfig`
/.current_board

# Development signing material, generated by `make ota-dev-keys`
/keys/

# Local editor / OS noise
.vscode/
.idea/
Expand Down
4 changes: 2 additions & 2 deletions .specify/memory/constitution.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ every change and MUST NOT regress without justification.
cache size, `rootfs.ext4` and boot partition usage, artifact size) are recorded in README.md
under "Checks and CI" and are the reference for the thresholds above. Both partitions are
currently below the 80% limit.
- TODO(PERF_BASELINES): still to record in the README: time-to-login and a local incremental
build time.
- TODO(PERF_BASELINES): still to record in the README: a local incremental build time.
Time-to-login is recorded (`docs/boot-baseline-beaglebone-black.md`, measured 2026-10-27).

Rationale: embedded targets are resource-constrained and a one-hour build makes needless rebuilds
expensive.
Expand Down
83 changes: 76 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ make docker-check # docker-build, then `make check` in the con
make list-boards # boards = configs/<board>_defconfig
make beaglebone_black_defconfig # select a board; output goes to output/<board>/
make build # full build; images land in output/<board>/images/
make check # static checks (shell lint, defconfig round-trip, image layout)
make check # static checks (shell lint incl. overlay init scripts, defconfig round-trip, image layout, storage layout agreement)
make menuconfig # any other target is forwarded to Buildroot for the board
make savedefconfig # writes back to configs/<board>_defconfig
make linux-menuconfig # also <pkg>-rebuild, clean, ...
Expand All @@ -46,12 +46,21 @@ edit persist on the host.

```
configs/<board>_defconfig one per board (and variants, e.g. <board>_dev_defconfig)
board/ota/common/ shared by every board: rootfs_overlay/, post-build.sh
board/ota/<board>/ board-only: rootfs_overlay/, post-image.sh, genimage.cfg, ...
board/ota/common/ shared by every board: rootfs_overlay/ (init.d/S00ota-clock, S99ota-health,
usr/lib/ota/pre-install), post-build.sh
board/ota/<board>/ board-only: rootfs_overlay/ (etc/fstab, fw_env.config, rauc/system.conf,
network/interfaces), post-image.sh, genimage.cfg, linux.config,
uboot.config, uboot-env.txt
package/<name>/ internal packages; add a `source` line to package/Config.in
patches/<pkg>/ BR2_GLOBAL_PATCH_DIR: patches and .hash files per package
external.desc, Config.in, external.mk BR2_EXTERNAL glue
scripts/check.sh static checks behind `make check` (POSIX sh)
scripts/gen-dev-keys.sh `make ota-dev-keys`: development CA + signing pair into keys/dev/ (gitignored)
scripts/make-untrusted-bundles.sh the bundles a device must refuse (quickstart scenario 7); output/ only
scripts/make-broken-kernel-bundle.sh a signed bundle whose kernel is garbage (quickstart scenario 5); output/ only
keys/dev/ development signing material, never committed
specs/002-ab-ota-rauc/ A/B feature: spec, plan, research (R1-R9), contracts/, quickstart, tasks
docs/logs/ hardware captures that back the claims in the spec and README
.github/workflows/ CI: ci.yml (checks on branch push / PR to master), build.yml (boards, manual/tag only)
```

Expand All @@ -74,10 +83,34 @@ Adding a board: create `board/ota/<board>/` and `configs/<board>_defconfig`, the
a `.hash` for custom-version kernel/U-Boot in `patches/{linux,linux-headers,uboot}/`. Bumping
`BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE` or the U-Boot version means adding its hash line there
(a single `.hash` file may hold several versions, so boards can share it).
- **Kernel/U-Boot configs** currently come from in-tree defconfigs (`omap2plus`, `am335x_evm`).
To customize, switch the defconfig to `BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG` with
`BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_OTA_PATH)/board/ota/<board>/linux.config"`
and generate it with `make linux-update-defconfig` (same pattern for U-Boot).
- **Kernel and U-Boot use the board's own configs**, not the in-tree defconfigs:
`board/ota/<board>/linux.config` and `uboot.config` (`BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG`,
`BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG`), written back with `make linux-update-defconfig` (same pattern
for U-Boot). Several options are load-bearing and fail only on hardware: SquashFS (zlib) and the loop
device (RAUC mounts a bundle), the RTC driver built in, `omap_wdt` and the watchdog core built in with
`omap_wdt.early_enable=1`. `uboot-env.txt` is compiled into the SPL as well as U-Boot, and the AM335x
SPL has little SRAM: growing it much past ~2.9 KB breaks the link with `region '.sram' overflowed`
unless something else in the SPL is dropped (`CONFIG_SPL_NET` already is).
- **The card layout, the reserved region and the one counter.** `beaglebone_black` uses an MBR with four
primaries: p1 boot (32 MiB, `MLO` + `u-boot.img` only, never updated), p2 and p3 the OS slots (512 MiB
ext4, read-only, each with its own kernel), p4 `/data` (256 MiB). The boot-selection state is **not** a
partition: two raw copies at `0x80000` and `0xA0000` (128 KiB each), written by U-Boot's `saveenv`
and by `fw_setenv`. `BOOT_ORDER` and `BOOT_<slot>_LEFT` in that environment are the **only** boot
attempt counter: U-Boot's own bootcount (`CONFIG_BOOTCOUNT_*`) is deliberately off, because it lives in an
RTC scratch register that a power cycle loses. Never add a second counter. Contract:
`specs/002-ab-ota-rauc/contracts/storage-layout.md`; `make check` compares it across six files.
- **Signing material and the three `OTA_*` variables.** `make ota-dev-keys` writes a two-tier development
CA into `keys/dev/` (gitignored); a build of a RAUC board refuses to start without it (`check_keys` in the
`Makefile`). `OTA_KEYRING` (the CA certificate, installed as `/etc/rauc/keyring.pem`), `OTA_SIGNING_CERT`
and `OTA_SIGNING_KEY` default to `keys/dev/` and are exported to the post-build and post-image scripts;
override them to sign with other material. A lost *signing* key is answered by a new certificate under the
same CA, no reflash; replacing the *CA* strands every flashed device. The setting that
matters on the device is `check-purpose=codesign` in `system.conf`: without it every bundle is refused.
- **What only hardware shows.** The host cannot run RAUC's mount, the kernel, the watchdog or the bootloader,
and in this feature a green `make check` plus host stubs coexisted with seven real defects (RTC module
overwriting the clock, `RAUC_SYSTEM_BOOTED_BOOTNAME` holding a device path, `check-purpose`, `mountprefix`,
SquashFS missing, no pending-install refusal, and the watchdog being stopped at probe). Stubs encode the
author's assumption. A boot-affecting change needs a board run, and its log goes in `docs/logs/`.
- **The image runs as a non-root user (`br`)** because Buildroot refuses to build as root.
`make docker-build` passes the host UID/GID as build args and `docker-shell` runs with `-u`
the same IDs, so files in the mount keep host ownership.
Expand All @@ -97,6 +130,42 @@ Adding a board: create `board/ota/<board>/` and `configs/<board>_defconfig`, the
builds in the container with the same single `/workspace` mount; the runner's UID/GID reach the
image through `make docker-build`. A green build is not a boot test: boot-affecting changes
still need the manual smoke test from the constitution.
- **The target clock is a floor, not the real time.** The boards here have no battery-backed RTC:
the kernel clock starts at 1970-01-01, and the board's RTC driver then sets it to the RTC's
power-on value, 2000-01-01 (BeagleBone Black measured). That driver must be **built in**
(`CONFIG_RTC_DRV_OMAP=y`): as a module it registers seconds into boot and overwrites anything
an init script set before it (seen on hardware, research R8). `board/ota/common/post-build.sh`
writes `BUILD_DATE` (epoch seconds) to `/etc/build-info`, and
`board/ota/common/rootfs_overlay/etc/init.d/S00ota-clock` raises the clock to it at the start of
boot, only when the clock is earlier. Anything on the device that checks a time window
(`rauc install` certificate validity, TLS, token expiry, a log or file that needs a true
timestamp) therefore sees the **image's build time** after a cold boot, never the real time.
When writing a spec or plan that touches the target's clock: (1) a certificate or token issued
*after* the running image was built is "not yet valid" on that device until something sets the
clock; (2) timestamps on the device are wrong by however long it was off, so do not use them as
evidence or ordering across reboots; (3) real time needs an RTC or a time source and is its own
feature, not an assumption; (4) a new build-time artefact that the device validates must be
created *before* the image is built (this is why `check_keys` refuses to build without the keys);
(5) `SOURCE_DATE_EPOCH` is deliberately not the floor, since a commit time can predate the
certificate. Rationale and the one known gap: `specs/002-ab-ota-rauc/research.md` R8, FR-033.
- **`ota-status` is the status command.** Plain `rauc status` has no versions and calls any slot with attempts
left `good`, so `ota-status` (overlay `usr/bin`) says running / confirmed / pending / standby / retired /
unusable / empty in words. "Confirmed" comes from the marker `/run/ota-confirmed` that `S99ota-health` writes
when it passes; do not infer it from the counter or from RAUC's `good`.
- **The bench network is a fixed address.** `beaglebone_black` has `192.168.0.2/24` in
`rootfs_overlay/etc/network/interfaces`, for a board cabled straight to the build host (`192.168.0.1`), which
serves bundles with `python3 -m http.server`. There is no DHCP server on that cable and no SSH server
on the image; delivering a bundle is outside the A/B feature (research R8).
- **`CONFIG_CMDLINE` is read last.** The beaglebone kernel uses `CONFIG_CMDLINE_EXTEND`, and
`drivers/of/fdt.c` appends the built-in string *after* what U-Boot passes (the Kconfig help says
the opposite), so on a duplicate the built-in value wins. It carries only `omap_wdt.early_enable=1`,
without which the driver stops the watchdog U-Boot started (research R5). Never put `root=` or
`console=` there: `root=` is set per slot by `uboot-env.txt`, and a built-in one would override it.
- **`make check` also guards the card layout.** For a RAUC board it compares the numbers that six
files must share (`genimage.cfg`, `uboot.config`, `fw_env.config`, `uboot-env.txt`, `system.conf`,
`fstab`): state offsets and size, partition numbers of slot A, slot B and `/data`. A mismatch there
is silent on a device and shows up as every update rolling back. It also lints and checks the mode of
overlay scripts without an extension (init scripts, RAUC handlers), found by their shebang.
- **`make check`** compares the regenerated minimal defconfig against the working-tree file in a
temp file (never writes `configs/`, never relies on git state). New boards need no CI edits;
they are discovered from `configs/`.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
xz-utils \
# --- Static checks (make check) ---
shellcheck \
# --- Update bundle signing (make ota-dev-keys) ---
openssl \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# 'which' and 'awk' must resolve; /usr/bin/file is required by Buildroot
Expand Down
27 changes: 25 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ BUILDROOT_DIR := $(ROOT_DIR)/buildroot
DL_DIR := $(ROOT_DIR)/dl
BOARDS := $(patsubst configs/%_defconfig,%,$(wildcard configs/*_defconfig))

# Signing material for OTA update bundles, read by the post-build and post-image
# scripts. Overriding these points a build at other material (staging,
# production, a PKCS#11 URL) without editing a script. Generated, never
# committed: see scripts/gen-dev-keys.sh.
KEYS_DIR ?= $(ROOT_DIR)/keys/dev
OTA_KEYRING ?= $(KEYS_DIR)/dev-ca.cert.pem
OTA_SIGNING_CERT ?= $(KEYS_DIR)/dev-signing.cert.pem
OTA_SIGNING_KEY ?= $(KEYS_DIR)/dev-signing.key.pem
export OTA_KEYRING OTA_SIGNING_CERT OTA_SIGNING_KEY

# BOARD=<name>, written by <board>_defconfig; `make BOARD=x ...` overrides it
-include .current_board

Expand All @@ -23,8 +33,15 @@ check_env = @test -f /.dockerenv || { \
echo "No Buildroot tree: 'git submodule update --init' first." >&2; exit 1; }
check_board = @test -n "$(BOARD)" || { \
echo "No board selected: 'make <board>_defconfig' first (boards: $(BOARDS))." >&2; exit 1; }

.PHONY: help list-boards build check docker-build docker-check docker-shell
# Boards that sign update bundles cannot build without a signing key. Checked
# here rather than in post-build.sh so a missing key costs no build time.
check_keys = @! grep -q '^BR2_PACKAGE_RAUC=y' configs/$(BOARD)_defconfig 2>/dev/null \
|| test -f $(OTA_SIGNING_KEY) \
|| { echo "Board $(BOARD) signs update bundles, but this key is missing:" >&2; \
echo " $(OTA_SIGNING_KEY)" >&2; \
echo "Generate the development material first: make ota-dev-keys" >&2; exit 1; }

.PHONY: help list-boards build check ota-dev-keys docker-build docker-check docker-shell
.NOTPARALLEL:

help:
Expand All @@ -39,6 +56,7 @@ help:
@echo " savedefconfig, <pkg>-rebuild, clean"
@echo " make list-boards - list boards in configs/"
@echo " make check - static checks: shell lint, defconfig round-trip, image layout"
@echo " make ota-dev-keys - generate the development signing CA and key (once)"
@echo "Current board: $(or $(BOARD),<none>)"

list-boards:
Expand Down Expand Up @@ -68,6 +86,10 @@ check:
$(check_env)
@sh scripts/check.sh

ota-dev-keys:
$(check_env)
@sh scripts/gen-dev-keys.sh $(KEYS_DIR)

%_defconfig:
$(check_env)
@echo "BOARD=$*" > .current_board
Expand All @@ -76,6 +98,7 @@ check:
build:
$(check_env)
$(check_board)
$(check_keys)
$(call br,$(BOARD))

# Keep the catch-all below from trying to remake these
Expand Down
Loading