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

## Unreleased

- `set_pull`, `power_on`, `i2c_open`, `expansion` and the guide no longer say the pull resistors
are 3.3 V only: they pull to the LA voltage, at 1.8 V on firmware newer than 3.10.12.

## 3.0.3

- Needs embeddedci 3.0.3.
Expand Down
3 changes: 2 additions & 1 deletion packages/embeddedci-mcp/src/embeddedci_mcp/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
Target power internal 5 V (efuse 1) efuse=1 (external: efuse=2)

Pull resistors: set_pull(las, pull="up"|"down"|"off"); the pod picks the value. Today's boards
(pull_status shows each channel's supported directions; 3V3-referenced, so off at a 1.8 V LA bank):
(pull_status shows each channel's supported directions; they pull to the LA voltage, 1.8 V or 3.3 V;
firmware 3.10.12 and older refuses them at 1.8 V):
LA1, LA2 4.7k up LA3, LA4 2.2k up LA5, LA6 10k up
LA7, LA8 10k down only LA9-LA14 none

Expand Down
13 changes: 7 additions & 6 deletions packages/embeddedci-mcp/src/embeddedci_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ async def power_on(
"omit to use the current one."))] = None,
) -> m.PowerResult:
"""Power the board on with its wiring profile applied first: the profile's I/O voltage is set
(when the pod has none or another one), its pull resistors (pulls, at 3.3 V) are set, then the
(when the pod has none or another one), its pull resistors (pulls; at 1.8 V only on firmware newer than 3.10.12) are set, then the
rail goes on, and the pod records the profile.
The result names the rail, the profile and the I/O voltage. Never changes the I/O voltage under
a board that is already powered."""
Expand Down Expand Up @@ -958,7 +958,7 @@ async def i2c_open(
scl: Annotated[Optional[LaRef], Field(description="SCL channel; omit for the profile's i2c_scl.")] = None,
hz: Annotated[int, Field(ge=10_000, le=1_000_000, description="SCL rate.")] = 100_000,
pullups: Annotated[Literal["pod", "external"], Field(description=(
"pod: channels with the pod's pull-up on (set_pull(pull=\"up\") first, LA1-LA6 today, LA voltage 3.3); "
"pod: channels with the pod's pull-up on (set_pull(pull=\"up\") first, LA1-LA6 today; at 1.8 V firmware newer than 3.10.12); "
"external: the board has its own."))] = "pod",
) -> m.I2cSessionResult:
"""Make the pod an I2C master on two LA pins (gateware v55+), replacing any open session.
Expand Down Expand Up @@ -1654,8 +1654,8 @@ async def set_pull(
"Older form, use pull: true engages each channel's own direction, false is off."))] = None,
) -> m.PullStatusResult:
"""Pull LA channels up or down, or switch their pull resistor off. For an I2C bus pull SDA and
SCL up. The resistors are 3V3-referenced, so the pod refuses to engage them with the LA bank at
1.8 V."""
SCL up. The pull-ups pull to the LA voltage, at 1.8 V too on firmware newer than 3.10.12 (older
firmware refuses them with the LA bank at 1.8 V)."""
if pull is None and enabled is None:
raise ValueError('set_pull needs pull: "up", "down" or "off"')
want: Any = pull if pull is not None else bool(enabled)
Expand Down Expand Up @@ -1959,8 +1959,9 @@ async def expansion(
hz: Annotated[Optional[int], Field(ge=1, le=6_000_000, description=(
"Bus clock; default 400 kHz for I2C (100 kHz pcf8574), 1 MHz for SPI."))] = None,
pullups: Annotated[Optional[Literal["pod", "external"]], Field(description=(
"I2C pull-ups: pod (LA1-LA6 only, pull to 3.3 V, switched on here) or external (the "
"breakout's). Default pod at 3.3 V on LA1-LA6, else external."))] = None,
"I2C pull-ups: pod (LA1-LA6 only, pull to the LA voltage, switched on here) or external (the "
"breakout's). Default pod on LA1-LA6 when the pod has pull-ups at this voltage (1.8 V: "
"firmware newer than 3.10.12), else external."))] = None,
names: Annotated[Optional[Dict[str, str]], Field(description=(
"Names for the pins, {'EXT1': 'LED1', ...}; usable wherever EXTn is."))] = None,
) -> m.ExpansionResult:
Expand Down
4 changes: 2 additions & 2 deletions packages/embeddedci-mcp/tests/tools_surface.json
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,7 @@
}
],
"default": null,
"description": "I2C pull-ups: pod (LA1-LA6 only, pull to 3.3 V, switched on here) or external (the breakout's). Default pod at 3.3 V on LA1-LA6, else external.",
"description": "I2C pull-ups: pod (LA1-LA6 only, pull to the LA voltage, switched on here) or external (the breakout's). Default pod on LA1-LA6 when the pod has pull-ups at this voltage (1.8 V: firmware newer than 3.10.12), else external.",
"title": "Pullups"
},
"scl": {
Expand Down Expand Up @@ -2854,7 +2854,7 @@
},
"pullups": {
"default": "pod",
"description": "pod: channels with the pod's pull-up on (set_pull(pull=\"up\") first, LA1-LA6 today, LA voltage 3.3); external: the board has its own.",
"description": "pod: channels with the pod's pull-up on (set_pull(pull=\"up\") first, LA1-LA6 today; at 1.8 V firmware newer than 3.10.12); external: the board has its own.",
"enum": [
"pod",
"external"
Expand Down
5 changes: 5 additions & 0 deletions packages/embeddedci/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
gateware 58`, on every `status` up to firmware 3.10.12) no longer makes the serial transport
time out waiting for the prompt. A prompt followed only by complete `[tag] ...` lines ends the
reply.
- **Pull resistors at 1.8 V:** on firmware with the `la_pull_1v8` feature (newer than 3.10.12) the
pod's pulls work with the LA bank at 1.8 V (v3 boards pull up to the bank rail), so `power_on`
applies a 1.8 V profile's `pulls` and `expansion(pullups="pod")` (also its default) works at
1.8 V. With older firmware both behave as before, and `power_on` logs that the pulls stay off.
The `Wiring` warning for `pulls` with `la_mv` 1800 now names the firmware it needs.

## 3.0.3

Expand Down
9 changes: 5 additions & 4 deletions packages/embeddedci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ slave-SPI configuration port). It needs a LAN or cloud connection and firmware w
Pods with gateware v55+ (`bp.capabilities.gateware`, `bp.capabilities.bus_master`) are an I2C master
on any two LA pins, 10 kHz to 1 MHz: read and write registers of a chip on the DUT's board, or scan
the bus. The pins are open drain, so the bus needs pull-ups: the pod's own on LA1-LA6 (switch them
on first; they pull to 3.3 V, so the LA voltage must be 3.3 V), or the board's with
on first; they pull to the LA voltage, at 1.8 V on firmware newer than 3.10.12), or the board's with
`pullups="external"`.

```python
Expand Down Expand Up @@ -1220,9 +1220,10 @@ arguments it returns the `ExpansionStatus`, and `expansion(None)` detaches.
several chips on one bus: `addr=[0x20, 0x21]` gives `EXT1`..`EXT32`, numbered in that order.
- `sda` and `scl` default to the wiring profile's `i2c_sda` and `i2c_scl`, so the expander can sit
on the DUT's I2C bus.
- `pullups`: `"pod"` switches on the pod's pull-ups (LA1-LA6 only; they pull to 3.3 V) and
`"external"` relies on the breakout's. By default `"pod"` when the LA voltage is 3.3 V and both
pins are on LA1-LA6, else `"external"`. At 1.8 V the breakout needs pull-ups to 1.8 V.
- `pullups`: `"pod"` switches on the pod's pull-ups (LA1-LA6 only; they pull to the LA voltage)
and `"external"` relies on the breakout's. By default `"pod"` when both pins are on LA1-LA6 and
the pod has pull-ups at this LA voltage, else `"external"`. At 1.8 V that needs firmware newer
than 3.10.12; with older firmware the breakout needs its own pull-ups to 1.8 V.
- `hz` defaults to 400 kHz for I2C chips (100 kHz for the PCF8574) and 1 MHz for SPI chips.
- SPI chips take `spi=(sck, mosi, miso, cs)` (or a dict with those keys) instead of `sda`/`scl`;
omitted, the wiring profile's `spi_sclk`, `spi_mosi`, `spi_miso` and `spi_cs`. The pod's SPI
Expand Down
2 changes: 1 addition & 1 deletion packages/embeddedci/examples/test_bmp280.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
@pytest.fixture(scope="session")
def benchpod_la_voltage():
"""The DUT's I/O voltage, selected on the pod when the session connects."""
return 3.3 # change to 1.8 for a 1V8 board (the pull-ups then can't be used)
return 3.3 # change to 1.8 for a 1V8 board (pod pull-ups at 1.8 V: firmware newer than 3.10.12)


@pytest.fixture
Expand Down
41 changes: 31 additions & 10 deletions packages/embeddedci/src/embeddedci/benchpod/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,11 +1102,15 @@ def power_on(self, efuse: Optional[Union[Efuse, int]] = None,

def _apply_profile_pulls(self, w: Wiring) -> None:
"""Switch the pull resistors the profile lists on and the others off (``pulls`` None: leave
them). They work at 3.3 V only, and the console (serial) transport can't set them."""
them). Firmware before ``la_pull_1v8`` has them at 3.3 V only (at 1.8 V they are left
off), and the console (serial) transport can't set them."""
if w.pulls is None or type(self._transport).__name__ == "SerialTransport":
return
volts = w.la_voltage if w.la_voltage is not None else self.get_la_voltage().voltage
if volts is None or abs(volts - 3.3) > 0.05:
if not self._pulls_at(volts):
if volts is not None:
_log.warning("power_on: this firmware has no pull resistors at %g V; the profile's "
"pulls stay off (update the firmware)", volts)
return
wanted = w.pull_directions()
for la in PULL_TABLE:
Expand Down Expand Up @@ -1489,7 +1493,22 @@ def _flash_local(self, *, swclk: int, swdio: int, nreset: bool, target: str, fil
# The host names a direction ("up", "down", "off"); the pod picks the resistor and reports its
# value. Which channels have one and which way each can pull depends on the board: on today's
# boards LA1-LA6 pull up, LA7/LA8 down and LA9-LA14 have none (constants.PULL_TABLE). The
# resistors are 3V3-referenced, so the pod refuses to engage one while the LA bank is at 1.8 V.
# pull-ups go to the LA bank rail, so they work at 1.8 V too on firmware with the la_pull_1v8
# feature; older firmware refuses to engage one while the LA bank is at 1.8 V.

def _pulls_at(self, volts: Optional[float]) -> bool:
"""Whether the pod engages pull resistors at LA voltage ``volts``: at 3.3 V always, at
1.8 V on firmware with the ``la_pull_1v8`` feature (older firmware refuses them there)."""
if volts is None:
return False
if abs(volts - 3.3) <= 0.05:
return True
if abs(volts - 1.8) > 0.05:
return False
try:
return self.supports("la_pull_1v8")
except BenchPodError:
return False

def _pull_dir_api(self) -> bool:
"""The pod takes ``pull: up|down|off`` (feature ``la_pull_dir``); older firmware only
Expand Down Expand Up @@ -3653,9 +3672,10 @@ def expansion(
I2C chips: ``addr`` is the 7-bit address (default: the chip's first), or a list of them for
several chips on one bus (EXT pins numbered in that order); ``sda``/``scl`` default to the
wiring profile's ``i2c_sda``/``i2c_scl``, so the expander can share the DUT's bus.
``pullups`` is ``"pod"`` (the pod's pull-ups on LA1-LA6, switched on here; they pull to 3.3 V)
or ``"external"`` (the breakout's own); by default ``"pod"`` when the LA voltage is 3.3 V and
both pins are on LA1-LA6. ``hz`` defaults to 400 kHz (the chip's limit when lower).
``pullups`` is ``"pod"`` (the pod's pull-ups on LA1-LA6, switched on here; they pull to the LA
voltage) or ``"external"`` (the breakout's own); by default ``"pod"`` when both pins are on
LA1-LA6 and the pod has pull-ups at this LA voltage (3.3 V, or 1.8 V on firmware with the
``la_pull_1v8`` feature). ``hz`` defaults to 400 kHz (the chip's limit when lower).

``names`` names the pins: ``{"EXT1": "LED1", ...}`` or a list in EXT order. Omitted
arguments come from an ``expansion`` object in the wiring profile, when it has one
Expand Down Expand Up @@ -3705,13 +3725,14 @@ def expansion(
addrs = self._expansion_addrs(info, addr if addr is not None else block.get("addr"))
n_chips = 1
pull = pullups if pullups is not None else block.get("pullups")
pod_ok = self._pulls_at(lv) and sda_i <= 6 and scl_i <= 6
if pull is None:
pull = "pod" if abs(lv - 3.3) < 0.05 and sda_i <= 6 and scl_i <= 6 else "external"
pull = "pod" if pod_ok else "external"
check_choice(pull, _i2c_master.PULLUPS, "pullups")
if pull == "pod" and (abs(lv - 3.3) >= 0.05 or sda_i > 6 or scl_i > 6):
if pull == "pod" and not pod_ok:
raise _expansion.ExpansionError(
"pullups='pod' needs the LA voltage at 3.3 V and both pins on LA1-LA6 (the pod's "
"pull-ups pull to 3.3 V and only LA1-LA6 have them); use pullups='external' "
"pullups='pod' needs both pins on LA1-LA6 (only they have pod pull-ups) and, at "
"1.8 V, firmware with pull-ups at 1.8 V (newer than 3.10.12); use pullups='external' "
"with pull-ups on the breakout")
else:
if sda is not None or scl is not None or pullups is not None:
Expand Down
10 changes: 8 additions & 2 deletions packages/embeddedci/src/embeddedci/benchpod/feature_map.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"_generated": "GENERATED by tools/gen_features.py from features/features.toml. DO NOT EDIT: edit the table.",
"schema": 1,
"revision": 3,
"table_sha256": "2ff7c0e8d4790d851d4bf3dc5bb0be91aba2b40dc9d3b1abc20cf41430af67a0",
"revision": 4,
"table_sha256": "1a6b293fa3ceedaf6946f5a40de85f81ea99a3db74a5937a4742490b45902898",
"floor": "3.9.2",
"docs_base": "https://github.com/embeddedci-com/benchpod-firmware/blob/main/docs/",
"facts": {
Expand Down Expand Up @@ -652,6 +652,12 @@
"firmware": "3.10.12",
"board": "any",
"docs": "API.md#switch-or-query-an-la-pin-pull-resistor"
},
"la_pull_1v8": {
"rev": 4,
"firmware": "next",
"board": "any",
"docs": "API.md#switch-or-query-an-la-pin-pull-resistor"
}
}
}
3 changes: 2 additions & 1 deletion packages/embeddedci/src/embeddedci/benchpod/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ class PullState:
#: The resistor's value, e.g. ``"4.7k"`` (``""`` without one). Reported, never chosen: on
#: boards with several values the firmware picks one from the pin's function.
ohms: str
#: A pull can be engaged right now (the resistors are 3V3-referenced, so not at 1.8 V).
#: A pull can be engaged right now (a bank voltage is set; firmware before ``la_pull_1v8``:
#: only at 3.3 V).
available: bool = True
#: Every direction the channel can pull: ``("up",)``, ``("down",)``, ``("up", "down")`` or ``()``.
supported: Tuple[str, ...] = ()
Expand Down
3 changes: 2 additions & 1 deletion packages/embeddedci/src/embeddedci/benchpod/wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ def warnings(self) -> List[str]:
out.append(f"uart_rx is on LA{self.uart_rx}, which has a pull-down; the UART idles high, "
"so keep the pull disabled")
if self.la_mv == 1800 and self.pulls:
out.append("pulls: the pull resistors work at 3.3 V only; at 1.8 V they stay off")
out.append("pulls: at 1.8 V the pull resistors need firmware newer than 3.10.12; older "
"firmware leaves them off")
return out

def pull_directions(self) -> Dict[int, str]:
Expand Down
4 changes: 2 additions & 2 deletions packages/embeddedci/tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BENCHPOD_API_KEY=eci_… make e2e-cloud CLOUD_DEVICE=benchpod-v2.0.0
|---|---|---|---|
| pod | `test_e2e_pod.py` | `--benchpod-connection` | status/capabilities/typed state, LA voltage, rev3-only features, argument validation, firmware errors, every analog path, DAC codes vs the SDK volts mapping, DAC→ADC readback, `generate` levels in volts, `route=False` loopbacks, replay (shallow, co-triggered, deep on the deep image, refused on the loop image), `stop_dac_after`, shallow + deep ADC, LA + correlated capture, LA step pulses, the achieved LA rate at rounded and burst-capped rates, control loop (fixed/sweep/input map), gateware image round trip and automatic switching (control loop, deep replay, `switch_image=False`), bias resistors, sensor emulation (library sensors, two on one bus, faults, a stimulus, the NMEA GPS), UART session plumbing, CAN loopback + responder |
| gpio | `test_e2e_gpio.py` | `--benchpod-connection`; firmware with `la_pins`, gateware v35+ for triggers | GPIO output/open-drain read-back, pin ownership (UART refused on a GPIO pin and the reverse, release), bias-resistor conflicts both ways, step trains on GPIO pins, LA-voltage lock (rev3), wiring signal names with active-low, rising/level triggers, trigger timeout, triggered ADC capture, FPGA pulse widths measured from the trigger |
| rev3 | `test_e2e_rev3.py` | `--benchpod-connection` on a rev3 pod; `BENCHPOD_E2E_NRST_LA` for the wire checks | board strap (v3, ~3.0 V), 1.8 V bank read back from the mux status pin, pull-ups released and refused at 1.8 V, GPIO + capture on the 1.8 V bank, reset pin hold/release/pulse, pulses capped at 1 s, and with the jumper: the reset line open-drain to the bank rail at 3.3 V and 1.8 V and the pulse width on the wire; USB-C CC report consistency (and a cable seen with `BENCHPOD_E2E_USB_CC=1`) |
| rev3 | `test_e2e_rev3.py` | `--benchpod-connection` on a rev3 pod; `BENCHPOD_E2E_NRST_LA` for the wire checks | board strap (v3, ~3.0 V), 1.8 V bank read back from the mux status pin, pulls at 1.8 V (kept across the switch, a pull-up and a pull-down engaged at 1.8 V; firmware before `la_pull_1v8`: released and refused), GPIO + capture on the 1.8 V bank, reset pin hold/release/pulse, pulses capped at 1 s, and with the jumper: the reset line open-drain to the bank rail at 3.3 V and 1.8 V and the pulse width on the wire; USB-C CC report consistency (and a cable seen with `BENCHPOD_E2E_USB_CC=1`) |
| dut | `test_e2e_dut.py` | + `--benchpod-firmware` and the wired board | SWD flash, boot banner via power cycle, power monitor + eFuse see the board, interactive console (help/status/reset), firmware detects the emulated BMP280, firmware reports a missing sensor, the emulated sensor's bus capture sees the boot probe, a 4 s logic capture of the boot decodes the chip-id read (and every transaction the pod served) and the UART banner; power profiles of a boot, of a delayed power-on and of an unpowered rail; with `BENCHPOD_E2E_NRESET=1` (rev3): flash under reset, a reset pulse reboots the DUT with the rail up, a held reset keeps it quiet until released |
| digital | `test_e2e_digital.py` | `--benchpod-connection` on a digital-only pod (skips on the analog board) | status says `analog: false` and drops the analog capabilities; every analog call (DAC, ADC, 4-20 mA, ADC capture, correlated capture with ADC samples, generate, replay) fails fast with `UnsupportedFeatureError` (`feature="analog"`), raw commands carry the pod's own refusal, `dac_stop` still works and the pod still answers and captures LA data afterwards |
| usb | `test_e2e_usb.py` | `BENCHPOD_E2E_USB` | the text console: status/ping/LA voltage/power, fail-fast hints for everything else |
Expand Down Expand Up @@ -102,7 +102,7 @@ BENCHPOD_E2E_UART_SENSOR_TX=8 \
until the firmware opens it), the line the process node's own UART sensor tests use; the capture
reads it back from LA8. What skips there: the LA step-train, achieved-rate, above-12 MS/s,
pre-trigger and host-clock tests in `test_e2e_pod.py`, the pull-up toggle, the UART session on free
channels, every GPIO/ownership/trigger test in `test_e2e_gpio.py`, the 1.8 V pull-up and GPIO tests
channels, every GPIO/ownership/trigger test in `test_e2e_gpio.py`, the 1.8 V pull and GPIO tests
in `test_e2e_rev3.py`, the LA13/LA14 drive tests in `test_e2e_la13_14.py`, and the UART-session and
LA13/LA14 tests of the cloud tier. Everything else runs: captures (which only observe all 14
channels), the analog tiers, sensor emulation on the I2C pins, the pull-resistor directions, the
Expand Down
Loading