Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/embeddedci-mcp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ For BenchPod firmware with the `jtag` feature; JTAG flashing needs embeddedci 4.
There is no transport argument: JTAG is used when the four JTAG pins are known and either no SWD
pins are, or the target is JTAG only (`esp32`, `esp32s2`, `gd32vf103`, `fe310`, `k210`, names
starting with `riscv`); otherwise SWD. `set_wiring` and `wiring` carry the new `jtag_*` fields.
- **`debug_port` in the wiring profile** (`swd`, `jtag` or null: automatic) picks the port for a board
wired for both. `flash` decides in this order: JTAG pins passed in the call (and no SWD pins) mean
JTAG, SWD pins passed mean SWD; else the profile's `debug_port`; else the automatic rule above.
`set_wiring` takes the field and `wiring` shows it. `flash` has no new argument. Needs embeddedci 4.0.4.

## 4.0.3

Expand Down
2 changes: 1 addition & 1 deletion packages/embeddedci-mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ description, ranges and enums, so an agent sees more than this table.

| Tool | Purpose | Parameters |
| --- | --- | --- |
| `flash` | Program the DUT over SWD or JTAG through the pod's CMSIS-DAP probe (JTAG is picked when the wiring has `jtag_tck`, `jtag_tms`, `jtag_tdi` and `jtag_tdo` and there are no SWD pins, or the target is JTAG only: `esp32`, `esp32s2`, `gd32vf103`, `fe310`, `k210`, `riscv*`; needs the pod's `jtag` feature): a local `file` (OpenOCD runs next to the server), or a build uploaded to embeddedci.com (`build` id or `latest`, `repo`, `ref`; embeddedci.com runs OpenOCD on a cloud connection, LAN/USB downloads it). With `target` `esp32` (or `esp32s3`, `esp32c3`, ...) the pod flashes an ESP32-family target over its UART ROM bootloader instead: `file` is a `.bin` or an ESP-IDF `flasher_args.json`, TXD0/RXD0 on `rx`/`tx` (default: the profile's `uart_rx`/`uart_tx`), IO0 on `boot`, EN on the pod's reset pin (`nreset`), a `.bin` at `load_address`. | `swclk`, `swdio`, `tck`, `tms`, `tdi`, `tdo`, `trst`, `target`, `file`, `nreset`, `load_address`, `target_power`, `verify=true`, `reset=true`, `connect_under_reset`, `extra_configs`, `extra_args`, `timeout_s=300`, `connect_attempts=5`, `build`, `repo`, `ref`, `artifact`, `server_side`, `rx`, `tx`, `boot` |
| `flash` | Program the DUT over SWD or JTAG through the pod's CMSIS-DAP probe (JTAG is picked when the wiring has `jtag_tck`, `jtag_tms`, `jtag_tdi` and `jtag_tdo` and there are no SWD pins, or the target is JTAG only: `esp32`, `esp32s2`, `gd32vf103`, `fe310`, `k210`, `riscv*`; the wiring profile's `debug_port` (`swd` or `jtag`) picks for a board wired for both, and JTAG or SWD pins passed in the call beat it; needs the pod's `jtag` feature): a local `file` (OpenOCD runs next to the server), or a build uploaded to embeddedci.com (`build` id or `latest`, `repo`, `ref`; embeddedci.com runs OpenOCD on a cloud connection, LAN/USB downloads it). With `target` `esp32` (or `esp32s3`, `esp32c3`, ...) the pod flashes an ESP32-family target over its UART ROM bootloader instead: `file` is a `.bin` or an ESP-IDF `flasher_args.json`, TXD0/RXD0 on `rx`/`tx` (default: the profile's `uart_rx`/`uart_tx`), IO0 on `boot`, EN on the pod's reset pin (`nreset`), a `.bin` at `load_address`. | `swclk`, `swdio`, `tck`, `tms`, `tdi`, `tdo`, `trst`, `target`, `file`, `nreset`, `load_address`, `target_power`, `verify=true`, `reset=true`, `connect_under_reset`, `extra_configs`, `extra_args`, `timeout_s=300`, `connect_attempts=5`, `build`, `repo`, `ref`, `artifact`, `server_side`, `rx`, `tx`, `boot` |
| `usb_flash` | Flash the board on the pod's USB host port, the way a computer would (pod firmware 4.0.3+, LAN or cloud). The loader comes from the file and the board that mounted: a UF2 or drag-and-drop drive (Pico, Adafruit, DAPLink), DFU or the STM32 ROM loader, Teensy, Arduino AVR and SAMD, ESP32; `reason` in the result says why. `.hex` and `.dfu` files are converted to a binary with their address. A Pico (RP2040, RP2350) in BOOTSEL gets a `.bin` or `.hex` through PICOBOOT (every page read back); `verify` reads a drive back (`FAIL.TXT`, `CURRENT.UF2`) and the result's `note` says what it found. A drive flash sets the file's date from this computer's clock. Starts host mode when it is off. | **`file`**, `address`, `name`, `leave=true`, `mode`, `port`, `timeout_s`, `verify=false` |
| `usb_check` | Check the board's own USB firmware on the pod's host port (pod firmware 4.0.3+, LAN or cloud): `enumerate` (power-on to pull-up, descriptor and mounted over `count` power cycles), `power` (current against `bMaxPower`), `suspend` (suspended current against 2.5 mA, resume, still answers), `reset` (port resets and the time to enumerate again), `replug` (VBUS dropouts of `off_ms`). The board's VBUS must come from the internal 5 V (efuse 1) rail, switched on (`power_on`). Returns when the check ends: `passed` is the verdict, `result` the numbers (uA, ms); a failing board is a normal result. Starts host mode when it is off. | **`test`**, `count`, `off_ms`, `timeout_ms`, `duration_ms`, `settle_ms`, `port`, `timeout_s` |
| `usb_hid` | The HID interfaces of the board on the pod's host port and its input reports (keyboard keys, mouse, gamepad; pod firmware 4.0.3+, `usb_host` first): `list` the interfaces with their report descriptors, `start` a capture into a ring of 64 on the pod, `read` reports from it, `stop` it. The capture ends when the board detaches or host mode ends. | `action=list`, `count=1`, `timeout_s=2`, `instance` |
Expand Down
3 changes: 3 additions & 0 deletions packages/embeddedci-mcp/src/embeddedci_mcp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ class WiringResult(BaseModel):
i2c_address: Optional[int] = Field(description="The profile's I2C address (i2c_addr) as a 7-bit integer; null when unset.")
swd_nreset: bool
swd_target: str
debug_port: Optional[str] = Field(None, description=(
"The profile's debug_port: 'swd' or 'jtag' (what flash uses when the call passes no pins); "
"null: automatic."))
pins: List[WiringPin] = Field(description="LA1-LA14 with what is wired to each and its bias resistor.")
signals: List[WiringSignal] = Field(default_factory=list)
warnings: List[str] = Field(default_factory=list,
Expand Down
6 changes: 4 additions & 2 deletions packages/embeddedci-mcp/src/embeddedci_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ def op() -> m.WiringResult:
async def set_wiring(
profile: Annotated[Dict[str, Any], Field(description=(
"The profile as a JSON object (schema version 2): la_mv, efuse, uart_rx/uart_tx/uart_baud, "
"i2c_sda/i2c_scl/i2c_addr, swd_swclk/swd_swdio/swd_nreset/swd_target, jtag_tck/jtag_tms/jtag_tdi/jtag_tdo/jtag_trst, spi_*, and signals "
"i2c_sda/i2c_scl/i2c_addr, swd_swclk/swd_swdio/swd_nreset/swd_target, jtag_tck/jtag_tms/jtag_tdi/jtag_tdo/jtag_trst, debug_port (\"swd\" or \"jtag\": what flash uses when "
"the call passes no pins; null: automatic), spi_*, and signals "
"[{name, la, direction, active_low, description}], pulls (the pull resistors power_on switches "
"on, the others off: {\"1\": \"up\", \"2\": \"up\", \"8\": \"down\"}, or a list of channels "
"that pull their own way, e.g. [1, 2]; today LA1-LA6 pull up, LA7/LA8 down; left out: "
Expand Down Expand Up @@ -1135,7 +1136,8 @@ async def flash(
SWD or JTAG is chosen for you, there is no transport argument: JTAG when the four JTAG pins
(`tck`, `tms`, `tdi`, `tdo`, from the arguments or the profile's jtag_*) are known and either
no SWD pins are, or the target is JTAG only (esp32, esp32s2, gd32vf103, fe310, k210 and riscv*
OpenOCD configs, e.g. target/esp32.cfg); otherwise SWD. JTAG needs the pod's `jtag` feature
OpenOCD configs, e.g. target/esp32.cfg); otherwise SWD. JTAG pins passed in the call mean JTAG,
SWD pins passed mean SWD, else the profile's debug_port (swd or jtag) decides. JTAG needs the pod's `jtag` feature
(newer firmware): without it the call fails before anything is armed.

Give either `file` (a path on this server's host) or an uploaded build (`build`, or
Expand Down
1 change: 1 addition & 0 deletions packages/embeddedci-mcp/src/embeddedci_mcp/summaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def wiring_summary(wiring: Wiring, *, saved: bool = False) -> m.WiringResult:
profile_rev=wiring.profile_rev, la_voltage=wiring.la_voltage,
efuse=wiring.efuse, uart_baud=wiring.uart_baud, i2c_address=wiring.i2c_address,
swd_nreset=wiring.swd_nreset, swd_target=wiring.swd_target,
debug_port=getattr(wiring, "debug_port", None),
pins=[m.WiringPin(la=la, wired_to=pins.get(la), pull=_bias(la), dut_dir=dirs.get(la))
for la in range(1, 15)],
signals=[m.WiringSignal(name=s.name, la=s.la, direction=s.direction,
Expand Down
36 changes: 36 additions & 0 deletions packages/embeddedci-mcp/tests/test_wiring_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ def test_wiring_draws_the_profile_on_the_pods_header(connected, monkeypatch):
# SDK the MCP supports, which may predate them.
needs_jtag_sdk = pytest.mark.skipif(not hasattr(Wiring, "jtag_tck"),
reason="the installed embeddedci SDK has no jtag_* wiring fields")
needs_debug_port_sdk = pytest.mark.skipif(not hasattr(Wiring, "debug_port"),
reason="the installed embeddedci SDK has no debug_port wiring field")


@needs_jtag_sdk
Expand Down Expand Up @@ -251,3 +253,37 @@ def old_flash(**kwargs):
monkeypatch.setattr(SESSION.require(), "flash", old_flash)
with pytest.raises(ToolError, match="JTAG needs a newer embeddedci SDK"):
call("flash", file="a.elf", tck=3, tms=4, tdi=5, tdo=6)


@needs_debug_port_sdk
def test_set_wiring_takes_and_shows_debug_port(connected):
assert call("set_wiring", profile={"version": 2, "la_mv": 3300})["debug_port"] is None
result = call("set_wiring", profile={"version": 2, "la_mv": 3300, "debug_port": "jtag"})
assert result["debug_port"] == "jtag" and result["profile"]["debug_port"] == "jtag"
assert SESSION.require().wiring.debug_port == "jtag"
assert call("wiring")["debug_port"] == "jtag"


@needs_debug_port_sdk
def test_set_wiring_validates_debug_port(connected):
with pytest.raises(ToolError, match="debug_port must be 'swd' or 'jtag'"):
call("set_wiring", profile={"version": 2, "debug_port": "usb"})


@needs_debug_port_sdk
def test_flash_adds_no_argument_for_debug_port(connected, monkeypatch):
from embeddedci.benchpod.flash import FlashResult

seen = {}

def fake_flash(**kwargs):
seen.update(kwargs)
return FlashResult(ok=True, returncode=0, stdout="", stderr="")

_set({**BENCH, "debug_port": "jtag"})
monkeypatch.setattr(SESSION.require(), "flash", fake_flash)
assert call("flash", file="a.elf")["ok"] is True
assert "debug_port" not in seen and "port" not in seen and "transport" not in seen
assert "flash" in mcp._tool_manager._tools
desc = mcp._tool_manager._tools["flash"].description
assert "debug_port" in desc
2 changes: 1 addition & 1 deletion packages/embeddedci-mcp/tests/tools_surface.json
Original file line number Diff line number Diff line change
Expand Up @@ -5389,7 +5389,7 @@
"properties": {
"profile": {
"additionalProperties": true,
"description": "The profile as a JSON object (schema version 2): la_mv, efuse, uart_rx/uart_tx/uart_baud, i2c_sda/i2c_scl/i2c_addr, swd_swclk/swd_swdio/swd_nreset/swd_target, jtag_tck/jtag_tms/jtag_tdi/jtag_tdo/jtag_trst, spi_*, and signals [{name, la, direction, active_low, description}], pulls (the pull resistors power_on switches on, the others off: {\"1\": \"up\", \"2\": \"up\", \"8\": \"down\"}, or a list of channels that pull their own way, e.g. [1, 2]; today LA1-LA6 pull up, LA7/LA8 down; left out: power_on leaves the pulls as they are). What it leaves out is undefined (not wired); a pin set to null is not wired. {\"version\": 1} objects fill in the old default pins.",
"description": "The profile as a JSON object (schema version 2): la_mv, efuse, uart_rx/uart_tx/uart_baud, i2c_sda/i2c_scl/i2c_addr, swd_swclk/swd_swdio/swd_nreset/swd_target, jtag_tck/jtag_tms/jtag_tdi/jtag_tdo/jtag_trst, debug_port (\"swd\" or \"jtag\": what flash uses when the call passes no pins; null: automatic), spi_*, and signals [{name, la, direction, active_low, description}], pulls (the pull resistors power_on switches on, the others off: {\"1\": \"up\", \"2\": \"up\", \"8\": \"down\"}, or a list of channels that pull their own way, e.g. [1, 2]; today LA1-LA6 pull up, LA7/LA8 down; left out: power_on leaves the pulls as they are). What it leaves out is undefined (not wired); a pin set to null is not wired. {\"version\": 1} objects fill in the old default pins.",
"title": "Profile",
"type": "object"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/embeddedci/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ SWD flashing is unchanged.
either no SWD pins are, or the target is JTAG only (`esp32`, `esp32s2`, `gd32vf103`, `fe310`,
`k210`, names starting with `riscv`); otherwise SWD. A pod without the `jtag` feature raises
`UnsupportedFeatureError` before anything is armed.
- **`debug_port` in the wiring profile** (`"swd"`, `"jtag"` or `None`, the default: automatic) picks the
port for a board wired for both. `bp.flash()` decides in this order: pins passed in the call
win (JTAG pins only: JTAG; SWD pins only: SWD; both kinds or neither: go on), then the profile's
`debug_port` (an incomplete pin set raises, naming the unset profile fields, e.g. "debug_port is
jtag but jtag_tdo is not set"), then the automatic rule above. `flash` takes no new argument.
Passing only JTAG pins now means JTAG even when SWD is wired and the target is an ARM part.
- `Transport.dap_start()` takes `tck`, `tms`, `tdi`, `tdo`, `trst` and `port`; `swclk` and `swdio`
are optional when the JTAG pins are given.
- The bundled feature table is revision 16.
Expand Down
6 changes: 5 additions & 1 deletion packages/embeddedci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ print(wiring.describe()) # a pin table: bias resistor and
| `i2c_sda`, `i2c_scl`, `i2c_addr` | not wired, not wired, not set | the I2C bus (emulated sensors default to it; put I2C on LA1-LA6, which have pull-ups) |
| `swd_swclk`, `swd_swdio`, `swd_nreset`, `swd_target` | not wired, not wired, `False`, `""` (auto-detect) | flashing |
| `jtag_tck`, `jtag_tms`, `jtag_tdi`, `jtag_tdo`, `jtag_trst` | not wired | JTAG flashing (firmware feature `jtag`); `jtag_trst` is optional. `jtag_tck` may share a channel with `swd_swclk` and `jtag_tms` with `swd_swdio` (the same pins on an ARM part); every other overlap is an error |
| `debug_port` | `None` (automatic) | `"swd"` or `"jtag"`: which port `flash` uses when the call passes no pins of either kind. Automatic: JTAG only when SWD is not wired or the target is JTAG only. An incomplete pin set for the chosen port is an error naming the unset fields |
| `spi_sclk`, `spi_mosi`, `spi_miso`, `spi_cs` | not wired | decoder channels |
| `signals` | `[]` | named signals: `Signal(name, la, direction="input"/"output"/"open_drain"/"bidir", active_low=False, description="")` |
| `dut_dirs` | `{}` | the DUT direction of a role or signal where its default is wrong: `{"uart_rx": "bidir", "READY": "dut_input"}` (role key or signal name to `dut_input`, `dut_output` or `bidir`); see [pin directions](#gpio-on-the-la-pins) |
Expand Down Expand Up @@ -996,7 +997,10 @@ assert result.ok, result.stderr # also: returncode, stdout, target_unreachab
JTAG when all four JTAG pins are known and either no SWD pins are, or the target is JTAG only:
`esp32`, `esp32s2`, `gd32vf103`, `fe310`, `k210` and any name starting with `riscv` (the OpenOCD
config's file name, so `target/esp32.cfg` counts). Otherwise it uses SWD. With both wired, an ARM
target keeps SWD (faster). JTAG needs the pod's `jtag` feature (firmware with features table
target keeps SWD (faster) unless the profile's `debug_port` says `"jtag"`. The order: pins passed
in the call win (JTAG pins only: JTAG, the rest from the profile; SWD pins only: SWD; both kinds
or neither: go on), then the profile's `debug_port` (`"swd"` or `"jtag"`; an incomplete pin set
raises, e.g. "debug_port is jtag but jtag_tdo is not set"), then the automatic rule above. JTAG needs the pod's `jtag` feature (firmware with features table
revision 16, gateware v61 or later, not the emulation FPGA image) and raises
`UnsupportedFeatureError` before anything is armed without it. A bare `"esp32"` target (no
`target/` path) still flashes over the chip's UART bootloader. An uploaded build flashed by
Expand Down
Loading