-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Debug app: cache the latest connection parameters.
Fixes showing wrong connection parameters after re-opening the app.
- Loading branch information
Showing
9 changed files
with
238 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/build.yml | ||
|
||
test: | ||
needs: [build] | ||
uses: ./.github/workflows/test.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
on: [workflow_call] | ||
|
||
jobs: | ||
test: | ||
runs-on: self-hosted | ||
container: | ||
image: ghcr.io/zephyrproject-rtos/zephyr-build:v0.26.2 | ||
volumes: | ||
- /dev/bus/usb/:/dev/bus/usb | ||
options: --privileged | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
continue-on-error: true # JLink install will fail | ||
run: | | ||
if [ ! -f "`which JLinkExe`" ]; then | ||
echo "Installing JLink tools..." | ||
wget -q --post-data 'accept_license_agreement=accepted&non_emb_ctr=confirmed&submit=Download+software' https://www.segger.com/downloads/jlink/JLink_Linux_V796t_x86_64.deb | ||
sudo apt -qq update | ||
sudo apt -y install ./JLink_Linux_V796t_x86_64.deb &>/dev/null | ||
fi | ||
if [ ! -f "`which nrfjprog`" ]; then | ||
echo "Installing Nordic command line tools..." | ||
wget -q https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-10-x-x/10-24-2/nrf-command-line-tools_10.24.2_amd64.deb | ||
sudo apt -y install ./nrf-command-line-tools_10.24.2_amd64.deb &>/dev/null | ||
export PATH=$PATH:/opt | ||
fi | ||
python -m pip install --upgrade pip | ||
pip install -r app/pytest/requirements.txt | ||
- name: 'Download image' | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: zswatch_nrf5340_cpuapp@3_debug | ||
|
||
- name: Display structure of downloaded files | ||
run: ls | ||
|
||
- name: Test with pytest | ||
run: | | ||
pip install pytest | ||
pytest app/pytest/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import pytest | ||
import utils | ||
import logging | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
|
||
def pytest_configure(): | ||
utils.flash() | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def reset(): | ||
utils.reset() | ||
yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
log_cli = True | ||
log_cli_level = INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# RUN-TEST: required to do run time tests of zephyr | ||
# | ||
# things used by twister or related in run time testing | ||
|
||
# used to flash & debug various boards | ||
pyocd>=0.35.0 | ||
|
||
# used by twister for board/hardware map | ||
tabulate | ||
natsort | ||
|
||
# used by mcuboot | ||
cbor>=1.0.0 | ||
|
||
# use for twister | ||
psutil | ||
|
||
# Artifacts package creation | ||
bz | ||
|
||
# used for CAN <=> host testing | ||
python-can>=4.3.0 | ||
|
||
# RTT connection | ||
pylink-square |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import time | ||
import logging | ||
import utils | ||
|
||
log = logging.getLogger() | ||
|
||
|
||
def test_flash(): | ||
"""Test flashing, don't need to assert as failing to flash throws exception""" | ||
utils.flash() | ||
|
||
|
||
def test_reset(): | ||
"""Test Reset, don't need to assert as failing to reset throws exception""" | ||
utils.reset() | ||
|
||
|
||
def test_boot(): | ||
log.info("Wait for boot") | ||
time.sleep(30) | ||
assert utils.read_rtt(timeout_ms=20000).find("Enter inactive") != -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import subprocess | ||
import logging | ||
import time | ||
import pylink | ||
|
||
SERIAL_NUMBER = "760208490" | ||
|
||
log = logging.getLogger() | ||
|
||
|
||
def current_milli_time(): | ||
"""Get times in milliseconds""" | ||
return round(time.time() * 1000) | ||
|
||
|
||
def reset(): | ||
"""Reset DUT""" | ||
log.info("Reset DUT") | ||
subprocess.run( | ||
[ | ||
"nrfjprog", | ||
"--family", | ||
"nrf53", | ||
"--snr", | ||
SERIAL_NUMBER, | ||
"--reset", | ||
], | ||
shell=False, | ||
stderr=subprocess.STDOUT, | ||
text=True, | ||
check=True, | ||
) | ||
|
||
|
||
def flash(): | ||
"""Flash firmware""" | ||
log.info("Flashing CP_APPLICATION.") | ||
subprocess.run( | ||
[ | ||
"nrfjprog", | ||
"--family", | ||
"nrf53", | ||
"--snr", | ||
SERIAL_NUMBER, | ||
"--recover", | ||
"--program", | ||
"./zswatch_nrf5340_cpuapp@3_debug.hex", | ||
"--qspichiperase", | ||
"--verify", | ||
], | ||
shell=False, | ||
stderr=subprocess.STDOUT, | ||
text=True, | ||
check=True, | ||
) | ||
|
||
log.info("Flashing CP_NETWORK.") | ||
subprocess.run( | ||
[ | ||
"nrfjprog", | ||
"--family", | ||
"nrf53", | ||
"--snr", | ||
SERIAL_NUMBER, | ||
"--reset", | ||
"--program", | ||
"./zswatch_nrf5340_CPUNET.hex", | ||
"--coprocessor", | ||
"CP_NETWORK", | ||
"--qspisectorerase", | ||
"--verify", | ||
], | ||
shell=False, | ||
stderr=subprocess.STDOUT, | ||
text=True, | ||
check=True, | ||
) | ||
|
||
|
||
def read_rtt(target_device="nRF5340_XXAA", timeout_ms=10000): | ||
"""Read Segger RTT output""" | ||
jlink = pylink.JLink() | ||
log.info("Connecting to JLink...") | ||
jlink.open(serial_no=SERIAL_NUMBER) | ||
log.info("Connecting to %s..." % target_device) | ||
jlink.set_tif(pylink.enums.JLinkInterfaces.SWD) | ||
jlink.connect(target_device) | ||
jlink.rtt_start(None) | ||
start_time = current_milli_time() | ||
read_data = "" | ||
|
||
while jlink.connected() and start_time + timeout_ms > current_milli_time(): | ||
read_bytes = jlink.rtt_read(0, 1024) | ||
|
||
if read_bytes and read_bytes != "": | ||
data = "".join(map(chr, read_bytes)) | ||
read_data = read_data + data | ||
|
||
time.sleep(0.1) | ||
|
||
jlink.close() | ||
log.debug(read_data) | ||
|
||
return read_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters