|
18 | 18 |
|
19 | 19 | import os |
20 | 20 | import shutil |
| 21 | +import time |
21 | 22 | from pathlib import Path |
22 | 23 |
|
23 | 24 | import pytest |
|
35 | 36 | from test.hw.hw_helpers import ( # noqa: E402 |
36 | 37 | DEFAULT_OUT_DIR, |
37 | 38 | acquire_xsa, |
| 39 | + assert_jesd_links_data, |
38 | 40 | assert_no_kernel_faults, |
39 | 41 | assert_no_probe_errors, |
| 42 | + assert_rx_capture_valid, |
40 | 43 | collect_dmesg, |
41 | 44 | compile_dts_to_dtb, |
42 | 45 | deploy_and_boot, |
43 | 46 | open_iio_context, |
| 47 | + shell_out, |
44 | 48 | ) |
45 | 49 |
|
46 | 50 |
|
@@ -152,33 +156,49 @@ def test_adrv9371_zc706_xsa_hw(board, built_kernel_image_zynq, tmp_path): |
152 | 156 | f"No AD9528 clock device found. Devices: {sorted(found)}" |
153 | 157 | ) |
154 | 158 |
|
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 | + ) |
182 | 202 |
|
183 | 203 |
|
184 | 204 | # --------------------------------------------------------------------------- |
|
0 commit comments