Skip to content

tests: USB port-level RF reset between matrix cells#78

Merged
josephnef merged 1 commit into
masterfrom
regress-rf-state-reset
Jun 3, 2026
Merged

tests: USB port-level RF reset between matrix cells#78
josephnef merged 1 commit into
masterfrom
regress-rf-state-reset

Conversation

@josephnef
Copy link
Copy Markdown
Collaborator

Summary

Adds `usb_port_power_cycle(dut)` to `tests/regress.py` — toggles the USB port's `authorized` sysfs flag to force a chip-power cycle between matrix cells. Called from `_ensure_dut_location` so every cell starts with the DUT's RF state at chip-reset defaults regardless of what the previous cell left behind.

Why

`libusb_reset_device` and sysfs unbind/rebind do NOT reset Realtek RF analog state — values written to RF registers survive both. Without the port-level cycle, canary captures and matrix cells inherit RF state (band-select bits, IQK coefficients, AGC indices) from the previous run on the same DUT.

Verified empirically on RTL8814AU during the 8814A channel-set chain work: fresh-chip-cycle captures showed RF[A] 0x18 bit 16 (band-select) and RF[A] 0x00 bit 15 (LNA mode) reproducibly clean. Without the cycle, those bits drifted run-to-run.

Cost

Adds ~3 s per DUT per cell (0.5 s deauthorize gap + 2 s re-enumerate settle). Opt-out via `--no-rf-reset` for trivial smoke runs.

Test plan

  • Helper smoke-tested directly on the 8814 sysfs path — single cycle took 3.34 s, device re-enumerated cleanly
  • regress.py argparse round-trips the new flag (`--help` shows it; default-on)
  • Matrix run on host with 8814 + 8821 — cells start clean, no inherited state between cells (used in the 8814A channel-set chain PR's hardware verification)

Adds usb_port_power_cycle(dut): writes 0 then 1 to
/sys/bus/usb/devices/<id>/authorized with a 0.5 s gap and a 2 s
settle. Called at the start of _ensure_dut_location, so every cell
starts with the DUT's RF state at chip-reset defaults regardless of
what the previous cell left behind.

Why this is needed: libusb_reset_device and sysfs unbind/rebind do
NOT reset Realtek RF analog state — values written to RF registers
survive both. Without the port-level cycle, canary captures of e.g.
RF[A]/[B] 0x18 retain band-select bits from the previous session,
turning per-cell comparisons into noise. Verified empirically on
RTL8814AU while validating the PHY_SwitchWirelessBand8814A port:
fresh-chip captures vs prior-session-state captures differ in bit
16 of RF 0x18 and bit 15 of RF 0x00 simply because the chip never
fully powered down between runs.

Adds ~3 s per DUT per cell (2.5 s settle + the 0.5 s gap). Cycle
is default-on and can be opted out with --no-rf-reset for trivial
smoke runs where the perf hit isn't worth it.

Smoke-tested on the host 8814 sysfs path — single cycle took 3.34 s
and the device re-enumerated cleanly afterward.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@josephnef josephnef force-pushed the regress-rf-state-reset branch from 4e075c2 to 0888d67 Compare June 3, 2026 12:15
@josephnef josephnef merged commit dfe5c95 into master Jun 3, 2026
5 checks passed
@josephnef josephnef deleted the regress-rf-state-reset branch June 3, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant