Skip to content

002 ab ota rauc - #3

Merged
sinbadincr merged 61 commits into
masterfrom
002-ab-ota-rauc
Oct 31, 2026
Merged

sinbadincr merged 61 commits into
masterfrom
002-ab-ota-rauc

Conversation

@sinbadincr

Copy link
Copy Markdown
Owner

No description provided.

mtriSE and others added 30 commits October 27, 2026 18:36
Capture boot evidence and a timing baseline for the single-rootfs image
before the A/B OTA work in specs/002-ab-ota-rauc/ changes the storage
layout and the boot path. Three grabserial runs give 11.50 s from the
U-Boot SPL banner to the login prompt, with 1.2% spread, so the figure is
precise enough to detect the 10% regression the boot-time budget allows.
/proc/uptime cannot produce this number because it starts counting only
when the kernel does, leaving out the bootloader entirely.

The raw serial logs are kept exactly as captured, including one NUL byte
in run 3 that makes git treat that file as binary; the document says to
grep it with -a and explains the clock reset in its first two lines.

Reading the logs also turned up five facts that feed the A/B work: the
U-Boot environment is a FAT file that does not exist yet, booting goes
through extlinux.conf and never reads uEnv.txt, 2.08 s of the 11.50 s is
the autoboot countdown, a hardware watchdog is already running and the
kernel takes it over, and the boot partition needs only the two
bootloader stages once the kernel moves into the OS slot.

README records the figure and the method. The constitution's
PERF_BASELINES note loses its time-to-login item, which is now recorded,
and keeps the incremental build time still to be measured.

Documentation only: no script, defconfig, Makefile or image input
changed, so none of the checks in Principle IV's table applies.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Add the Spec Kit artifacts for feature 002: two redundant OS slots, an
update that only ever writes the slot that is not running, a slot that
must prove itself healthy before it is recorded as good, and a bootloader
that returns to the last good slot on its own when it does not.

Six decisions are recorded in the spec rather than left to the
implementation, because each one changes what has to be built:

- the kernel, device tree and modules travel inside the OS slot, so a
  rollback can never pair a new kernel with an old userspace;
- the running slot is mounted read-only, which makes "the running slot is
  never modified" enforceable instead of conventional;
- the health confirmation is four local conditions and no network, so a
  board on a bench with no uplink can still confirm a good update;
- the layout is fixed at build time and never resized on the device;
- the development certificate is committed but its private key is not,
  which keeps Principle VII intact, and a documented command generates
  the key with the build naming that command when it is missing;
- the boot-selection state gets a region of its own, in no filesystem and
  outside the bootloader area, with the choice between an unpartitioned
  region and a partition of its own left to research because the four
  MBR primary partitions are already spoken for.

The spec also requires that a slot which hangs after booting is reset by
hardware so the attempt counter can retire it, that the failure record
outlives the reboot which reveals it, and that exactly one boot counter
is active, since the counter inherited from the board's bootloader
configuration lives in an RTC register this board loses on power
removal. The boot-time criterion names the 11.50 s baseline measured in
the previous commit and the method behind it.

Four clarifications were answered during specification and five
amendments after reviewing the baseline; both are logged in the spec.
FR-025 states that it is verified by review rather than by test until a
second board exists.

No code yet: spec, quality checklist and clarification log only.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Phase 0 and Phase 1 artifacts for feature 002. Seven questions had to be
settled before any of this could be written, and four of the answers came
out of reading the boot baseline rather than documentation:

- MBR, not GPT: the AM335x ROM looks through MBR entries for a bootable
  FAT partition and finds nothing on a GPT medium. That spends all four
  primary partitions, so the boot-selection state becomes a reserved
  region rather than a partition of its own, closing the choice FR-001
  deliberately left open.
- The U-Boot environment leaves FAT for raw offsets 0x80000 and 0xA0000
  with a redundant copy. Not because fw_setenv cannot address a FAT file
  -- it can, there is a VFAT example in U-Boot's own fw_env.config -- but
  because every boot attempt writes that environment, and in FAT an
  interrupted write endangers the filesystem holding MLO and u-boot.img.
  ENV_OFFSET must be set explicitly: its ARCH_OMAP2PLUS default of
  0x260000 lands inside partition 1.
- ext4 mounted read-only for the OS slot, 128 MiB inside 512 MiB.
  Squashfs is deferred, not rejected: the kernel lacks CONFIG_SQUASHFS,
  but the real cost is changing the image pipeline and slot type in the
  same breath as the layout and the rollback path.
- One attempt counter. The board's inherited U-Boot configuration already
  enables CONFIG_BOOTCOUNT_AM33XX, which counts in an RTC register this
  board loses on power removal, so it is switched off rather than left
  one grep away from being enabled.
- A custom kernel configuration turns out to be unavoidable:
  CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED=y with an open timeout of 0 makes
  the kernel ping the bootloader's watchdog forever, so a hung slot is
  never reset. The watchdog looks like protection and provides none, and
  FR-032 cannot be met without changing that.
- Development signing material is a two-tier CA, not a single
  self-signed key. The keyring holds the CA, so a lost or compromised
  signing key is answered by issuing a new certificate; with a single
  key, RAUC states you cannot replace an expired certificate or revoke a
  compromised one without updating the keyring, which lives in the rootfs
  and therefore means reflashing. That structure cannot be retrofitted,
  so it belongs in this feature even though only one environment exists.

The plan records two configuration files this feature has to introduce
and why nothing smaller would do, and the constitution check passes all
seven principles with obligations noted against IV, V and VI.

contracts/ fixes the numbers five files must agree on, the environment
variables and device commands, and the signing chain. quickstart.md has
nine hardware scenarios, each naming the success criterion it discharges.

No code yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Phase 2 output for feature 002, plus four corrections to the plan that
writing the tasks forced.

The task list is ordered so the single most expensive mistake is caught
first. T016 proves that fw_printenv in Linux and printenv at the U-Boot
prompt see the same boot-selection state, and that fw_setenv writes reach
the bootloader. If that is wrong, every update rolls back while every
image is sound, and it is the most commonly reported failure in systems
of this shape. It sits at the end of the foundational phase, before any
user story, and the strategy section says not to batch the hardware
verifications to the end for exactly this reason.

User Story 1 is the MVP and carries the brick risk: a board that boots as
before on the new layout, with rauc status answering and the boot-time
budget proven. The remaining stories add updating, rollback, trust and
observability in that order. Fifteen tasks need the board, which is not a
formality: this feature changes the partition layout, the bootloader
environment, the kernel configuration, the bootargs and init, and the
constitution requires a boot smoke test for every one of those.

Three tasks exist only because the boot baseline contradicted an
assumption: one disables a second boot counter nobody knew was enabled,
one fixes a watchdog that looks like protection and provides none, and
one deletes a boot configuration file the board never reads.

The plan corrections, all in the same direction -- prefer an upstream
Buildroot mechanism over scripting of ours:

- CONFIG_ENV_SOURCE_FILE cannot carry the slot-selection script. U-Boot
  requires that file to live inside its own source tree with a .env
  extension and errors out when it is absent, so pointing it at the
  external tree is impossible and using it would mean shipping the boot
  logic inside a patch.
- BR2_TARGET_UBOOT_DEFAULT_ENV_FILE does the job properly: Buildroot
  resolves the path and sets CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE and
  CONFIG_ENV_DEFAULT_ENV_TEXT_FILE, both of which exist in U-Boot
  2026.07.
- BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE turns the same text file into
  uboot-env.bin, so post-image.sh no longer calls mkenvimage itself.
  Note there is no BR2_TARGET_UBOOT_ENVIMAGE; the option lives under
  host-uboot-tools.
- Both mechanisms are needed, because they fail differently. The built-in
  default is what boots the board if the reserved region is unreadable;
  the seeded region is what the running system reads, since fw_printenv
  has no access to the built-in default. An unseeded region fails the
  fourth health condition on the first boot.

No code yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Phase 1 of feature 002. `make ota-dev-keys` generates a development CA and
a bundle-signing pair into the gitignored keys/dev/, and nothing in the
repository becomes a credential: neither private key nor either
certificate is committed.

Two tiers rather than one self-signed key, because that choice cannot be
changed later without reflashing every device. The keyring on a device
holds the CA, so a lost or compromised signing key is answered by issuing
a new certificate; with a single key, RAUC cannot replace an expired
certificate or revoke a compromised one without updating the keyring,
which lives in the rootfs.

The generator refuses to overwrite an existing CA. Replacing it is not an
ordinary regeneration: every image already flashed with the old CA would
be unable to install any bundle, so the way out has to be deliberate.
Both certificate subjects carry NOT FOR PRODUCTION, which shows up in
`rauc info` and `openssl x509 -text`.

`check_keys` runs on the build target rather than in post-build.sh, so a
missing key costs three milliseconds instead of an hour of building, and
the three OTA_* variables are exported so a later feature can point the
build at staging or production material, or at a PKCS#11 URL, without
editing a script.

The Dockerfile gains openssl explicitly rather than inheriting it as a
dependency of ca-certificates. It also gains a .dockerignore: the
Dockerfile never COPYs anything from the repo, which is bind-mounted at
run time, so output/ and dl/ were being uploaded to the daemon on every
`make docker-build` and never read.

Verified in the container: shellcheck clean; `openssl verify` accepts the
chain; the CA shows CA:TRUE with pathlen:0 and keyCertSign, the signing
certificate CA:FALSE with codeSigning; modes are 600 on keys and 644 on
certificates; a second run refuses and changes nothing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Phase 2 of feature 002: the boot-selection state leaves the FAT boot
partition, the slot-selection script becomes a reviewable text file, the
kernel moves into the OS slot, and the watchdog starts being a watchdog.
No layout change yet, so this builds and `make check` passes.

The environment moves to raw sectors 0x80000 and 0xA0000 with a redundant
copy. Not because fw_setenv cannot address a FAT file -- U-Boot's own
fw_env.config documents a VFAT form -- but because every boot attempt
writes that environment, and in FAT an interrupted write endangers the
filesystem that holds MLO and u-boot.img. ENV_OFFSET is set explicitly:
its ARCH_OMAP2PLUS default of 0x260000 would land inside partition 1.

board/ota/beaglebone_black/uboot-env.txt is used twice by Buildroot, as
U-Boot's compiled-in default environment and as the image that seeds the
reserved region. Both are needed: the compiled-in default is what boots
the board if that region is unreadable, and the seeded region is what
fw_printenv reads, since it cannot see the compiled-in default.

Three things found by building rather than by reading, each recorded in
research.md:

- The compiled-in default environment also lands in the SPL, and the
  AM335x SPL has a hard SRAM ceiling. 2916 bytes of boot script overflow
  it by 512 bytes. Two controlled builds isolate it: upstream's
  configuration links cleanly, the same configuration plus the
  environment file does not, and bisecting every option this feature adds
  left the failure in place. CONFIG_SPL_NET goes: the SPL was compiling
  TFTP, NFS and Ethernet for a board that boots from an SD card. MLO
  drops from 110928 to 79008 bytes, which also leaves headroom for the
  script to grow.
- am335x_evm disables CMD_SETEXPR, which the script needs to decrement
  the attempt counter, and CMD_TEST, so the script uses itest.
- RAUC's U-Boot backend runs only fw_printenv and fw_setenv; there is no
  fw_getenv anywhere in it, so no symlink is needed. It stores
  BOOT_<slot>_LEFT as a hexadecimal string, and marking a slot bad
  removes it from BOOT_ORDER as well as zeroing the counter -- so the
  exhausted-slots path handles BOOT_ORDER being empty, not merely every
  counter being zero.

The second attempt counter goes with CONFIG_BOOTCOUNT_LIMIT. The one it
inherited from am335x_evm keeps its count in an RTC register this board
loses on power removal, which is the event the power-cut criterion
exercises five times.

The kernel configuration exists for one reason: with
CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED=y and an open timeout of 0, the
kernel pings the bootloader's watchdog forever while no userspace process
has claimed it, so a slot that boots and then hangs is never reset. The
watchdog looked like protection and provided none. It is now built in
rather than a module, with a 60 second open timeout.

tasks.md carries the ticks for both phases and one ordering correction:
T016 cannot run until T017 puts uboot-env.bin into the image, because an
unseeded region fails its CRC check and the test would prove nothing.

Verified: `make check` passes all nine checks including the defconfig
round-trip; uboot-env.bin is exactly 0x20000 bytes; zImage and the device
tree are installed inside the rootfs; rauc, fw_printenv and fw_setenv are
on the target and host-rauc and mkenvimage on the host; rootfs.ext4 is
128 MiB. No hardware test yet: that is T016.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
T017 of feature 002. Four MBR primaries plus a reserved region, so the
boot-selection state has somewhere to live that no filesystem and no
partition table entry covers:

  0x80000  env, primary         128 KiB   outside the partition table
  0xa0000  env, redundant copy  128 KiB   outside the partition table
  1 MiB    p1 boot  FAT 32 MiB  bootable, type 0x0C, MLO and u-boot.img only
           p2 rootfs.A 512 MiB  populated
           p3 rootfs.B 512 MiB  empty until the first update
           p4 data     256 MiB  reserved; its filesystem arrives with T018

The kernel and device tree are gone from the boot partition, which now
holds 1.65 MiB of 32 MiB. They travel inside each OS slot, so a rollback
can never pair a new kernel with an old userspace, and no update needs to
write the partition that carries the bootloader.

scripts/check.sh had to learn this, which is the part of T040 that T017
makes unavoidable rather than optional: its device-tree rule required
every DTB the kernel builds to be listed in genimage.cfg, which is now
exactly wrong. The two places are mutually exclusive, so a board that
installs the kernel into the rootfs must list neither the DTB nor a kernel
image in the boot partition, and any other board keeps the old
bidirectional rule.

Verified: the MBR carries the 0xAA55 signature and four primaries at the
sizes above, 1313 MiB declared in total, p1 bootable with type 0x0C at LBA
2048; both copies of uboot-env.bin in the image match the built file byte
for byte; boot.vfat holds only MLO and u-boot.img; make check passes all
nine checks.

sdcard.img is 161 MiB rather than 1.3 GB, because genimage leaves the
trailing space of an imageless partition unwritten. That is recorded in
the storage-layout contract along with its one consequence: flashing
leaves stale bytes beyond the end of the file, so the data area needs a
filesystem of its own rather than being mounted on the strength of
whatever the card held before.

T016 is now runnable: the state region exists in the image, so
fw_printenv has something valid to read.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The boot-selection state works in both directions that this capture
covers. U-Boot reads the seeded region rather than falling back to its
compiled-in default, setexpr and saveenv decrement and persist the
counter across a reboot, and fw_printenv in Linux reads exactly the bytes
U-Boot wrote -- so /etc/fw_env.config names the right device, offsets and
size. ext4load pulls a 7.6 MB zImage and the device tree out of the OS
slot, the kernel comes up with root=/dev/mmcblk0p2 ro, and all four
partitions appear.

What it did not prove: the write direction. `fw_setenv BOOT_A_LEFT 2` was
run while the value was already 2, so a write that silently landed
elsewhere would look identical. The log says so rather than letting the
capture read as a full pass, and names the one command that closes it.

Three other things the same capture settles, two of which change later
work:

- The clock starts at 2000-01-01T00:00:00 UTC. This board has no RTC
  backup, so a certificate whose validity window opens at build time is
  not yet valid when a device boots. That was a theoretical worry about
  the staging and production signing work; it is now a measured
  behaviour, and the signing-chain contract carries the figure.
- The watchdog still does not arm. The board sat at an idle shell for 253
  seconds with no userspace watchdog client and was never reset, although
  U-Boot reports starting it with a 60 second timeout and the kernel
  registers omap_wdt. The kernel configuration from T014 was necessary
  but is not sufficient, so FR-032 is not satisfied and T034 would fail
  today. research.md R5 lists three candidates in order of likelihood and
  T032 now starts by finding out which, instead of assuming the config
  change did the job.
- The root filesystem is still remounted read-write at 2.96 s, which is
  the check for T023.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Completes the code for User Story 1: the layout from the previous commit
now has a system that fits it. T016 closed on hardware first, which is
why this could be built on top with any confidence.

The running OS slot is mounted read-only and stays that way, so it cannot
drift from the bundle it was installed from and an unclean power loss
cannot corrupt it. Buildroot made that cheaper than expected: its BusyBox
skeleton already points /var/cache, /var/log, /var/spool, /var/tmp,
/var/run and /var/lock at /tmp and /run, both of which are already tmpfs,
so only /var/lib is a real directory in the rootfs and nothing writes to
it at boot. No /var reconstruction was needed, just
BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW off and an fstab that says ro.

/data gets a real ext4 in the factory image rather than being mounted on
the strength of whatever the card held before. genimage cannot build it:
Buildroot hands genimage an empty rootpath on purpose, so a filesystem
cannot be filled from the target tree. post-image.sh makes it with
mke2fs instead, 256 MiB and sparse, which is the normal division of
labour for a second filesystem.

RAUC's system.conf puts the slot status on /data, because the record of
which slot is bad and why has to outlive both the reboot that reveals the
failure and the overwriting of the failed slot (FR-014). post-build.sh
installs the keyring and creates the mount point, keyed on rauc being
present in the target rather than on any particular option, so it stays
board-independent (FR-029).

uEnv.txt and extlinux.conf are deleted. The boot baseline proved the board
booted through extlinux.conf and never read uEnv.txt; both are replaced by
the slot-selection script.

Verified: make check passes all nine checks; the installed
/etc/rauc/keyring.pem is byte-identical to keys/dev/dev-ca.cert.pem, so
the device trusts exactly the CA this tree generated; partition 4 in the
image carries ext magic 0xef53 with label "data" at LBA 2164736; no
remount script is left in the target's init scripts.

One figure in the storage-layout contract was wrong and is corrected:
sdcard.img is now 1313 MiB long rather than 161 MiB, because the last
partition finally has an image, though only about 63 MiB of it is data and
the rest holes. Flashing writes the whole length, since dd does not skip
holes.

US1 is now code-complete and waits on hardware: T024 and T025.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The first hardware run of User Story 1 showed `rauc status` reporting the
empty slot B as "boot status: good". RAUC's U-Boot backend calls a slot good
when it is listed in BOOT_ORDER with attempts left, and the seed listed B
with three. That is wrong twice over. The spec says the empty slot must
never be selected, and the boot script would have honoured the listing: a
failing A would fall through to B, which holds nothing, spend B's attempts
on loads that cannot succeed, and only then reach the last-resort path.

The factory image now seeds BOOT_ORDER=A and BOOT_B_LEFT=0. RAUC gives B its
attempts and moves it to the front when the first update is installed, so
nothing else changes. The edit lands in all three places the file is
compiled into -- the U-Boot built-in default, the SPL, and uboot-env.bin
that seeds the reserved region -- which was checked in the artifacts rather
than assumed, because Buildroot tracks the path of the environment file and
not its contents, so a plain rebuild would have kept the old values.
uboot-env.bin parses with a valid redundant-format CRC, and both copies in
sdcard.img match it byte for byte.

The same capture closes most of User Story 1: the running slot is read-only
(touching / fails), /data is mounted and writable, rauc accepts
system.conf and names the booted slot, and the remount-read-write line that
the T016 capture showed at 2.96 s is gone. The evidence is in
docs/logs/t024-us1-first-capture.log, including what it does not show.

Docs that described the old seed -- quickstart, the storage-layout contract,
the data model and the text of T010 and T024 -- are corrected. T024 also
now says BOOT_A_LEFT reads 2 after the first boot until mark-good restores
it; the old wording expected 3 and would have failed a correct system.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The second hardware run found a boot-time error that the read-only root
introduced: `seedrng: can't create directory '/var/lib/seedrng': Read-only
file system`, every boot. The commit that made the root read-only said
nothing writes to /var/lib at boot. That was wrong: Buildroot's skeleton
points most of /var at tmpfs, but /var/lib is a real directory in the rootfs
and seedrng keeps its seed there.

The fix is the one the init script documents for exactly this case, a
`--seed-dir` in /etc/default/seedrng, pointed at /data/seedrng. The seed
then also survives updates and rollbacks, which is the property it exists
for. post-build.sh writes the file inside the same A/B-only block that
creates /data, and only when the seedrng init script is present: a shared
overlay would send a board without /data looking for a directory that is
not there. /data is mounted from fstab before any init script runs, which
the boot log confirms, and seedrng creates the last path component itself.

The capture closes most of what the previous one left open:

- the seed fix works: the empty slot is reported `bad`, not `good`;
- `fw_printenv -n` reports 240 and 238 characters for the two lines that
  printenv showed cut off at exactly 238, which are their full lengths. The
  cut-off is in the capture path, so the last-resort path is intact;
- `rauc status mark-good` sets BOOT_A_LEFT to 3 from Linux, and after a
  power cycle U-Boot announces "2 attempts left", i.e. it read 3. That is
  the write direction that the T016 capture could not show, and the T016
  log now says so;
- /data survives power being cut while Linux runs, and the journal replay is
  visible in the log.

T024 is ticked on that evidence. The seedrng change is not yet on
hardware; it rides along with the next flash, which T025 needs anyway.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Three grabserial runs on the image built from a3ce015, by the same method
as the baseline: mean 10.512 s from the SPL banner to the login prompt,
spread 0.051 s. The budget is 12.65 s, so T025 passes with 2.14 s to spare,
and with it every task of User Story 1.

The 0.99 s improvement over the 11.50 s baseline is written up as what it is
and not as a win for the A/B machinery. Splitting the time at the moment the
kernel starts, the whole gain is the autoboot countdown, which fell from 2.08
s to 1.01 s when bootdelay went from 2 to 1: -1.07 s of a -1.066 s change.
Everything else in the bootloader phase is a wash, and saveenv costs about 11
ms. Like for like the A/B boot is about 0.08 s, 0.7%, slower than the
single-slot one, all of it between kernel start and the login prompt, and
that 0.08 s is stated as not yet attributed.

Run 4 took the last-resort path, because earlier boots had spent every
attempt without a mark-good. It is kept and labelled rather than discarded:
its login time is within 7 ms of run 5, and it is the first hardware run of
that path with the stored environment, which reached a login prompt. The
RAUC line that puzzled the capture, "Unable to find primary boot slot",
appears exactly once, after run 4, and is explained by that run's own U-Boot
output: RAUC names the primary slot as the first in BOOT_ORDER with attempts
left, and slot A had none. The new log notes that this is a decision for the
health script to take on purpose.

The same runs confirm the seedrng fix on hardware, with no "can't create
directory" line. They all say "without crediting", which is expected and
corrects an expectation from earlier in this work: the creditable seed is
written at a clean shutdown, and the board was power-cycled each time.

This is User Story 1 only. The health script and the watchdog feeder add work
after init, so the figure is measured again, and the README baseline updated,
under T043.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… one

Decided with the person running the hardware, after the first run of the
last-resort path on a board: RAUC cannot name a primary slot there, because
it picks the first slot in BOOT_ORDER that still has attempts and none does.

A boot that passes every health check is confirmed good, with the record
stating it was a last-resort boot. The alternative reads as cautious and is
not: with no confirmation the watchdog feeder never starts, since only a
confirmation starts it, so the hardware resets the board after 60 seconds
and the same last-resort boot follows. A device whose one remaining slot is
healthy would cycle forever, which is the failure this feature exists to
prevent.

FR-012 gains the sentence, the clarification log gains the decision and its
reason, and T027 says how condition two reads when there is no pending slot:
RAUC names the booted slot as primary, or names no primary at all, and a
different slot named as primary still fails as an inconsistent state.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… certificates

rauc install checks certificate validity against the system clock and has
no --no-check-time, while the board cold-boots into 2000 and the
development certificates start in 2026. Research R8 records the finding,
the delivery path chosen for US2 (host http.server, udhcpc and wget, no
defconfig change) and the options for the clock. T029 and T030 carry the
resulting steps so US2 can start at T026 without asking again.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The board has no battery-backed RTC and cold-boots into 2000-01-01, before the
validity window of the certificate that signs update bundles, and rauc install
has no --no-check-time. post-build.sh now records BUILD_DATE in /etc/build-info
and S00ota-clock, the first init script, raises the clock to it when it is
earlier. The result is a floor, not the real time. A clock already past the
floor is left alone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r specs

Option B of research R8 was approved: FR-033 requires a clockless device not to
run earlier than its image's build time, T046 implements it, and T029/T030 no
longer set the clock by hand. CLAUDE.md gains the note that the target clock is
a floor and what that means for any later spec that validates time on the
device. T040 must lint init scripts, which the *.sh filter does not see.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
post-image.sh stages the rootfs and a manifest naming ota-beaglebone-black and
the VERSION read back from the image's own /etc/build-info, and signs it with
the development material. The bundle is 23.1 MB. It is not verified at build
time: rauc info loop-mounts a plain bundle, which the build container cannot do.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
S99ota-health checks, in order, that RAUC and the bootloader agree on the
running slot (or that U-Boot took its last-resort path, which it records),
that /data is mounted and writable, and that the boot-selection state reads and
writes back; only then does it call rauc status mark-good. A failure leaves the
slot unconfirmed and writes the reason to /data/ota-health.log. No network.

Checked on the host against stubbed rauc and fw_* tools for nine paths; not yet
run on the board. The watchdog feeder is T032.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
On the first hardware boot S00ota-clock raised the clock to the build time and
the omap_rtc module, loaded by mdev seconds later, set it back to 2000-01-01
(CONFIG_RTC_HCTOSYS). With the driver built in, hctosys runs before init.

S99ota-health refused to confirm a healthy slot: with root=/dev/mmcblk0p2 RAUC
puts the device in RAUC_SYSTEM_BOOTED_BOOTNAME, not the boot name. It now takes
the slot whose state is booted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The clock at power-on is 1970-01-01; 2000-01-01 is the RTC's own value, set when
its driver registers. Research R8, T046 and T027 say what failed and why the
host-side checks could not see it. The console excerpt is under docs/logs/.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The RTC driver built in, ota-clock is the last writer and date at the prompt is
the build day with no date -s typed; ota-health confirms slot A and the attempt
counter is back at 3. Boot time and the network are not measured by this log.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
192.168.0.2/24 with gateway 192.168.0.1, for a board cabled straight to the build
host. Nothing on that cable answers DHCP, and waiting for a lease would cost boot
time. No package is added and nothing listens.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… network test

Research R8 replaces udhcpc with the address now in the image, with the ping and
wget results from the board. T047 records the change; T029 now checks the address
comes up by itself and compares checksums on both ends.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Fetched over the static address into /data, the 23 MB bundle has the same SHA-256
on the board as on the host. Recorded as the user's report, since only the hash
was pasted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rpose

The first rauc install on hardware failed with "unsuitable certificate purpose":
the signing certificate has only the Code Signing extended key usage, and without
check-purpose OpenSSL verifies the CMS signature for S/MIME signing. Reproduced
on the host with openssl cms -verify, which fails by default and succeeds with
-purpose any, so the chain and the digest were fine.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…owed

Delivery and the clock worked; rauc install refused a bundle the project itself
built, because the signing certificate is Code Signing only and the device had no
check-purpose. Recorded with the host reproduction, the contract, FR-016 and a
fifth refusal case for the untrusted-bundle scenario.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The second install attempt verified the signature, then failed to create
/mnt/rauc/bundle on the read-only slot. Behind that, the kernel has no SquashFS,
and a plain bundle is a squashfs, which RAUC mounts with mount(2) through a loop
device. Set mountprefix to /run/rauc and build SquashFS (zlib, the bundle's
compression) into the kernel.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e image

The signature verified; the mount of the bundle failed on the read-only slot, and
behind it the kernel had no SquashFS. Research R9 lists what the install path
requires, and which parts are still unproven.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ne runs

The second install on hardware, run while slot B was pending, was accepted and
rewrote B: RAUC only refuses to write the slot that is running. A pre-install
handler, run after the bundle is verified and before the target slot is marked
bad, now refuses when RAUC's primary slot is not the running one, or when another
rauc install exists. A rolled-back or last-resort device has nothing pending and
can still be updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nforced

Install in about 8 s, boot of the new slot, its version, health confirmed. The
second install, run while the first was pending, was not refused: FR-009 was
assumed to come from RAUC and does not. Task T048 adds it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
mtriSE and others added 26 commits October 29, 2026 17:53
Trials 1, 2 and 5 pass. Trials 3 and 4 were not run; the record says so instead of
counting them, and notes that SC-002's five of five is not shown as written.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The closing install put 40a54ec into the half-written slot A: BOOT_ORDER "A B",
counter back at 3, boots, confirmed good, reports the older version. Also records
that booting an older image lowers the clock floor, and that boot time is close to
its budget and needs a proper measurement.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nfirmed

omap_wdt stops the watchdog U-Boot started unless early_enable is set, so nothing
could ever reset a hung board: the 253 s idle shell measured by T016. The parameter
now comes from the kernel's built-in command line (extending the bootloader's,
with the old root= string replaced so it cannot override the slot's), and
S99ota-health starts the BusyBox feeder (5 s feed, 30 s margin) only after
rauc status mark-good succeeds. A slot that does not confirm is reset about two
minutes after boot, and the attempt counter retires it.

Host-checked; the reset itself is for the hardware trials of User Story 3.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s not have

The kernel is built without CONFIG_WATCHDOG_SYSFS, so /sys/class/watchdog/watchdog0
has no state attribute. The feeder is shown through its process and its open file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…line order is corrected

Killing the feeder without the magic close reset the board in 25 s inside the 30 s
margin, and the same slot confirmed again. The kernel appends CONFIG_CMDLINE after
U-Boot's arguments, so research R5 had the order backwards; CLAUDE.md now says
what may go in it. The kernel-hang reset and the never-confirmed scenario are open.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… split

A panic on the confirmed slot was reset by the hardware within the feeder's 30 s
margin and the slot confirmed again. The 60 s figure applies only to a kernel that
hangs before userspace claims the watchdog; the contract had the two as one row.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Records what the end of the console shows and what the user's account adds,
and keeps the two apart. The counters, the timing and rauc status are still
to come.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The full capture of scenario B shows A tried three times with the counter at 2, 1,
0, the watchdog resetting 49 s after each kernel start, and the good slot taking
over. The documented 125 s was wrong: the watchdog core gives an unopened watchdog
one 60 s window, not 60 s of pings plus another 60 s. The tables and the comment in
S99ota-health now say what was measured.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…match

SC-014 asked for three trials of a slot that never confirms; one was run and the
user decided to stop. It is recorded as waived, with the T016 measurement standing
in for the unrepeated "before" run. Closing the story also showed that the
last-resort path boots slot A, where T031 and the boot contract say the first slot
in BOOT_ORDER; noted as open instead of settled either way.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Init scripts and RAUC handlers have no .sh extension, so shellcheck never saw them
and S00ota-clock had to be linted by hand; they are now found by their shebang,
linted, and required to be executable. The numbers that genimage, U-Boot, fw_env,
RAUC and fstab must share (state offsets and size, no overlap, partition numbers of
slot A, slot B and /data) are compared on every run. Each check was shown to fail
by breaking one agreement at a time; 13 breakages, 13 caught.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nt how to run them

make-untrusted-bundles.sh builds a genuine control and the five bundles a device has to
refuse (unsigned, a second CA, one byte altered, a different board, a certificate from
the device's own CA without the Code Signing usage). The last is dated from the CA's own
notBefore so the device cannot refuse it for its date instead of its purpose. Quickstart
scenario 7 says how to make, run and read them; the device's wording is T037's to record.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Each line in /data/ota-health.log now carries the date, the uptime, the revision of the
image that wrote it, the slot and a condition from a fixed set, so it can be read long
after the boot that wrote it, when the slot may have been overwritten. The date is the
clock floor plus uptime and the contract says so. The log is bounded at 64 KiB with one
rotated copy. A healthy boot still writes nothing.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
README: the tree and flashing text were of the single-slot image. It now has an "Updating a
device" section (card layout, the reserved region, the 2 GB minimum, keys and OTA_*, installing,
rollback with its measured timing, the failure log, the limits including the bootloader that is
never updated in the field), and says its old footprint and boot-time figures are the single-slot
image's until they are re-measured. CLAUDE.md: layout, the board's own kernel and U-Boot configs,
the card layout and the one counter rule, signing material, the bench network, and what only
hardware showed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
README gains the measured sizes of the A/B image: the slot at 47.8% of its filesystem, the
boot partition at 4.9%, the data area with room for about ten bundles, a 23.1 MB bundle, and a
sdcard.img that is 63 MiB of real data. The boot time is not measured and the README says so.
T045 is checked on a true clean clone: docker-check green, savedefconfig leaves no diff.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…mand

try_bundle fetches a bundle, works out which slot an install would write, records the
boot-selection state and a checksum of that slot, runs rauc install, and says whether
anything changed. The bundle script serves it next to the bundles, and quickstart scenario 7
uses it instead of a block of commands that carried comments into the serial console.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eason

Unsigned, second CA, altered, other board and no Code Signing usage were each refused with a
different message, and the boot-selection state and the target slot were unchanged after every
one. The quickstart table now carries the wording the device used. The genuine control has not
been run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
On hardware the console names the chosen slot every boot and a rolled-back device shows the other slot
as bad. The single command FR-026 asks for is rauc status --detailed, not rauc status, and even it
does not say that an update awaits confirmation or that a slot is confirmed rather than eligible.
The contract also said a retired slot leaves BOOT_ORDER; it stays listed with no attempts.
T039 stays open on the choice between documenting this and adding an ota-status command.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
rauc status has no versions, calls a slot good while it merely has attempts left, and never says that an
update awaits confirmation. ota-status reads RAUC, the boot-selection state, /etc/build-info and a marker
that S99ota-health writes when it confirms a boot, and says in words which slot runs, whether this boot is
confirmed, whether an update is pending, and whether the other slot is standby, pending, retired,
unusable or empty. Checked on the host against seven states; the board run is T039.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Standby and running-confirmed, retired after a slot that hung, pending before the reboot and
running-confirmed after it all read as designed, and the retired slot now says what was tried and
that it never confirmed. The states seen only on the host, and the freshly flashed card, are listed as
not seen.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ound

The exhausted-slots path boots slot A without spending an attempt, not the
first slot in BOOT_ORDER. Keep that, record the difference as a known issue,
and let an operator name another slot with ota_fallback_slot (fw_setenv or the
U-Boot prompt). Any value other than B means A, so a typo cannot strand the
device. T031 is closed on that basis.

The first board run showed "Unknown operator 'eq'": itest takes -eq or ==.
Fixed to -eq. The fixed script has not been booted yet; recorded as such.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The operator ran the fixed script on the board and reported the last-resort
path behaving as written. No console capture was attached and it is not stated
whether ota_fallback_slot B was tried, so the log records the report as a
report and does not claim that B boots.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…is retired

A bundle whose fw_env.config pointed at the wrong offsets failed the fourth
health condition, never confirmed, ran out of attempts and was retired; the
device came back on the other slot and the reason was readable from /data.
The three reboots are the operator's account and only the last of six health
log records was shown, and the log says so. Quickstart scenario 8 gets the
recipe.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…budget

Three grabserial runs on the board with S00ota-clock and S99ota-health in the
image: 11.614 s from the SPL banner to the login prompt, spread 0.12%, 1.0%
over the single-slot baseline. About 0.9 s sits before the health script's
"confirmed good" line; that is read from neighbouring timestamps, not isolated.
T043 is closed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… the device rolls back

A signed bundle whose /boot/zImage is garbage (scripts/make-broken-kernel-bundle.sh)
was installed into the idle slot. U-Boot refused the kernel each time, BOOT_B_LEFT
went 3, 2, 1, 0 and the device ended on slot A, confirmed. One trial of three; the
other two were waived by the user and are recorded as not run.

Recorded as not met: the failed slot leaves no reason in /data, as its kernel never
starts. Also recorded: the bad kernel falls through to the next slot in the same
power-up, so A is refused confirmation twice and confirmed only on the third boot,
and that confirmation is labelled last-resort although U-Boot did not take that path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
docs/logs/README.md lists, per check, the logs behind it and whether each is a
console capture, a report from the operator, waived, or not run. It also lists what is
not shown anywhere: SC-002, SC-003 and SC-014 as written, FR-014 for a slot that fails
before userspace, mark-bad, ota_fallback_slot B, and the mirror of T033. The nine defects
that only the board showed are listed with their logs.

All tasks of the feature are now closed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sinbadincr sinbadincr self-assigned this Oct 31, 2026
@sinbadincr
sinbadincr merged commit 547a915 into master Oct 31, 2026
2 checks passed
@sinbadincr
sinbadincr deleted the 002-ab-ota-rauc branch October 31, 2026 04:34
mtriSE pushed a commit that referenced this pull request Nov 1, 2026
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