From f24147f9d9d53caefb06afcd92610430c1ccec7a Mon Sep 17 00:00:00 2001 From: Daniel Kampert Date: Wed, 24 Jul 2024 08:00:09 +0200 Subject: [PATCH] Move J-Link serial number and build directory to config Add ZSWatch HW revision as variable --- app/pytest/pytest.ini | 3 +++ app/pytest/requirements.txt | 5 ++--- app/pytest/utils.py | 16 +++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/pytest/pytest.ini b/app/pytest/pytest.ini index e610b3c2..ae7d0a2d 100644 --- a/app/pytest/pytest.ini +++ b/app/pytest/pytest.ini @@ -1,3 +1,6 @@ [pytest] log_cli = True log_cli_level = INFO +env = + JLINK_SERIAL=760208506 + ZSWATCH_REVISION=5 diff --git a/app/pytest/requirements.txt b/app/pytest/requirements.txt index be1bcea3..7cd53262 100644 --- a/app/pytest/requirements.txt +++ b/app/pytest/requirements.txt @@ -18,8 +18,7 @@ psutil # Artifacts package creation bz -# used for CAN <=> host testing -python-can>=4.3.0 - # RTT connection pylink-square + +pytest-env \ No newline at end of file diff --git a/app/pytest/utils.py b/app/pytest/utils.py index 5478ef85..7fa06c8d 100644 --- a/app/pytest/utils.py +++ b/app/pytest/utils.py @@ -1,10 +1,9 @@ +import os import subprocess import logging import time import pylink -SERIAL_NUMBER = "760208490" - log = logging.getLogger() @@ -22,7 +21,7 @@ def reset(): "--family", "nrf53", "--snr", - SERIAL_NUMBER, + os.environ["JLINK_SERIAL"], "--reset", ], shell=False, @@ -33,6 +32,9 @@ def reset(): def flash(): + log.info("Using J-Link {}".format(os.environ["JLINK_SERIAL"])) + log.info("Using ZSWatch revision {}".format(os.environ["ZSWATCH_REVISION"])) + """Flash firmware""" log.info("Flashing CP_APPLICATION.") subprocess.run( @@ -41,9 +43,9 @@ def flash(): "--family", "nrf53", "--snr", - SERIAL_NUMBER, + os.environ["JLINK_SERIAL"], "--program", - "./zswatch_nrf5340_cpuapp@3_debug.hex", + "./zswatch_nrf5340_cpuapp@{}_debug.hex".format(os.environ["ZSWATCH_REVISION"]), "--chiperase", "--verify", ], @@ -60,7 +62,7 @@ def flash(): "--family", "nrf53", "--snr", - SERIAL_NUMBER, + os.environ["JLINK_SERIAL"], "--program", "./zswatch_nrf5340_CPUNET.hex", "--coprocessor", @@ -81,7 +83,7 @@ def read_rtt(target_device="nRF5340_XXAA", timeout_ms=10000): jlink = pylink.JLink() logging.getLogger("pylink.jlink").setLevel(logging.WARNING) log.info("Connecting to JLink...") - jlink.open(serial_no=SERIAL_NUMBER) + jlink.open(serial_no=os.environ["JLINK_SERIAL"]) log.info("Connecting to %s..." % target_device) jlink.set_tif(pylink.enums.JLinkInterfaces.SWD) jlink.connect(target_device)