Skip to content

Commit 459b47d

Browse files
committed
test(hw, adrv9371): flip ensm_mode=radio_on + restore rx-capture check
Root-causes the AD9371 rx-capture gap: the Mykonos driver defaults the Enable State Machine to ``radio_off`` after probe, so JESD204 RX trains to ``Link status: DATA`` but the ARM's radio FSM is not delivering samples to the TPL. ``buf.refill()`` therefore times out on ``ad_ip_jesd204_tpl_adc`` even though the link looks fine. ADRV9009 (Talise) doesn't have this problem — either the default is ``radio_on`` or the post-boot profile load implicitly flips it. Mykonos needs an explicit write. Write ``radio_on`` directly to the ``ad9371-phy`` IIO device's ``ensm_mode`` attribute via the labgrid shell (same defensive pattern the adrv9009 test uses for Talise profile writes — avoids the libiio TCP socket drop during driver state changes), then re-verify JESD + dmesg stayed healthy and call ``assert_rx_capture_valid`` for real. Rules out the alternative approach of runtime ``profile_config`` writes (commits b117949 + 5222208 reverted after proving they drop JESD and never relock on Mykonos). Cross-links those commits from the new code path's docstring so the dead-end is discoverable.
1 parent 6e04485 commit 459b47d

1 file changed

Lines changed: 47 additions & 27 deletions

File tree

test/hw/test_adrv9371_zc706_hw.py

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import os
2020
import shutil
21+
import time
2122
from pathlib import Path
2223

2324
import pytest
@@ -35,12 +36,15 @@
3536
from test.hw.hw_helpers import ( # noqa: E402
3637
DEFAULT_OUT_DIR,
3738
acquire_xsa,
39+
assert_jesd_links_data,
3840
assert_no_kernel_faults,
3941
assert_no_probe_errors,
42+
assert_rx_capture_valid,
4043
collect_dmesg,
4144
compile_dts_to_dtb,
4245
deploy_and_boot,
4346
open_iio_context,
47+
shell_out,
4448
)
4549

4650

@@ -152,33 +156,49 @@ def test_adrv9371_zc706_xsa_hw(board, built_kernel_image_zynq, tmp_path):
152156
f"No AD9528 clock device found. Devices: {sorted(found)}"
153157
)
154158

155-
# TODO(adrv9371-capture): data-path smoke test is deferred on
156-
# AD9371/ZC706 until the out-of-the-box design delivers samples
157-
# from the TPL core without runtime intervention.
158-
#
159-
# Investigated and ruled out (commits b117949, 5222208 — both
160-
# reverted):
161-
#
162-
# - Mirroring the adrv9009 post-boot Talise write with a Mykonos
163-
# profile does *not* unblock DMA here. The profile file
164-
# (``ad9371_5/profile_TxBW100_ORxBW100_RxBW100.txt``, 2123 bytes,
165-
# deviceClock_kHz=122880 matching the AD9528 VCXO) is accepted
166-
# by the driver at ``/sys/.../iio:device2/profile_config`` — but
167-
# immediately after the write the JESD204 RX link leaves
168-
# ``Link status: DATA`` and does not return within a 30 s poll.
169-
# Talise re-inits and JESD-relocks on ``profile_config`` write;
170-
# Mykonos on AD9371 does not do the same JESD restart, leaving
171-
# the link down after any runtime profile change.
172-
#
173-
# - On initial boot (before any write), JESD is in DATA but
174-
# ``iio.Buffer.refill()`` on ``ad_ip_jesd204_tpl_adc`` times
175-
# out, i.e. the TPL DMA isn't streaming despite a locked link.
176-
#
177-
# The next investigation step is a board-specific capture recipe
178-
# (possibly via the Mykonos driver's ``ensm_mode`` / calibration
179-
# attributes, or via pyadi-iio's ``adi.ad9371`` helpers with
180-
# explicit RX enable) — out of scope for the data-capture-smoke
181-
# addition in this PR.
159+
# --- 7. Switch Mykonos into radio_on before data capture. ---
160+
# ad9371-phy defaults to ``ensm_mode=radio_off`` after probe on
161+
# this Kuiper design — JESD204 lane training completes (Link
162+
# status: DATA) but the ARM's radio FSM is not delivering
163+
# samples to the TPL, so ``buf.refill()`` on
164+
# ``ad_ip_jesd204_tpl_adc`` times out. Flip to ``radio_on`` via
165+
# sysfs to start sample flow. (Runtime ``profile_config`` writes
166+
# drop the JESD link on Mykonos — commits b117949 + 5222208
167+
# reverted after proving that approach doesn't work — so use the
168+
# simpler ENSM write here.)
169+
ensm_path = shell_out(
170+
shell,
171+
r"for d in /sys/bus/iio/devices/iio:device*; do "
172+
r'[ "$(cat "$d/name" 2>/dev/null)" = "ad9371-phy" ] '
173+
r'&& echo "$d/ensm_mode" && break; '
174+
r"done",
175+
).strip()
176+
assert ensm_path, "Could not locate ad9371-phy/ensm_mode sysfs node"
177+
initial_ensm = shell_out(shell, f"cat {ensm_path}").strip()
178+
print(f"initial ensm_mode ({ensm_path}): {initial_ensm!r}")
179+
180+
shell_out(shell, f"echo radio_on > {ensm_path}")
181+
time.sleep(1.0)
182+
post_ensm = shell_out(shell, f"cat {ensm_path}").strip()
183+
assert post_ensm == "radio_on", (
184+
f"ensm_mode did not stick: wanted 'radio_on', got {post_ensm!r}"
185+
)
186+
print(f"post-write ensm_mode: {post_ensm}")
187+
188+
# ENSM transition should not disturb the link — the Mykonos ARM
189+
# just starts streaming. Re-verify JESD + dmesg stayed clean.
190+
assert_jesd_links_data(shell, context="after ensm_mode=radio_on")
191+
post_ensm_dmesg = shell_out(shell, "dmesg")
192+
assert_no_kernel_faults(post_ensm_dmesg)
193+
assert_no_probe_errors(post_ensm_dmesg)
194+
195+
# --- 8. Data-path smoke test: capture a real AD9371 RX buffer. ---
196+
assert_rx_capture_valid(
197+
ctx,
198+
("axi-ad9371-rx-hpc", "axi-ad9371-rx-obs-hpc"),
199+
n_samples=2**12,
200+
context="ad9371 xsa",
201+
)
182202

183203

184204
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)