.embedder/hardware/. Run these files with hardware_script_run so provider helpers, bridge routing, validation, capture publishing, and hardware leases all apply.
Do not run a hardware script with plain Python or a shell command. Injected helpers will be missing, and the process will not participate in hardware coordination.
Choose a script location
Use a loose script for one probe:capture2.py or capture_v2.py; stale variants make it unclear which probe produced the evidence.
Keep a durable case note
CASE.md stores one bug across context compaction and later sessions. Use this structure:
.embedder/hardware/cases/spi2-nack/CASE.md
open, resolved, and abandoned. You may also add an updated timestamp. Do not delete a closed case; change its status and keep the evidence.
Update hypothesis verdicts and findings when a probe settles them. Keep the short in-session checklist in the task list instead of duplicating it in the note.
Write against injected helpers
The script runner inspects the file and selects providers from the detected hardware and helper names it uses. Provider preludes inject helpers before your code runs. Examples include:gdb.*,serial_send,serial_read, andserial_read_historyrtt_send,rtt_read, andrtt_read_historyla_*,scope_*,ppk2_*, andjoulescope_*ble_*
la_* interface for Saleae, Digilent, and PicoScope logic capture. Direct Digilent vendor helper calls are rejected.
Most provider libraries must not be imported directly. The J-Trace SDK is the exception: import jtrace in a script when you need its custom API.
Return structured results
Print a final one-line JSON object withsuccess and summary. Add data and metadata when they help the next step.
.embedder/hardware/read_boot.py
asyncio.run. The runner parses the last valid result object from stdout.
Provider publish helpers can add instrument captures to the Logic, Power, or Oscilloscope views. BLE helpers stream scan, GATT, and notification events to the Bluetooth view. The tool result lists each published instrument capture.
Run tools on the hardware host
Callrun_tool inside a hardware script when you need a flasher or debugger executable:
exit_code, output, and host.
Understand hardware leases
Everyhardware_script_run requests exclusive access.
Foreground lease
A foreground script holds the hardware for the tool operation. Other sessions wait until the script and provider cleanup finish. The default timeout is 60 seconds. You can set a foreground timeout from 1 second through 10 minutes.Background lease
Setrun_in_background=true for a soak, endurance test, or long capture:
timeout value is ignored; a 24-hour backstop prevents a dead script from holding the board forever.
Only one background hardware script may run in a session. A second script is refused until the first exits.
Cross-session protection
The arbiter queues other sessions behind an active owner. It also prevents a session from running an unchanged script whose latest successful run belongs to another session. Rewrite it for your task or use another filename. When a script programs firmware, Embedder records the load so other sessions know their previous hardware observations may be stale.Wait for or stop a background run
Use the task ID returned byhardware_script_run:
wait_task listens for completion. If its wait times out, the script keeps running and the lease remains held.
Stop a run with:
Review validation before running
File writes return hardware-script diagnostics. Fix them before you execute the script. Validation checks include:- Unknown or vendor-internal helper names
- A provider action used without its connection helper
- Unsafe or unsupported argument combinations
- Direct imports that bypass provider setup
Find existing scripts
The debug-session toolbox lists loose scripts, open cases, closed cases, and each script’s leading docstring..embedder is normally ignored by project search, so open a listed script by its exact path or list .embedder/hardware/ directly.
Pass the path relative to .embedder/hardware as script_name:
Fix script problems
The helper is undefined
The helper is undefined
Run the file with
hardware_script_run, not Python or shell. Confirm that hardware_status reports the provider and that the script uses its documented helper name.No provider is available
No provider is available
Refresh
hardware_status and follow the provider’s dependency or connection reason before rerunning.The board is busy
The board is busy
Check active trace sessions and background tasks. Wait for the owner or stop your session’s task; do not bypass the lease.
A bridge tool cannot see the probe
A bridge tool cannot see the probe
Replace subprocess use with
run_tool so the command runs on the hardware host.The script completed but no result was parsed
The script completed but no result was parsed
Print a final JSON object containing a boolean
success and string summary on one line.Combined workflows
Coordinate several observations in one script.
Debug mode overview
Choose a provider for the next probe.

