diff --git a/packages/embeddedci-mcp/CHANGELOG.md b/packages/embeddedci-mcp/CHANGELOG.md index d33e8b6..67029ec 100644 --- a/packages/embeddedci-mcp/CHANGELOG.md +++ b/packages/embeddedci-mcp/CHANGELOG.md @@ -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. diff --git a/packages/embeddedci-mcp/src/embeddedci_mcp/guide.py b/packages/embeddedci-mcp/src/embeddedci_mcp/guide.py index c0c592d..1111e12 100644 --- a/packages/embeddedci-mcp/src/embeddedci_mcp/guide.py +++ b/packages/embeddedci-mcp/src/embeddedci_mcp/guide.py @@ -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 diff --git a/packages/embeddedci-mcp/src/embeddedci_mcp/server.py b/packages/embeddedci-mcp/src/embeddedci_mcp/server.py index 5372c1f..0552a7d 100644 --- a/packages/embeddedci-mcp/src/embeddedci_mcp/server.py +++ b/packages/embeddedci-mcp/src/embeddedci_mcp/server.py @@ -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.""" @@ -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. @@ -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) @@ -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: diff --git a/packages/embeddedci-mcp/tests/tools_surface.json b/packages/embeddedci-mcp/tests/tools_surface.json index 060daf5..931ec02 100644 --- a/packages/embeddedci-mcp/tests/tools_surface.json +++ b/packages/embeddedci-mcp/tests/tools_surface.json @@ -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": { @@ -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" diff --git a/packages/embeddedci/CHANGELOG.md b/packages/embeddedci/CHANGELOG.md index 9da753e..b76d9c5 100644 --- a/packages/embeddedci/CHANGELOG.md +++ b/packages/embeddedci/CHANGELOG.md @@ -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 diff --git a/packages/embeddedci/README.md b/packages/embeddedci/README.md index 3a72d5a..892a751 100644 --- a/packages/embeddedci/README.md +++ b/packages/embeddedci/README.md @@ -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 @@ -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 diff --git a/packages/embeddedci/examples/test_bmp280.py b/packages/embeddedci/examples/test_bmp280.py index b41300c..df2c091 100644 --- a/packages/embeddedci/examples/test_bmp280.py +++ b/packages/embeddedci/examples/test_bmp280.py @@ -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 diff --git a/packages/embeddedci/src/embeddedci/benchpod/client.py b/packages/embeddedci/src/embeddedci/benchpod/client.py index ee435a6..dd62f9b 100644 --- a/packages/embeddedci/src/embeddedci/benchpod/client.py +++ b/packages/embeddedci/src/embeddedci/benchpod/client.py @@ -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: @@ -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 @@ -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 @@ -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: diff --git a/packages/embeddedci/src/embeddedci/benchpod/feature_map.json b/packages/embeddedci/src/embeddedci/benchpod/feature_map.json index 874e2b8..df77ddd 100644 --- a/packages/embeddedci/src/embeddedci/benchpod/feature_map.json +++ b/packages/embeddedci/src/embeddedci/benchpod/feature_map.json @@ -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": { @@ -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" } } } diff --git a/packages/embeddedci/src/embeddedci/benchpod/state.py b/packages/embeddedci/src/embeddedci/benchpod/state.py index 03abd00..2e02349 100644 --- a/packages/embeddedci/src/embeddedci/benchpod/state.py +++ b/packages/embeddedci/src/embeddedci/benchpod/state.py @@ -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, ...] = () diff --git a/packages/embeddedci/src/embeddedci/benchpod/wiring.py b/packages/embeddedci/src/embeddedci/benchpod/wiring.py index dcd80ab..d8b1d7a 100644 --- a/packages/embeddedci/src/embeddedci/benchpod/wiring.py +++ b/packages/embeddedci/src/embeddedci/benchpod/wiring.py @@ -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]: diff --git a/packages/embeddedci/tests/e2e/README.md b/packages/embeddedci/tests/e2e/README.md index acf8c09..ec046a1 100644 --- a/packages/embeddedci/tests/e2e/README.md +++ b/packages/embeddedci/tests/e2e/README.md @@ -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 | @@ -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 diff --git a/packages/embeddedci/tests/e2e/test_e2e_rev3.py b/packages/embeddedci/tests/e2e/test_e2e_rev3.py index 8bb0399..c308655 100644 --- a/packages/embeddedci/tests/e2e/test_e2e_rev3.py +++ b/packages/embeddedci/tests/e2e/test_e2e_rev3.py @@ -22,7 +22,7 @@ from embeddedci.benchpod import FirmwareError, ResetState, UsbCcStatus -from e2e_bench import FREE_LA, FREE_PULL_LA +from e2e_bench import FREE_LA, FREE_PULL_LA, FREE_PULLDOWN_LA from e2e_helpers import events_during pytestmark = pytest.mark.hardware @@ -106,22 +106,51 @@ def test_bank_voltage_reads_back_from_the_mux(v3): @FREE_PULL_LA -def test_1v8_releases_and_refuses_the_pull_ups(v3, bench): +def test_pulls_at_1v8(v3, bench): + """v3 pull-ups go to the bank rail. Firmware with la_pull_1v8 keeps an engaged pull across the + switch to 1.8 V, engages one at 1.8 V and the line reads high there; older firmware releases + it on the switch and refuses it at 1.8 V.""" ch = bench.free_pull_la v3.set_la_voltage(3.3) before = v3.pull_state(ch).enabled try: v3.enable_pullup(ch) v3.set_la_voltage(1.8) - # the pull-ups are referenced to +3V3: left engaged they would lift a 1.8 V line to 3.3 V - assert not [la for la in v3.enabled_pulls() if la <= 6], v3.enabled_pulls() - with pytest.raises(FirmwareError, match="1.8"): + if v3.supports("la_pull_1v8"): + assert ch in v3.enabled_pulls(), v3.enabled_pulls() + v3.disable_pullup(ch) v3.enable_pullup(ch) + assert v3.pull_state(ch).state == "up" + if v3.capabilities.la_pins: + assert v3.read_gpio(ch) == 1 # held high at the 1.8 V bank, nothing driving it + else: + assert not [la for la in v3.enabled_pulls() if la <= 6], v3.enabled_pulls() + with pytest.raises(FirmwareError, match="1.8"): + v3.enable_pullup(ch) finally: v3.set_la_voltage(3.3) v3.set_pull(ch, before) +@FREE_PULLDOWN_LA +def test_pull_down_at_1v8(v3, bench): + """LA7/LA8 pull to ground on every board: firmware with la_pull_1v8 engages them at 1.8 V.""" + if not v3.supports("la_pull_1v8"): + pytest.skip("the pod firmware has no pulls at 1.8 V (feature la_pull_1v8)") + ch = bench.free_pulldown_la + before = v3.pull_state(ch).enabled + try: + v3.set_la_voltage(1.8) + v3.set_pull(ch, "down") + assert v3.pull_state(ch).state == "down" + if v3.capabilities.la_pins: + assert v3.read_gpio(ch) == 0 + finally: + v3.set_pull(ch, "off") + v3.set_la_voltage(3.3) + v3.set_pull(ch, before) + + @FREE_LA def test_gpio_and_capture_work_on_the_1v8_bank(v3, bench): if not v3.capabilities.la_pins: diff --git a/packages/embeddedci/tests/test_expansion.py b/packages/embeddedci/tests/test_expansion.py index b40dbfa..3a95cf7 100644 --- a/packages/embeddedci/tests/test_expansion.py +++ b/packages/embeddedci/tests/test_expansion.py @@ -111,15 +111,19 @@ def olat(self) -> int: class ExpPod: - def __init__(self, chips: Dict[int, Any], *, mv: int = 3300) -> None: + def __init__(self, chips: Dict[int, Any], *, mv: int = 3300, features_rev: int = 0) -> None: self.chips = chips self.mv = mv + self.features_rev = features_rev self.commands: List[dict] = [] self.session: Optional[dict] = None self.pullups: set = set() self.gpio: Dict[int, dict] = {} def status(self) -> Dict[str, Any]: + if self.features_rev: # 4: la_pull_1v8, pulls at a 1.8 V bank + return {"board": "stm32h563", "version": "3.10.13", "gateware": 58, "fpga_image": "deep", + "features_rev": self.features_rev, "hw": ["nrst_pin"]} return {"board": "stm32h563", "version": "3.10.4", "gateware": 55, "caps": ["la", "la_pins", "gpio_read", "capture_trigger", "spi_master"]} @@ -141,6 +145,11 @@ def command(self, req: dict) -> Any: if cmd == "la" and "pullup" in req: (self.pullups.add if req["pullup"] == "on" else self.pullups.discard)(req["la"]) return {"la": req["la"], "pullup": req["pullup"]} + if cmd == "la" and "pull" in req: + on = req["pull"] != "off" + (self.pullups.add if on else self.pullups.discard)(req["la"]) + return {"la": req["la"], "pullup": int(on), "ohms": "4.7k", "pull": "up", + "state": "up" if on else "off", "dirs": ["up"], "pullups_available": 1} if cmd == "i2c_start": if self.session: raise FirmwareError("i2c busy: send i2c_stop first", cmd=cmd) @@ -175,8 +184,8 @@ def command(self, req: dict) -> Any: raise AssertionError(f"unexpected {req}") -def attach(chips=None, *, wiring=None, mv=3300, **kw): - fake = ExpPod(chips if chips is not None else {0x20: Tca9555()}, mv=mv) +def attach(chips=None, *, wiring=None, mv=3300, features_rev=0, **kw): + fake = ExpPod(chips if chips is not None else {0x20: Tca9555()}, mv=mv, features_rev=features_rev) bp = BenchPod(transport=fake, wiring=wiring or Wiring(i2c_sda=1, i2c_scl=2)) if "chip" not in kw: kw["chip"] = "tca9555" @@ -237,10 +246,12 @@ def test_voltage_checks(): fake = ExpPod({0x20: Tca9555()}, mv=0) with pytest.raises(ExpansionError, match="set the LA voltage first"): BenchPod(transport=fake).expansion("tca9555") - with pytest.raises(ExpansionError, match="pullups='pod' needs the LA voltage at 3.3 V"): - attach(mv=1800, pullups="pod") - bp, fake, st = attach(mv=1800) # 1.8 V: the breakout's pull-ups + with pytest.raises(ExpansionError, match="at 1.8 V, firmware with pull-ups at 1.8 V"): + attach(mv=1800, pullups="pod") # older firmware: none at 1.8 V + bp, fake, st = attach(mv=1800) # so the breakout's pull-ups assert st.pullups == "external" and fake.pullups == set() + bp, fake, st = attach(mv=1800, features_rev=4) # la_pull_1v8: the pod's, at 1.8 V + assert st.pullups == "pod" and fake.pullups == {1, 2} def test_argument_validation(): diff --git a/packages/embeddedci/tests/test_wiring_profiles.py b/packages/embeddedci/tests/test_wiring_profiles.py index 2d2549d..5688401 100644 --- a/packages/embeddedci/tests/test_wiring_profiles.py +++ b/packages/embeddedci/tests/test_wiring_profiles.py @@ -230,6 +230,31 @@ def test_power_on_leaves_the_pulls_without_the_key_or_at_1v8(): assert pod.sent("la") == [] +class PullsAt1v8Pod(ProfilePod): + """Firmware with la_pull_1v8 (features revision 4): pulls work with the bank at 1.8 V.""" + + def status(self) -> Dict[str, Any]: + return {"board": "stm32h563", "adc_bits": 16, "version": "3.10.13", "features_rev": 4, + "gateware": 58, "fpga_image": "deep", "hw": ["nrst_pin"]} + + def command(self, req: dict) -> Any: + if req["cmd"] == "la" and "la" in req: + self.commands.append(req) + on = req.get("pull", "off") != "off" + d = "down" if req["la"] in (7, 8) else "up" + return {"la": req["la"], "pullup": int(on), "ohms": "4.7k", "pull": d, + "state": d if on else "off", "dirs": [d], "pullups_available": 1} + return super().command(req) + + +def test_power_on_applies_the_pulls_at_1v8_on_firmware_that_has_them(): + pod = PullsAt1v8Pod({"k66": {**K66, "pulls": [1]}}, default="k66") + bp = BenchPod(transport=pod, lease=False) + bp.power_on() + sets = {c["la"]: c["pull"] for c in pod.sent("la")} + assert sets == {1: "up", 2: "off", 3: "off", 4: "off", 5: "off", 6: "off", 7: "off", 8: "off"} + + def test_pulls_key(): w = Wiring.from_dict({"version": 2, "pulls": [3, 1, 3]}) assert w.pulls == (1, 3) and w.to_dict()["pulls"] == [1, 3] @@ -238,7 +263,7 @@ def test_pulls_key(): Wiring(pulls=[9]) assert not Wiring(i2c_sda=7, pulls=[]).warnings() assert Wiring(i2c_sda=7, pulls=[7]).warnings() - assert any("3.3 V only" in x for x in Wiring(la_mv=1800, pulls=[1]).warnings()) + assert any("newer than 3.10.12" in x for x in Wiring(la_mv=1800, pulls=[1]).warnings()) def test_connect_sets_the_io_voltage_from_the_pods_profile():