Hardware runsDraft
tools/hw-run/hw-run runs one test boot of a target machine from a build host. The run model
is the same for every device; the only generation it has been used on is the
M5 series.
It has one launcher and four profiles, and every wait ends on an event.
This page describes the run model; the exact flags of your checkout are
printed by hw-run --help.
Some parts of this page describe the project's reference lab setup, not
a requirement: the default firmware choice (a 16-CPU test firmware), the file
carrier that passes command files to the guest, and the hwlock readers-writer
script are specific to that setup. Another lab substitutes its own firmware
list, carrier and locking, keeping the run model.
Hardware runs are not part of the host test suites and are never started by CI. They need the board, the debug cable and a running oblinkd. Treat the commands below as descriptions of the tool, not as a recipe that was re-run for this page.
What a run is#
A run is a declared list of steps. Each step has one event that completes it and a ceiling. The ceiling is a failure bound: when it is reached the run fails and says what it was waiting for and what it saw last. No step is a sleep, and no step is in a profile that does not need it. A run boots the board once and does not retry by itself.
| Profile | Steps | Ends on |
|---|---|---|
probe |
Image up, the named monitor commands, optionally a console line (--until), health reads. |
The last reply. |
boot |
Image up, launch, a milestone (kernel, kbd by default, or setup), health reads. |
The milestone. |
guest-cmd |
Boot to Windows Setup, open a command prompt, run one command file from the file carrier, health reads, fetch the result file. | The done marker. |
bench |
A guest-cmd with a generated command file that loads a driver package and runs a disk benchmark. |
The done marker. |
Never by default, in any profile: a disk benchmark (only bench), a
full-size screenshot (--shot), a monitor dump beyond the three health
reads (--health-extra), an idle period (--hold S).
hw-run probe --ref REF --label NAME --mon "info; fd; nvme"
hw-run boot --ref REF --label NAME --milestone kbd
hw-run guest-cmd --ref REF --label NAME --cmd tools/hw-run/examples/min.cmd
hw-run bench --ref REF --label NAME --pkg DIR --bench "<benchmark args>"
hw-run wait LABEL
REF names the source revision to build and test; LABEL names the run
directory. --dry-run prints the plan (the build, the proofs, the boot
object, the firmware choice) without touching anything. One file tells
the outcome: runs/<label>/result.json.
Flags#
| Flag | Meaning |
|---|---|
--flags "NAME=VALUE ..." |
Make variables for the build. Plain NAME=VALUE tokens only, no shell. |
--fd FILE, --fd-ok "reason" |
Use this firmware instead of the default; see below. |
--persistent-ok "reason" |
Allow monitor commands that write persistent state (disk, NVRAM, flash, PMU non-volatile). |
--mon "cmd; cmd", --until REGEX, --mon-after "..." |
The monitor commands of a probe. |
--mon-prelaunch "cmd; cmd" |
Plain monitor commands run once, in order, right before the launch. |
--milestone, --hold S |
Boot profile: the target milestone and an optional idle period. |
--cmd FILE, --pkg DIR, --cmd-timeout S |
Guest command profiles. |
--boot-timeout S, --lock-wait S |
Ceilings. |
--health-extra "..." |
Extra monitor reads, optionally polled until a regular expression matches. |
--detach |
Return at once; collect the verdict with hw-run wait LABEL. |
--no-watchdog |
Restore flat waits instead of the silence watchdog. |
--dry-run |
Show the plan only. |
The link and the chain#
OBLink is the only link. --link oblink is the default, and the older
--link kis is refused. The launcher reaches oblinkd through a small
helper script (under tools/hw-run) on the machine that holds the cable;
the environment variable OBLINK_CTL names the daemon's control address as
that helper sees it.
The run first finds out what the board is:
| The machine | What the run does |
|---|---|
| Link up, monitor idle, no guest | Goes on with the steps below. |
| Link up, the guest has shut itself down | A monitor reboot to the held state first, then the steps. |
| Link up, a guest is running | Busy (exit 9). Nothing is touched. |
| Link up, the monitor is silent | Exit 5, nothing touched. |
| No link | Exit 5, nothing touched. |
A dead link is a stop. The launcher has no second way to reset the board: it sends no USB-C messages and does not power-cycle the machine. When the link is gone or the monitor is silent, the run says it did not reboot and the board has to be restarted by hand before the next run.
The chain loads the image through the held OpenBoot:
- Pack the proved image and the cleared firmware into one boot object.
- Wait for the sideload window, then push the object over OBLink.
- Check it on the device: the CRC-32 of the window must equal the
object's, and
sideload image ... checkmust report success. - Hand over with
sideload image. The link goes away and comes back. - Wait for the new image's own idle event. Only when
infoshows the run's build and the firmware report shows the packed firmware is the image counted as this run's own, and only then is anything launched. - Run the profile against the new image.
- Tear down with the monitor's
reboot, which returns the board to the held state with the installed OpenBoot.
The teardown is refused over a running guest of an image this run did not verify as no-write, because a reboot is a power cut for that guest's disk.
The firmware rule#
The firmware travels inside the boot object, and the rule is required, not a convenience:
- Without
--fdthe default, in the reference lab setup, is its 16-CPU test firmware. For a flag set withANS_NATIVE=1the default is the native production firmware: older firmware builds do not know the handoff record of such an image and stop atinvalid handoff, so naming one of those older firmwares together with such a flag set is refused (exit 3) before anything is pushed. - Any firmware must be on the launcher's allowlist, which is matched by
SHA-256 and never by name, or be named with
--fd PATH --fd-ok "<reason>". The reason is recorded inresult.json. - The handoff description file must sit next to the firmware, and it must match the package's place.
What is refused#
The launcher refuses, with exit 3, an image that fails the no-write proofs
or links the rehearsal overlay, a boot of the internal ESP, a firmware off
the allowlist without --fd-ok, a monitor command that writes
persistent state without --persistent-ok, and a malformed flag or
monitor line. Everything else is accepted and recorded in result.json
and in the lock record. There is a documented opt-in for write images; it
is not part of the normal workflow and hw-run --help describes it.
A run ends at once, whatever it waits for, on a boot: FAIL E<n> line
after the launch, a boot device line naming the internal ESP, an
internal disk read above a tripwire before the run's own command, a
FATAL line, or the main core parking.
Exit status#
| Code | Meaning |
|---|---|
| 0 | OK |
| 2 | Usage |
| 3 | Refused by a safety rule |
| 4 | Build or proof failed |
| 5 | A hardware step failed or a milestone was not reached before its ceiling |
| 6 | The guest command returned non-zero |
| 7 | The guest command did not finish |
| 8 | The console check that the protected memory-controller regions were removed from the guest's maps failed |
| 9 | Busy (the lock, or an image is running that this run did not start) |
| 10 | Guest FATAL |
| 11 | Abort: the firmware booted the internal disk |
| 12 | Interrupted |
| 13 | An expectation the run declared was not met (for example the slot shadow comparison) |
| 14 | The host is not fit (another program holds the debug USB device) |
| 15 | Silent after the hand-over |
| 16 | The monitor went silent |
Events#
| Step | Event it ends on |
|---|---|
| Lock | flock on the hardware lock returns |
| Sideload window, push, hand-over, new image | The window shows; the push reply and the device CRC; the daemon loses and finds the device; the new image's idle event |
| Image up | main: MAINLOOP in the monitor's info |
| Launch | launching entry= in the monitor reply |
| Kernel | ExitBootServices -> Success, confirmed by the monitor's ms seeing guest kernel vectors |
| Keyboard | vxhci: milestone configured |
| Setup, prompt | The screen colours read through the framebuffer snapshot command |
| Guest command | The console window turns yellow (started), then green (rc 0) or red |
| Reboot (teardown) | The link goes away and comes back |
The console is not trusted to be complete. Milestones and health come from the monitor, and a fatal dump is also read from the log ring in RAM.
Guest command files#
guest-cmd stages a wrapper and the caller's command file on the file
carrier. The wrapper prints everything the command outputs between
HWRUN-START <nonce> and HWRUN-DONE <nonce> rc=<errorlevel> and paints
the window, and the verdict is the HWRUN-DONE line of this run's nonce
in the file read back after the guest is stopped. End the command file
with exit /b 0 or another code. tools/hw-run/examples/min.cmd is the
smallest one. Disk safety is not in the command text: the no-write image
refuses every disk write at EL2, and the verdict fails on a refused or
written block.
Locks#
Two locks keep concurrent work apart.
- The hardware lock is one file lock that every
hw-runtakes. A second run waits up to--lock-waitseconds and then reports busy.hw-run hold-lock --label NAME --reason TEXTtakes it by hand and keeps it untilhw-run release-lock --label NAMEor its maximum time; other runs see the recorded reason. - hwlock (
tools/hwlock/hwlock.sh; part of the reference lab setup) is a readers-writer lock for work against the already running guest.hwlock.sh shared <cmd>is for user-mode work such as probes and log reads, and may run in parallel.hwlock.sh exclusive <cmd>is for anything that changes the driver, reboots the machine, uses the debug link or restarts the display compositor, and waits for every shared holder to finish.hwlock.sh down <reason>marks the guest unusable so every holder stops, andupclears it. Shared jobs checkhwlock.sh statusbetween steps.
Not verified#
- The commands on this page were not run for this documentation pass.
- The firmware allowlist contents and the file carrier hardware are site-specific and are not described.