|
6 | 6 | import logging |
7 | 7 | import os |
8 | 8 | import subprocess |
9 | | - |
10 | | -import pyluwen |
11 | | -import pytest |
12 | 9 | import re |
13 | 10 | import sys |
14 | 11 | import time |
15 | | - |
16 | 12 | from pathlib import Path |
17 | | -from twister_harness import DeviceAdapter |
18 | 13 |
|
19 | | -logger = logging.getLogger(__name__) |
| 14 | +import pyluwen |
| 15 | +import pytest |
| 16 | +from twister_harness import DeviceAdapter |
20 | 17 |
|
21 | 18 | sys.path.append(str(Path(__file__).parents[3] / "scripts")) |
| 19 | +from pcie_utils import rescan_pcie |
| 20 | +import dmc_reset |
22 | 21 |
|
23 | | -from pcie_utils import rescan_pcie # noqa: E402 |
| 22 | +logger = logging.getLogger(__name__) |
24 | 23 |
|
25 | 24 | SCRIPT_DIR = Path(os.path.dirname(os.path.abspath(__file__))) |
26 | 25 |
|
@@ -186,3 +185,41 @@ def test_smi_reset(): |
186 | 185 |
|
187 | 186 | logger.info(f"'tt-smi -r' failed {fail_count}/{total_tries} times.") |
188 | 187 | assert fail_count == 0, "'tt-smi -r' failed a non-zero number of times." |
| 188 | + |
| 189 | + |
| 190 | +@pytest.mark.flash |
| 191 | +def test_dirty_reset(): |
| 192 | + """ |
| 193 | + Checks that the SMC comes up correctly after a "dirty" reset, where the |
| 194 | + DMC resets without the SMC requesting it. This is similar to the conditions |
| 195 | + that might be encountered after a NOC hang |
| 196 | + """ |
| 197 | + total_tries = 10 |
| 198 | + timeout = 60 # seconds to wait for SMC boot |
| 199 | + fail_count = 0 |
| 200 | + |
| 201 | + # Use dmc-reset script as a library to reset the DMC |
| 202 | + def args(): |
| 203 | + return None |
| 204 | + |
| 205 | + args.config = dmc_reset.DEFAULT_DMC_CFG |
| 206 | + args.debug = 0 |
| 207 | + args.openocd = dmc_reset.DEFAULT_OPENOCD |
| 208 | + args.scripts = dmc_reset.DEFAULT_SCRIPTS_DIR |
| 209 | + args.jtag_id = None |
| 210 | + args.hexfile = None |
| 211 | + for i in range(total_tries): |
| 212 | + logger.info(f"Iteration {i}:") |
| 213 | + ret = dmc_reset.reset_dmc(args) |
| 214 | + if ret != os.EX_OK: |
| 215 | + logger.warning(f"DMC reset failed on iteration {i}") |
| 216 | + fail_count += 1 |
| 217 | + continue |
| 218 | + ret = dmc_reset.wait_for_smc_boot(timeout) |
| 219 | + if ret != os.EX_OK: |
| 220 | + logger.warning(f"SMC did not boot after dirty reset on iteration {i}") |
| 221 | + fail_count += 1 |
| 222 | + continue |
| 223 | + logger.info(f"Iteration {i} of dirty reset test passed") |
| 224 | + logger.info(f"dirty reset failed {fail_count}/{total_tries} times.") |
| 225 | + assert fail_count == 0, "dirty reset failed a non-zero number of times." |
0 commit comments