interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / docs / HARDWARE_TEST_RIG.md

194 lines · 10828 bytes Raw Blame History Rendered
1# Machine 1 hardware test rig
2
3**Status: proposed design (2026-09-24). Nothing is wired or enabled yet. The
4operator chooses and approves the parts; maintainers wire it up. Until then,
5M2C power, capture and input stay pending and boots stay attended.**
6
7Governing: [ADR 0011](adr/0011-machine-1-hardware-test-rig.md),
8[MILESTONES.md gate M2C](MILESTONES.md), [NATIVE_BOOT_ONE_TIME.md](NATIVE_BOOT_ONE_TIME.md),
9issue [#25](https://github.com/aien-dev/aienux/issues/25).
10
11## Why
12
13Every Spark boot currently needs a person at the machine: someone holds the
14power button when a boot hangs, photographs the screen because the post-exit
15report has no other record, and types at the firmware menus. That does not
16scale, and it cannot run unattended. The rig gives three **independent**
17functions for Machine 1, all serialized through
18`aien-proof hold --resource machine-1` (see
19[Serialization](#serialization-through-aien-proof)):
20
211. **Power and reset control**: momentary press, long press (force off),
22 and a hard power cut that always works.
232. **Display or console capture**: the screen from cold boot through the
24 post-exit report, replacing the operator photograph.
253. **Deterministic input and boot selection**: scripted keystrokes into the
26 firmware boot menu, the firmware setup screen, and later the AIENOS early
27 console, so the same image boot can be driven the same way every time.
28
29Independence matters: a hung capture dongle must not block a power cut, and a
30dead HID gadget must not trap the machine with no way to reboot it. Each
31function below fails without breaking the other two.
32
33A Raspberry Pi is already cabled to the Spark and acts as the rig controller:
34USB keyboard gadget, capture host, relay driver, and the place `aien-proof`
35runs.
36
37## Parts list
38
39Prices are approximate, one unit each, 2026. Nothing here is proprietary; every
40part is replaceable with an equivalent.
41
42| Function | Part | Role | Approx. cost |
43| --- | --- | --- | --- |
44| Controller | Raspberry Pi 5 (already cabled to the Spark) | Runs `aien-proof`, the gadget stack, capture and relay control | owned |
45| Power sense | Spark ATX 24-pin sense lead (`PWR_OK`, green wire `PS_ON`) tapped at the PSU connector | Ground `PS_ON` to force the PSU on; read `PWR_OK` to know the board has power | cable only |
46| Power cut | SPDT relay board, 5 V coil, 10 A mains-rated contacts (for example an opto-isolated Songle SRD-05VDC module) | Inline with the mains feed or the PSU enable; drops power unconditionally | ~5 USD |
47| Power/reset buttons | 2x reed or opto-isolated reed relays (for example Omron G3VM SIP MOSFET relays) | One across the Spark front-panel power-header pins, one across the reset-header pins; momentary closure only | ~4 USD |
48| Display capture | USB 3 HDMI capture dongle, UVC class, 1080p60 (for example an MS2109 or MS2130 based dongle) | Spark HDMI out to dongle input; appears as a webcam on the Pi; loop-through port passes the desk monitor | ~20 to 40 USD |
49| Input emulation | The Pi itself, USB OTG port in HID gadget mode (Linux `configfs`, `dwc2` overlay) | Presents a standard USB boot-protocol keyboard to the Spark | included |
50| Console capture | Pi GPIO UART (TX/RX) wired to the Spark UART at `0x16A00000` | Bounded serial console once [#22](https://github.com/aien-dev/aienux/issues/22) lands; 3.3 V levels only | jumper wires |
51| Enclosure and safety | Fused mains inlet box for the relay, insulated standoffs, labeled header leads | Mains stays in a closed, fused box; low voltage leaves it | ~20 USD |
52
53Total new spend is roughly 50 to 70 USD. No part is on the Spark's boot
54critical path except by explicit command: with every relay at rest and every
55cable disconnected, the Spark boots exactly as it does today.
56
57## Function 1: power and reset control
58
59The Spark exposes standard PC-style front-panel pins. Shorting the power pins
60briefly is a press; shorting them for about five seconds forces power off. The
61relay board gives a hard cut that works even when the board is wedged.
62
63- `power.press` and `reset.press`: close the matching reed relay for about
64 500 ms, then open. Reed relays are used for the button lines because they are
65 isolated, polarity-tolerant and cannot drive the header.
66- `power.forceoff`: hold the power relay closed for 5 s.
67- `power.cut` / `power.restore`: energize or release the mains relay. This is
68 the last resort and the recovery path for every wedged state.
69- `power.status`: read the PSU `PWR_OK` sense line, so a script can wait for
70 power-good instead of sleeping a fixed time.
71
72Safety invariants (enforced by the control scripts, reviewed in the ledger):
73
74- The mains relay is **fail-on**: power flows when the relay is at rest, so a
75 dead Pi or a crashed script never holds the machine dark.
76- The button relays are **momentary-only**: the driver enforces a maximum
77 closure time in software and the hardware timer on the relay board enforces
78 it if the Pi hangs.
79- `power.cut` is the only destructive action, and it is always available to
80 the operator and to a failing script.
81
82## Function 2: display and console capture
83
84Two capture paths, both terminating on the Pi:
85
86- **HDMI**: the Spark's display output goes through the capture dongle's
87 loop-through port to the desk monitor, and the dongle's USB side lands on
88 the Pi as a UVC webcam. A capture run records video from before power-on
89 until the machine is back in Linux, plus a still frame at each stage gate
90 (firmware logo, pre-exit report, post-exit report, countdown). This replaces
91 the "photograph the screen" step in
92 [NATIVE_BOOT_ONE_TIME.md](NATIVE_BOOT_ONE_TIME.md) and records the post-exit
93 drawing that the M2 evidence
94 ([evidence/m2_first_boot_2026-09-24.md](../evidence/m2_first_boot_2026-09-24.md))
95 lists as a gap.
96- **UART**: the kernel already has a bounded 16550-style UART writer at
97 `0x16A00000`, 921600 baud (`crates/aienos-kernel/src/arch/aarch64.rs`),
98 skipped on the first boot because GB10 discovery failed. Once [#22](https://github.com/aien-dev/aienux/issues/22)
99 (SPCR-based discovery) lands, the Pi's GPIO UART records it at 3.3 V
100 levels. Until then, HDMI capture is the only post-exit record and stays
101 mandatory.
102
103Capture is read-only: nothing in this function can change what the machine
104does. A failed capture never blocks power control.
105
106## Function 3: deterministic input and boot selection
107
108The Pi's OTG port runs the Linux HID gadget (`configfs` + `dwc2`) and appears
109to the Spark as a plain USB keyboard. The gadget implements the HID boot
110protocol, so it works in the firmware setup screen and boot menu where no OS
111driver exists, and later against the native xHCI/HID driver from
112[#24](https://github.com/aien-dev/aienux/issues/24).
113
114Boot selection is deterministic: the rig never types blind. Each scripted
115sequence is a list of (wait for capture frame matching X, send keystrokes Y)
116steps. Examples:
117
118- Boot menu: `power.press`, wait for the firmware logo frame, send `Esc`,
119 wait for the boot-menu frame, send the arrow-key count for the `ubuntu`
120 entry, send `Enter`.
121- Firmware setup: the documented `systemctl reboot --firmware-setup` path is
122 preferred; the gadget is the fallback when Linux is not running.
123- AIENOS console: once the early console takes keyboard input, sequences come
124 from the same runner.
125
126The keystroke sets, frame references and expected end states are versioned in
127this repository next to the scripts that use them, so a boot sequence maps to
128one exact commit, same rule as the staged image.
129
130## Serialization through `aien-proof`
131
132`aien-proof` and its `machine-1` resource lock live in the
133[aien-sovereign-core](https://github.com/aien-spark/aien-sovereign-core)
134repository; this repository holds the rig design and the contract the control
135surface must meet. The contract is the one already used for staging:
136
137```text
138aien-proof hold --resource machine-1 --job <name> -- <rig command>
139```
140
141Rules:
142
143- Every rig function, including capture, runs only inside a
144 `machine-1` hold. The hold's full output becomes the ledger event, exactly
145 as `stage_one_time_boot.sh` and `collect_boot_report.sh` already work.
146- A hold runs one rig command. The rig never acts outside a hold; an attended
147 boot by the operator is recorded as one too.
148- `power.cut` is the single exception reachable in an emergency and is still
149 wrapped by the hold when scripted; physically, the operator can always cut
150 power by hand.
151- Scripts that run under the hold get no stdin, so anything privileged is
152 pre-authorized (`sudo -v`) before the hold, as in
153 [NATIVE_BOOT_ONE_TIME.md](NATIVE_BOOT_ONE_TIME.md).
154
155The M2 evidence flow changes in one place: the photograph rows
156(`framebuffer:` line and post-exit drawing) come from capture stills named in
157the ledger payload, and the collector checks them the way it checks the
158firmware-variable report today.
159
160## Attended-to-unattended boot contract
161
162The current attended procedure ([NATIVE_BOOT_ONE_TIME.md](NATIVE_BOOT_ONE_TIME.md))
163maps onto the rig without changing the image:
164
165| Attended step today | With the rig |
166| --- | --- |
167| Operator holds power button after a hang | `power.forceoff`, then `power.press` |
168| Monitor attached; operator photographs the screen | HDMI capture stills and video, recorded in the ledger payload |
169| Keyboard attached; operator picks entries in firmware | HID gadget sequences, matched against capture frames |
170| Recovery USB stick chosen from the boot menu by hand | Boot-menu sequence against the same capture frames |
171
172Until the owner-controlled boot chain exists (see the Secure Boot note in
173[MILESTONES.md](MILESTONES.md)), the rig changes how boots are driven, not
174what is booted: Secure Boot stays on, native AIENOS boots stay paused, and the
175rig's first job is running attended flows like recovery-media testing and the
176TRUST-1 100-boot campaign without a person in front of the machine.
177
178## Wiring checklist (maintainers)
179
1801. Bench-test the relay board on a lamp before touching the Spark.
1812. Tap `PS_ON`/`PWR_OK` at the ATX connector; verify sense reads on the Pi.
1823. Identify the Spark front-panel header; wire the two reed relays; verify a
183 500 ms closure powers the machine on and off.
1844. Route HDMI through the capture dongle to the desk monitor; verify the Pi
185 sees a UVC device and a frame.
1865. Enable the HID gadget on the Pi OTG port; verify the Spark firmware sees a
187 keyboard (boot-menu navigation by script).
1886. Wire the UART (3.3 V only); leave it disconnected until [#22](https://github.com/aien-dev/aienux/issues/22)
189 makes the Spark side real.
1907. Run the attended procedure once under the rig, end to end, and record the
191 ledger events as the rig's commissioning evidence.
192
193Each step is independently verifiable and independently reversible; a step
194that fails leaves the previous functions working.