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
6 changes: 6 additions & 0 deletions packages/embeddedci-mcp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog — `embeddedci-mcp`

## Unreleased

- Tool descriptions and the server guide say that from gateware v65 the emulation image has no SWD,
JTAG, SPI master or I2C master: `flash`, `spi_*`, `i2c_*`, `expansion` and `capture_la` with `send`
switch to the loop image themselves when no sensor runs, and refuse (`BP0059`) while sensors run.

## 4.0.4

For BenchPod firmware 4.0.4 (the `prog_flash` feature); needs the matching embeddedci (the tool says so on an older SDK).
Expand Down
5 changes: 4 additions & 1 deletion packages/embeddedci-mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ version the SDK pins (0.1.0, bundled) unless `BENCHPOD_SENSOR_LIBRARY`, the CLI'
| `control_loop` | Run a tabulated transfer function in the FPGA (for example a solar panel I-V curve). | `curve`, `voc_code`, `sharpness=4`, `points=256`, `k=8192`, `vmin=0`, `vmax=65535`, `tick_div=64`, `source`, `input_code=0`, `step=0`, `input_map`, `switch_image=true` |
| `loop_input` | Re-target the running loop's input without re-arming. | `input_code`, `source`, `step` |
| `loop_probe` | The running loop's live operating point. | none |
| `fpga_image` | Switch the FPGA to the `loop`, `deep_replay` or `emulation` gateware image (~2-3 s); refused while I2C, SPI or UART sensors run on the emulation image. | **`image`** |
| `fpga_image` | Switch the FPGA to the `loop`, `deep_replay` or `emulation` gateware image (~2-3 s); refused while I2C, SPI or UART sensors run on the emulation image. From gateware v65 the emulation image has no SWD, JTAG, SPI master or I2C master: `flash` (SWD/JTAG), `spi_*`, `i2c_*`, `expansion` and `capture_la` with `send` i2c/spi switch to the loop image themselves when no sensor runs, and refuse (`BP0059`) while sensors run (`sensor_stop` first, or flash before `sensor_start`). | **`image`** |

### CAN

Expand Down Expand Up @@ -533,6 +533,9 @@ capture tools' summaries, `la_timing` and `decode_la` instead.
`fpga_image` switches explicitly. I2C, SPI and UART sensors run on a third, emulation image that
`sensor_start` loads by itself; the pod never switches back, so `control_loop` and the deep
replays switch back once no such sensor runs (and name `sensor_stop` while one does).
From gateware v65 that emulation image has no SWD, JTAG, SPI master or I2C master: flash first, then
start the sensors. With sensors running those tools refuse with `BP0059`; with none running the pod
switches to the loop image by itself.
- **Non-blocking.** Tools run on worker threads under one device lock: a 5-minute flash doesn't
freeze the server, sends progress notifications, and concurrent calls can't interleave commands.
- **Annotations.** Read-only tools (`status`, `power_status`, `adc_read`, …) are marked so clients
Expand Down
2 changes: 1 addition & 1 deletion packages/embeddedci-mcp/src/embeddedci_mcp/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
- Analog: dac_output (DC), generate (sine/square/sawtooth) and replay drive the DAC and route its path; adc_read gives one calibrated value, capture_adc a waveform summary; dac_stop ends any DAC output.
- 4-20 mA input: adc_read(source='current_in') reads terminal J8 and returns current in amps (0.004 to 0.020 for a live loop) next to the voltage across the sense resistor (249 ohm; from analog module v3r5 100 ohm behind a 30 mA limiter, read in the low range by default, so a reading stuck near 28.5 to 31.5 mA is the limiter). calibration shows whether the pod has calibrated its ADC offset there. If not, analog readings can be off by up to about 50 mV: ask the user to disconnect J8, then calibrate (once per pod, stored on the pod; it corrects every ADC source).
- 4-20 mA output: current_out(current) holds a loop current on terminal J9, in amps (0.012 is 12 mA), and returns the current actually held and the range. It needs an external floating loop supply on J9 and cannot go below about 4 mA or above about 20 mA. It shares the DAC with the voltage outputs and switches them off; dac_stop does not return the loop to 4 mA, current_out(0.004) does. The loop must float: nothing in it may touch pod ground, also not through a target that shares a ground with the pod (SWD, UART). Ask the user how J9 is wired first, and never suggest wiring J9 straight into J8. generate and replay take dac_path='current_out' to play a waveform as a current (levels in amps); capture_adc(source='current_in') summarises the loop current in amps.
- Gateware images: the FPGA runs either the 'loop' image (control_loop) or the 'deep_replay' image (replays longer than 2048 samples). control_loop and replay switch automatically (~3 s; switched_image in the result says so). A switch resets the FPGA and stops any DAC output, UART session or sensor emulation, so start those after it. fpga_image switches explicitly. I2C/SPI/UART sensors run on a third, emulation image that sensor_start loads by itself (control_loop and deep replays are unavailable while it runs).
- Gateware images: the FPGA runs either the 'loop' image (control_loop) or the 'deep_replay' image (replays longer than 2048 samples). control_loop and replay switch automatically (~3 s; switched_image in the result says so). A switch resets the FPGA and stops any DAC output, UART session or sensor emulation, so start those after it. fpga_image switches explicitly. I2C/SPI/UART sensors run on a third, emulation image that sensor_start loads by itself (control_loop and deep replays are unavailable while it runs). From gateware v65 the emulation image has no SWD, JTAG, SPI master or I2C master: flash first, then start the sensors. While sensors run, flash (SWD/JTAG), spi_*, i2c_*, expansion and capture_la with send i2c/spi refuse with BP0059 (sensor_stop first); with no sensors running the pod switches to the loop image by itself (~3 s).
- Logic: capture_la, then decode_la (i2c/uart/spi/usb/modbus/can/pwm/onewire/smbus/pmbus; usb full speed needs a 48 MS/s capture) re-decodes that capture without re-capturing, and la_timing measures edge times, pulse widths, frequency and the delay between two channels (e.g. trigger pin to result pin).
- Triggers: capture_adc, capture_la and capture_correlated take trigger_la (+ trigger_edge rising/falling/high/low, trigger_timeout seconds) to start on an event rather than immediately, so t = 0 is that edge. Without the trigger firing the tool fails with "TriggerTimeout: ...".
- Power profiles: measure_power(duration) reports the DUT's average/minimum/peak current, voltage, energy and charge over a window, with an optional trace (points). To profile across other tool calls, bracket them with power_profile_start and power_profile_stop.
Expand Down
24 changes: 24 additions & 0 deletions packages/embeddedci-mcp/src/embeddedci_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,8 @@ async def spi_flash_info(

present=false means the ID read all 00 or all FF: nothing is answering (wiring, power, or /WP
and /HOLD not tied high). The pins are released again afterwards.

Gateware v65+: the emulation image (loaded by sensor_start) has no SPI master. With no I2C/SPI/UART sensor running the pod switches to the loop image by itself (~3 s); with sensors running this refuses (BP0059): sensor_stop first, or do it before sensor_start.
"""
def op() -> m.SpiFlashInfoResult:
pod = SESSION.require()
Expand Down Expand Up @@ -941,6 +943,8 @@ async def spi_flash_program(
25-series parts, first 16 MB. Throughput is roughly 30 KB/s over the LAN (erase is extra) and
slower over the cloud. Fails with the pod's message when nothing answers, the part is
write-protected, or a chunk does not verify.

Gateware v65+: the emulation image (loaded by sensor_start) has no SPI master. With no I2C/SPI/UART sensor running the pod switches to the loop image by itself (~3 s); with sensors running this refuses (BP0059): sensor_stop first, or do it before sensor_start.
"""
def op() -> m.SpiFlashProgramResult:
pod = SESSION.require()
Expand Down Expand Up @@ -996,6 +1000,8 @@ async def spi_transfer(
"""One full-duplex SPI transaction (CS asserted for all of tx) with any SPI device on the SPI pins.

Returns what came back on MISO. The SPI master is armed for the call and released after it.

Gateware v65+: the emulation image (loaded by sensor_start) has no SPI master. With no I2C/SPI/UART sensor running the pod switches to the loop image by itself (~3 s); with sensors running this refuses (BP0059): sensor_stop first, or do it before sensor_start.
"""
data = bytes.fromhex(tx_hex.replace(" ", ""))
if not data or len(data) > 4096:
Expand Down Expand Up @@ -1025,6 +1031,8 @@ async def i2c_open(
Then i2c_transfer, i2c_scan, or capture_la with send. SWD, SPI and I2C exclude each other.
"i2c busy" means another connection (the desktop app, the web app, a script) holds the
pod's I2C master: close it there.

Gateware v65+: the emulation image (loaded by sensor_start) has no I2C master. With no I2C/SPI/UART sensor running the pod switches to the loop image by itself (~3 s); with sensors running this refuses (BP0059): sensor_stop first, or do it before sensor_start.
"""
def op() -> m.I2cSessionResult:
pod = SESSION.require()
Expand Down Expand Up @@ -1174,6 +1182,12 @@ async def flash(
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.

Gateware v65+: SWD and JTAG are not in the emulation image (loaded by sensor_start). Flash
first, then start the sensors (one image switch). With no I2C/SPI/UART sensor running the pod
switches to the loop image by itself (~3 s); with sensors running the flash refuses (BP0059):
sensor_stop first. Flashing over UART or USB, or with the pod's own programming pins, switches
images on its own as before.

Give either `file` (a path on this server's host) or an uploaded build (`build`, or
`repo`/`ref` for the newest build of a branch). OpenOCD runs on this server's host, except for
an uploaded build on a cloud connection, which embeddedci.com flashes itself. The SWD pins, the
Expand Down Expand Up @@ -2379,6 +2393,8 @@ async def expansion(
EXT pins are not FPGA-timed: gpio_pulse, la_step, capture triggers and la_dir refuse them.
The expander's bus closes on its own before flash, i2c_open and SPI tools; i2c_open on the same
two pins shares the bus with it.

Gateware v65+: the emulation image (loaded by sensor_start) has no I2C or SPI master (the expander runs on it). With no I2C/SPI/UART sensor running the pod switches to the loop image by itself (~3 s); with sensors running this refuses (BP0059): sensor_stop first, or do it before sensor_start.
"""
def op() -> m.ExpansionResult:
pod = SESSION.require()
Expand Down Expand Up @@ -2643,6 +2659,10 @@ async def capture_la(
sample_rate_hz goes up to 12 MS/s, or 48 MS/s on gateware v50+ (48, 24 or 16 MS/s); above
12 MS/s a signal changing over ~6 million times per second for long stops early (truncated);
retry at 12 MS/s.

send i2c or spi needs the pod's bus master, which the emulation image (gateware v65+) lacks:
with no I2C/SPI/UART sensor running the pod switches to the loop image by itself (~3 s); with
sensors running it refuses (BP0059): sensor_stop first, or capture before sensor_start.
"""
def op() -> m.LaCaptureResult:
pod = SESSION.require()
Expand Down Expand Up @@ -3316,6 +3336,10 @@ async def fpga_image(
the emulation image once no I2C/SPI/UART sensor runs). The pod never switches back by itself,
and refuses to leave the emulation image while I2C/SPI/UART sensors run (sensor_stop first).
The switch resets the FPGA (any DAC output or UART session stops).

Gateware v65+: SWD, JTAG, the SPI master and the I2C master are not in the emulation image.
flash, spi_*, i2c_*, expansion and capture_la with send i2c/spi switch from it to the loop image
by themselves when no sensor runs, and refuse (BP0059) while sensors run.
"""
img = {"loop": FpgaImage.LOOP, "deep_replay": FpgaImage.DEEP_REPLAY,
"emulation": FpgaImage.EMULATION}[image]
Expand Down
9 changes: 9 additions & 0 deletions packages/embeddedci/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
application has not installed its own handler. A lease joined from `BENCHPOD_LEASE` is still the
runner's and is not released.

For gateware v65 (features table revision 18): the emulation image has no SWD, JTAG, SPI master or I2C master.

- `bp.has_bus_masters()` says whether the running image has them.
- `flash()` over SWD or JTAG, `open_spi()`, `spi_flash()`, `open_i2c()`, `expansion()` and
`capture_la(send=I2CSend/SpiSend)` switch the pod from the emulation image to the loop image (logged,
about 3 s) when no I2C, SPI or UART sensor runs, and raise `UnsupportedFeatureError` (`BP0059`) while
one does: stop the sensors first, or flash before starting them.
- The `benchpod_capability("spi_master")` and `("i2c_master")` markers do the same switch.

## 4.0.4

For BenchPod firmware 4.0.4 (features table revision 17).
Expand Down
Loading