Skip to content

Commit

Permalink
Move J-Link serial number to command line arguments
Browse files Browse the repository at this point in the history
Add ZSWatch HW revision as variable
  • Loading branch information
Kampi committed Jul 24, 2024
1 parent d540a61 commit d2a1b1a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ jobs:
- /dev/bus/usb/:/dev/bus/usb
options: --privileged

strategy:
matrix:
hardware_revisions: [3, 4]
jlink_devices: [760208506]
runner: []

steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -37,15 +43,15 @@ jobs:
python -m pip install --upgrade pip
pip install -r app/pytest/requirements.txt
- name: 'Download image'
- name: Download debug image
uses: actions/download-artifact@v4
with:
name: zswatch_nrf5340_cpuapp@3_debug
name: zswatch_nrf5340_cpuapp@${{ matrix.hardware_revisions }}_debug

- name: Display structure of downloaded files
run: ls

- name: Test with pytest
run: |
pip install pytest
pytest app/pytest/
pytest JLINK_SERIAL=${{ matrix.jlink_devices }} ZSWATCH_REVISION=${{ matrix.hardware_revisions }} app/pytest/
5 changes: 1 addition & 4 deletions app/pytest/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@ psutil
# Artifacts package creation
bz

# used for CAN <=> host testing
python-can>=4.3.0

# RTT connection
pylink-square
pylink-square
23 changes: 16 additions & 7 deletions app/pytest/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import os
import subprocess
import logging
import time
import pylink

SERIAL_NUMBER = "760208490"

log = logging.getLogger()


Expand All @@ -14,6 +13,8 @@ def current_milli_time():


def reset():
JLink_ID = os.environ["JLINK_SERIAL"]

"""Reset DUT"""
log.info("Reset DUT")
subprocess.run(
Expand All @@ -22,7 +23,7 @@ def reset():
"--family",
"nrf53",
"--snr",
SERIAL_NUMBER,
JLink_ID,
"--reset",
],
shell=False,
Expand All @@ -33,6 +34,12 @@ def reset():


def flash():
HW_Revision = os.environ["ZSWATCH_REVISION"]
JLink_ID = os.environ["JLINK_SERIAL"]

log.info("Using J-Link {}".format(JLink_ID))
log.info("Using ZSWatch revision {}".format(HW_Revision))

"""Flash firmware"""
log.info("Flashing CP_APPLICATION.")
subprocess.run(
Expand All @@ -41,9 +48,9 @@ def flash():
"--family",
"nrf53",
"--snr",
SERIAL_NUMBER,
JLink_ID,
"--program",
"./zswatch_nrf5340_cpuapp@3_debug.hex",
"./zswatch_nrf5340_cpuapp@{}_debug.hex".format(HW_Revision),
"--chiperase",
"--verify",
],
Expand All @@ -60,7 +67,7 @@ def flash():
"--family",
"nrf53",
"--snr",
SERIAL_NUMBER,
JLink_ID,
"--program",
"./zswatch_nrf5340_CPUNET.hex",
"--coprocessor",
Expand All @@ -77,11 +84,13 @@ def flash():


def read_rtt(target_device="nRF5340_XXAA", timeout_ms=10000):
JLink_ID = os.environ["JLINK_SERIAL"]

"""Read Segger RTT output"""
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=JLink_ID)
log.info("Connecting to %s..." % target_device)
jlink.set_tif(pylink.enums.JLinkInterfaces.SWD)
jlink.connect(target_device)
Expand Down

0 comments on commit d2a1b1a

Please sign in to comment.