HITL & tooling (pi/hitl/, tools/)

Hardware-in-the-loop rigs (pi/hitl/)

The HITL infrastructure runs the firmware on real ESP32-C6 boards under bazel test-style automation. A rig is a Raspberry Pi with one or more C6 boards over USB, reserved through a FIFO queue and reached over Tailscale. A Go daemon + CLI manage reservations; a Python harness drives the tests.

Suites include:

  • e2e_netstack: flash, BLE provisioning, wss and the agent manifest check.

  • map_upload, mapping_trigger and rename_wss.

  • fx_bench: the FX performance benchmark that feeds FX-VM performance.

  • video_stream.

  • loaded_tls_netstack: TLS handshakes on a heap loaded with a map and an effect.

  • ram_audit, described below.

  • time_base_skew: inter-fixture skew under one shared epoch, captured on both analyzer-tapped DUTs in one capture.

  • The real-phone journeys: Android on amd-rig, iOS on the Mac mini.

Every failure ships the DUT’s serial log as a CI artifact. The CI wiring and how to stand up your own rig are documented in Developing splanc (Hardware-in-the-loop testing).

Memory auditing over JTAG (ram_audit)

//pi/hitl/harness:ram_audit drives the field worst case: BLE provisioning, then the first wss handshake with BLE still up, then a 2048-LED map, a texture effect and loaded handshakes. Meanwhile ram_watch.tcl polls every heap’s free bytes over the C6’s system bus, without halting the core. At each new low it halts just long enough to dump HP + LP SRAM and the registers, so the last dump is the RAM image at the minimum watermark. At the end of the run it also reads the heap census (LM_HEAP_CENSUS, with --//firmware/player_app:heap_census_enabled) and the sysmode counters (LM_MODE). The DUT never reports metrics over the network.

  • --hang adds hang_watch.tcl. It polls FreeRTOS’s tick count, and if the tick stops for 3 s it halts the core, records the registers and a PC trail, dumps SRAM, and leaves the core halted so the watchdog can’t erase the evidence.

  • Gotcha: never halt during the Wi-Fi join. A dump halts the core for ~46 s, and a halt in the DHCP window ends in a TG0 watchdog reset after resume, which looks exactly like a firmware hang. Dumps are therefore armed only after provisioning (the harness touches /tmp/ram_watch.arm); the minimum comes later, at the first wss handshake.

Observability

Rigs push their metrics to Grafana Cloud through Alloy. This covers the Pi rigs, the Android bench amd-rig (both daemons, :8087 and :8088) and the iPhone bench mac-mini (a launchd Alloy agent). The dashboards are code in pi/hitl/observability/dashboards/ and are synced by .github/workflows/grafana-dashboards.yaml, which warns loudly if its Grafana credentials are missing. See pi/hitl/observability/README.md.

Host-side tools (tools/)

Dev, flash, and bench helpers that run on the machine with the board and radio:

  • tools/flash_server.py — host-side ESP32 flasher + serial-log reader; shells out to bazel under $BUILD_WORKSPACE_DIRECTORY to run flash targets.

  • tools/ble_onboard_server.py — Improv-BLE provisioning driver (SimpleBLE), the automated stand-in for the phone’s Web Bluetooth onboarding.

  • tools/browser_server.py — headless Chromium driver (Playwright) for exercising the player’s wss + self-signed-cert flow end to end.

  • tools/sim_studio/ — an interactive solver-debugging web app: generate fixtures, fly a camera, and watch reconstruction converge against ground truth.

  • tools/trace_server.py — a CV trace sink for offline detection debugging.

  • tools/fx_profile/ — the effects performance profiler.

bazel run //tools/sim_studio:serve      # solver-debugging UI on :8090

Sim Studio’s own README (HTTP API, usage, tests):

Sim Studio — interactive solver debugging

A developer tool to see the reconstruction algorithm working in real time. Generate a 3D LED fixture, fly a camera around it to synthesize captures, and watch the real M3 solver converge against ground truth — with per-LED error, parallax, and reprojection stats updating as you add views.

It is not a shipping module. It reuses the actual pipeline so what you debug is the real thing:

  • M9 make_fixture builds the ground-truth geometry and NoiseModel injects the same degradations the simulator uses;

  • the shared M3 camera model (look_at_quat + project) turns a camera pose into detections, in the exact WebXR convention the solver expects;

  • M3 reconstruct solves; the studio then scores every solved LED against the known truth.

Run

bazelisk run //tools/sim_studio:serve   # binds 0.0.0.0:8090 by default
# open http://localhost:8090

Reaching it from your host (claude-container)

.claude-container-overlay/overlay.json declares the studio as a named service ("services": {"studio": 8090, ...}), so once the server is running it is reachable from the host at http://studio.<instance>.claude.localhost/ (or http://studio.<instance>.claude.localhost:8484/ if the router doesn’t hold port 80) — no container restart needed, and no host-port collisions when several containers (one per worktree) run at once. <instance> is the workspace directory’s basename (led-mapper for the main checkout); run claude-container --services on the host to list every instance with working URLs. The service mux connects from inside the container, so binding localhost is fine; 0.0.0.0 remains the default for non-container use.

The Python API is fully local; the front-end loads Three.js from a CDN, so the browser needs internet access. (To vendor Three.js for offline use, drop the two ESM files next to app.js and adjust the import map in index.html.)

Using it

  1. New scene — pick a fixture (line/grid/cube/helix), LED count, and scale. Ground-truth LEDs render in green.

  2. Capture — orbit to a viewpoint and click Capture view: the LEDs the camera sees become detections and a frustum is drawn. Or click Auto-arc to place a whole sweep of views automatically (mirrors the real arc walk).

  3. Solve — runs M3 on the accumulated detections. Solved LEDs render colored by error (green = accurate → red = far from truth) with red lines to their true positions. Auto-solve after capture re-solves on every new view, so you watch the fit tighten as coverage grows.

  4. Noise — dial in pixel / pose / dropout noise per capture to see how the solver degrades; Min views / Min parallax expose the solver’s gates.

The stats panel shows views, detections, solved/total, mean & max ground-truth error (mm), global reprojection RMS (px), median parallax, and solve time.

Things to probe

  • A near-straight (small-arc) capture set → low parallax → watch confidence and error blow up (the degenerate case the production UI rejects).

  • Crank pose noise vs pixel noise to see which the bundle adjustment tolerates.

  • Compare fixtures: planar grid/line need the vertical sweep for out-of-plane parallax; cube/helix are easier.

HTTP API

Endpoint

Body

Returns

POST /api/scene

{fixture, leds, scale}

ground-truth LED positions + centroid/span

POST /api/capture

{eye, target, hfov, imgW, imgH, noise}

visible/added counts, pose, K

POST /api/solve

{minViews, minParallaxDeg, huberDelta}

OutputMap + per-LED ground-truth error + stats

POST /api/reset

—

clears captures (keeps the scene)

GET /api/fixtures · GET /api/state

—

fixture list · current counts

Tests

  • //tools/sim_studio:studio_test — the core (StudioSession: scene → capture → solve, scored vs truth; zero-noise arc recovers < 1 mm; noise increases error) and an HTTP integration test that boots a real server and drives the full scene → arc → solve flow, asserting the same accuracy and that / serves the app.