Skip to content

Commit

Permalink
tests: on_target: use dfu instead of segger
Browse files Browse the repository at this point in the history
Use dfu default flashing for all tests, instead of segger on 53.

Signed-off-by: Giacomo Dematteis <[email protected]>
  • Loading branch information
DematteisGiacomo committed Nov 11, 2024
1 parent 8bd2f8d commit 3930367
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/on_target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
--junit-xml=results/test-results-uart.xml \
tests
env:
SEGGER: ${{ secrets.SEGGER_DUT_1 }}
T91X_SERIAL_NUMBER: ${{ secrets.SEGGER_DUT_1 }}
LOG_FILENAME: oob_uart_test_log

- name: Run FOTA tests (standard)
Expand All @@ -129,9 +129,9 @@ jobs:
--junit-xml=results/test-results-fota.xml \
tests
env:
SEGGER: ${{ secrets.SEGGER_DUT_1 }}
IMEI: ${{ secrets.IMEI_DUT_1 }}
FINGERPRINT: ${{ secrets.FINGERPRINT_DUT_1 }}
T91X_SERIAL_NUMBER: ${{ secrets.NRFUTIL_ID_DUT_1 }}
T91X_IMEI: ${{ secrets.IMEI_DUT_1 }}
T91X_FINGERPRINT: ${{ secrets.FINGERPRINT_DUT_1 }}
LOG_FILENAME: oob_fota_test_log

- name: Run FOTA tests (FULLMFW)
Expand All @@ -142,9 +142,9 @@ jobs:
--junit-xml=results/test-results-fullmfw-fota.xml \
tests
env:
SEGGER: ${{ secrets.SEGGER_DUT_1 }}
IMEI: ${{ secrets.IMEI_DUT_1 }}
FINGERPRINT: ${{ secrets.FINGERPRINT_DUT_1 }}
T91X_SERIAL_NUMBER: ${{ secrets.NRFUTIL_ID_DUT_1 }}
T91X_IMEI: ${{ secrets.IMEI_DUT_1 }}
T91X_FINGERPRINT: ${{ secrets.FINGERPRINT_DUT_1 }}
LOG_FILENAME: oob_fullmfw_fota_test_log

- name: Run DFU tests
Expand Down
8 changes: 4 additions & 4 deletions tests/on_target/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ nrfutil device list
Precondition: thingy91x with segger fw on 53

```shell
export SEGGER=<your_segger>
export T91X_SERIAL_NUMBER=<your_t91x_serial_number>
pytest -s -v -m "dut1 and uart" tests
```

Expand All @@ -51,9 +51,9 @@ pytest -s -v -m "dut1 and uart" tests
Precondition: thingy91x with segger fw on 53

```shell
export SEGGER=<your_segger>
export IMEI=<your_imei>
export FINGERPRINT=<your_fingerprint>
export T91X_SERIAL_NUMBER=<your_t91x_serial_number>
export T91X_IMEI=<your_t91x_imei>
export T91X_FINGERPRINT=<your_t91x_fingerprint>
pytest -s -v -m "dut1 and fota" tests
```

Expand Down
20 changes: 11 additions & 9 deletions tests/on_target/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

UART_TIMEOUT = 60 * 30

SEGGER = os.getenv('SEGGER')
UART_ID = os.getenv('UART_ID', SEGGER)
FOTADEVICE_IMEI = os.getenv('IMEI')
FOTADEVICE_FINGERPRINT = os.getenv('FINGERPRINT')
T91X_SERIAL_NUMBER = os.getenv('T91X_SERIAL_NUMBER')
T91X_IMEI = os.getenv('T91X_IMEI')
T91X_FINGERPRINT = os.getenv('T91X_FINGERPRINT')

def get_uarts():
base_path = "/dev/serial/by-id"
Expand All @@ -34,7 +33,7 @@ def get_uarts():
uarts = []

for path in sorted(serial_paths):
if UART_ID in path:
if T91X_SERIAL_NUMBER in path:
uarts.append(path)
else:
continue
Expand All @@ -60,17 +59,20 @@ def t91x_board():
pytest.fail("No UARTs found")
log_uart_string = all_uarts[0]


serial_number = T91X_SERIAL_NUMBER
uart = Uart(log_uart_string, timeout=UART_TIMEOUT)
fota = HelloNrfCloudFOTA(device_id=f"oob-{FOTADEVICE_IMEI}", \
fingerprint=FOTADEVICE_FINGERPRINT)
fota = HelloNrfCloudFOTA(device_id=f"oob-{T91X_IMEI}", \
fingerprint=T91X_FINGERPRINT)

yield types.SimpleNamespace(
uart=uart,
serial_number=serial_number,
uart=uart,
fota=fota
)

# Cancel pending fota jobs, at fota test teardown
if FOTADEVICE_IMEI:
if T91X_IMEI:
try:
pending_jobs = fota.check_pending_jobs()
if pending_jobs:
Expand Down
15 changes: 7 additions & 8 deletions tests/on_target/tests/test_fota.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def run_fota_resumption(t91x_board, fota_type):
@pytest.fixture
def run_fota_fixture(t91x_board, hex_file):
def _run_fota(bundleId, fota_type, fotatimeout=APP_FOTA_TIMEOUT, test_fota_resumption=False):
flash_device(os.path.abspath(hex_file))
flash_device(serial=t91x_board.serial_number, hexfile=os.path.abspath(hex_file))
time.sleep(10)
t91x_board.uart.xfactoryreset()
t91x_board.uart.flush()
reset_device()
reset_device(serial=t91x_board.serial_number)
t91x_board.uart.wait_for_str("Connected to Cloud")

job_id = post_job(t91x_board, bundleId, fota_type)
Expand All @@ -78,7 +78,7 @@ def _run_fota(bundleId, fota_type, fotatimeout=APP_FOTA_TIMEOUT, test_fota_resum

@pytest.mark.dut1
@pytest.mark.fota
def test_app_fota(t91x_board, hex_file, run_fota_fixture):
def test_app_fota(t91x_board, run_fota_fixture):
# Get latest APP fota bundle
results = t91x_board.fota.get_fota_bundles()
if not results:
Expand All @@ -97,18 +97,17 @@ def test_app_fota(t91x_board, hex_file, run_fota_fixture):

@pytest.mark.dut1
@pytest.mark.fota
def test_delta_mfw_fota(t91x_board, hex_file, run_fota_fixture):
def test_delta_mfw_fota(t91x_board, run_fota_fixture):
# Flash with mfw201
flash_device(os.path.abspath(MFW_201_FILEPATH))
flash_device(serial=t91x_board.serial_number, hexfile=os.path.abspath(MFW_201_FILEPATH))

# run_fota(DELTA_MFW_BUNDLEID, hex_file)
run_fota_fixture(DELTA_MFW_BUNDLEID, "delta")

# Restore mfw201
flash_device(os.path.abspath(MFW_201_FILEPATH))
flash_device(serial=t91x_board.serial_number, hexfile=os.path.abspath(MFW_201_FILEPATH))


@pytest.mark.dut1
@pytest.mark.fullmfw_fota
def test_full_mfw_fota(t91x_board, hex_file, run_fota_fixture):
def test_full_mfw_fota(run_fota_fixture):
run_fota_fixture(FULL_MFW_BUNDLEID, "full", FULL_MFW_FOTA_TIMEOUT)
4 changes: 2 additions & 2 deletions tests/on_target/tests/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_gnss_location(t91x_board, hex_file):
run_location(t91x_board, hex_file, location_method="GNSS")

def run_location(t91x_board, hex_file, location_method):
flash_device(os.path.abspath(hex_file))
flash_device(serial=t91x_board.serial_number, hexfile=os.path.abspath(hex_file))
time.sleep(5)
t91x_board.uart.xfactoryreset()
patterns_cloud_connection = [
Expand All @@ -39,7 +39,7 @@ def run_location(t91x_board, hex_file, location_method):

# Cloud connection
t91x_board.uart.flush()
reset_device()
reset_device(serial=t91x_board.serial_number)
t91x_board.uart.wait_for_str(patterns_cloud_connection, timeout=60)

# Location
Expand Down
4 changes: 2 additions & 2 deletions tests/on_target/tests/test_uart_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@pytest.mark.dut1
@pytest.mark.uart
def test_uart_output(t91x_board, hex_file):
flash_device(os.path.abspath(hex_file))
flash_device(serial=t91x_board.serial_number, hexfile=os.path.abspath(hex_file))
time.sleep(5)
t91x_board.uart.xfactoryreset()
patterns_boot = [
Expand All @@ -42,7 +42,7 @@ def test_uart_output(t91x_board, hex_file):

# Boot
t91x_board.uart.flush()
reset_device()
reset_device(serial=t91x_board.serial_number)
t91x_board.uart.wait_for_str(patterns_boot, timeout=120)

# Button press
Expand Down
9 changes: 4 additions & 5 deletions tests/on_target/utils/flash_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@

logger = get_logger()

SEGGER = os.getenv('SEGGER')

def reset_device(serial=SEGGER, reset_kind="RESET_SYSTEM"):
def reset_device(serial=None, reset_kind="RESET_SYSTEM"):
logger.info(f"Resetting device, segger: {serial}")
try:
result = subprocess.run(
Expand All @@ -31,7 +30,7 @@ def reset_device(serial=SEGGER, reset_kind="RESET_SYSTEM"):
logger.info(e.stderr)
raise

def flash_device(hexfile, serial=SEGGER, extra_args=[]):
def flash_device(serial=None, hexfile=None, extra_args=[]):
# hexfile (str): Full path to file (hex or zip) to be programmed
logger.info(f"Flashing device, segger: {serial}, firmware: {hexfile}")
try:
Expand All @@ -46,7 +45,7 @@ def flash_device(hexfile, serial=SEGGER, extra_args=[]):

reset_device(serial)

def recover_device(serial=SEGGER, core="Application"):
def recover_device(serial=None, core="Application"):
logger.info(f"Recovering device, segger: {serial}")
try:
result = subprocess.run(['nrfutil', 'device', 'recover', '--serial-number', serial, '--core', core], check=True, text=True, capture_output=True)
Expand All @@ -58,7 +57,7 @@ def recover_device(serial=SEGGER, core="Application"):
logger.info(e.stderr)
raise

def dfu_device(zipfile, serial=None, reset_only=False, check_53_version=False, bootloader_slot=1):
def dfu_device(serial=None, zipfile=None, reset_only=False, check_53_version=False, bootloader_slot=1):
chip, is_mcuboot = detect_family_from_zip(zipfile)
if chip is None:
logger.error("Could not determine chip family from image")
Expand Down

0 comments on commit 3930367

Please sign in to comment.