Skip to main content
Use a hardware script for a repeatable check, a sequence of instrument actions, or a long measurement. Ask Embedder to create the Python script under .embedder/hardware/ and to define what counts as success.

A simple UART check

A hardware script is ordinary Python, saved under .embedder/hardware/. When Embedder runs it, helpers such as serial_read are already defined, so you don’t import them. To write one yourself, save this file and replace the port with your board’s port:
.embedder/hardware/boot_check.py
The serial helpers take the port and, optionally, the baud rate, which defaults to 115200: Helpers for debuggers and instruments are covered on each tool’s page. See Use instrument helpers. End the script by printing one JSON result with success and a short summary. Put useful observations in data. Print the result on a single line, as json.dumps does by default. Embedder reads the last line of output that holds both success and summary. The same rules apply to a script that runs in the background: a result with "success": false ends the background task as failed. When a script is meant to test something, always print the result line as its last output. Leave it out only for capture-only scripts. Keep captures and results tied to the script and firmware revision that produced them.

Check a pin

To read hardware state from the debugger, connect with a gdb.* helper and read the register. This script attaches through a J-Link and passes when PA0 on an STM32F407 reads high. Replace the device, ELF, register address, and pin with your own:
.embedder/hardware/check_pin.py
Without attach=True, gdb.jlink_connect() and gdb.openocd_connect() program the target with the ELF and run to main. With it, they load symbols only, and the debugger still halts the target when it connects. See Choose programming or attachment before you connect to a board whose state matters.
Look up the register address for your MCU with register lookup. The other gdb.* helpers are listed in Script helpers.

Run a script

The embedder script command takes a path relative to .embedder/hardware/, such as boot_check.py or cases/i2c-nack/capture_bus.py. The command prints the script’s output as it runs, then the result’s summary. A script with no result line ends with Hardware script completed without asserting a result. The command exits with 0 when the script passes or doesn’t assert a result, 1 when it fails, and 2 for a usage error. Press Ctrl+C to stop the command. To stop a run that Embedder started from chat, stop the chat response. See CLI reference for all options. Run scripts through Embedder when they use its instrument helpers. Running the same file with plain python doesn’t provide the helpers or their setup.

Run a script from the editor

  1. Open any Python file in the workspace.
  2. Select Run Hardware Script (▷) in the editor title bar, right-click in the editor and choose it, or run Embedder: Run Hardware Script from the Command Palette.
  3. In the row that appears at the bottom of the chat, choose:
    • Run to execute the script without sending the result to Embedder. When it finishes, Hand to agent sends the result if you change your mind.
    • Run and hand to agent to execute the script and send the result to Embedder when it finishes.
    • Cancel to remove the row without touching hardware.
To repeat a script Embedder ran earlier in the chat, select ↻ Run on that run’s row. It runs the current contents of the file with the same profile and shows the same three choices. While the script runs, output streams to the row and to the Monitor’s Debug Output tab. Select Show output to bring up the Monitor. To stop the run, select Stop on the row or the stop button that replaces ▷ in the title bar. Limits for editor-started runs:
  • Only one editor-started script runs at a time. A second run shows Another hardware script is already running. Stop it first.
  • If an agent task or another session is using the hardware, the run fails with Hardware is busy in another workflow.
  • Editor-started runs never install Python packages. If a package is missing, the run fails and tells you to run the script from chat or with embedder script in a terminal, where you can approve the install.

Run a script from the chat input

/run-script [file] starts a script yourself from the chat input, without asking Embedder to run it. Its alias is /run-hardware-script. In the terminal UI panel, press s to stop a running script, a to hand a finished result to Embedder, r to run it again, and Esc to hide or close the panel. Only one script started this way runs at a time.

Supply a capture profile

For settings that change between runs, read them from capture_profile in the script and keep the values in a companion file named after the script, such as boot_check.profile.json. Override the profile and timeout at launch:
The profile must contain a JSON object, and the script must read the fields you supply. If the script needs Python packages that aren’t installed yet, run it once from chat or an interactive terminal so you can approve the install.

Use instrument helpers

Choose the tool first, then use its guide for dependencies, channel numbering, and supported operations: ITM/SWO, xSCOPE, and CAN have no script helpers of their own. Ask Embedder to read them, as their guides describe: ITM/SWO, xSCOPE, and CAN. Several instruments share la_* or scope_* helper names, but triggers, decoders, capture modes, and output controls still depend on the tool. A script written for one instrument may need changes for another. Use run_tool(["probe-rs", "list"]) in a script when a command must run on the computer the hardware is attached to, including the bridge host of a remote bridge. Name the target explicitly before any programming or control action. To show script measurements live, ask Embedder to publish them to a dashboard. This needs no firmware change. For generated waveforms, supplies, BLE connections, and similar resources, include cleanup that runs even when a test fails.

Watch a live capture preview

While a script captures from an instrument, the Monitor’s Power, Logic, or Oscilloscope tab shows a live preview. If no tab of that kind is open, the Monitor opens one. A chip with the capture’s name and a Live or Ended pill replace the tab’s usual setup controls. The preview doesn’t open a second connection to the instrument, and closing it doesn’t stop the script. Use the script’s stop control to end acquisition. A finished preview stays visible until you select New capture. Scripts for other instruments can publish their own preview points:
Timestamps are milliseconds from the start of acquisition. Send bounded batches, and pass state="stopped" with the final update. A preview never saves a capture; use the instrument’s normal capture helper for that.

Keep a hardware case

For an investigation that needs several scripts, keep related files together in a case folder under .embedder/hardware/cases/. Name the folder with lowercase letters, digits, and hyphens, such as i2c-nack:
CASE.md is the record of one bug. Ask Embedder to keep its status (open, resolved, or abandoned), the symptom, hypotheses with verdicts, findings, the next check, and paths to evidence up to date. Embedder reuses an existing case for the same bug instead of starting a new one. Update existing scripts when the test changes, so it stays clear which version produced a result. Run a case script from a shell with its path, such as embedder script cases/i2c-nack/capture_bus.py.

Run longer checks

Ask for a background run when you need a soak test or a long capture. Embedder starts the script and returns to the chat while it runs, and reports the result when the script exits. The board stays reserved for that chat until then. A background run isn’t limited by the script timeout, but it stops after 24 hours. To check on it or stop it, ask Embedder, or use the chat’s background tasks: in VS Code they appear above the chat input, and in the terminal UI, /background lists them. An active hardware task can make another session wait. Check /hardware-queue before starting a conflicting operation, and release the equipment when the run finishes. If a session that no longer needs the board still holds it, /hardware-force-release frees it after you confirm; that session’s hardware work is interrupted.

Troubleshoot

Last modified on November 13, 2026