Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add nrf9151dk #109

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,33 +93,47 @@ jobs:
fi

# Asset Tracker Template firmware build

- name: Build nrf91 firmware
- name: Build thingy91x firmware
working-directory: asset-tracker-template/app
run: |
mkdir -p artifacts
cp overlay-memfault.conf overlay-memfault-att.conf
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why we are copying memfault overlay, I think this can be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to leave the original pristine I think. In case we decide to do something else with it later. Eg build some config with different memfault token / slug / org etc.

echo "CONFIG_MEMFAULT_NCS_PROJECT_KEY=\"${{ secrets.MEMFAULT_PROJECT_KEY }}\"" >> overlay-memfault-att.conf
echo CONFIG_MEMFAULT_NCS_FW_VERSION_STATIC=y >> overlay-memfault-att.conf
echo CONFIG_MEMFAULT_NCS_FW_VERSION=\"${{ env.VERSION }}\" >> overlay-memfault-att.conf
echo CONFIG_MEMFAULT_NCS_FW_TYPE=\"${{ env.MEMFAULT_SW_TYPE }}\" >> overlay-memfault-att.conf
west build -b thingy91x/nrf9151/ns -p --sysbuild -- -DEXTRA_CONF_FILE="overlay-memfault-att.conf"

- name: Rename artifacts
working-directory: asset-tracker-template/app/build
run: |
cp merged.hex asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91.hex
cp app/zephyr/.config asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91.config
cp app/zephyr/zephyr.signed.bin asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91-update-signed.bin
cp app/zephyr/zephyr.signed.hex asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91-update-signed.hex
cp app/zephyr/zephyr.elf asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91.elf
cp dfu_application.zip asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91-dfu.zip
west build -b thingy91x/nrf9151/ns -d build -p --sysbuild -- -DEXTRA_CONF_FILE="overlay-memfault-att.conf"
cp build/merged.hex artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91.hex
cp build/app/zephyr/.config artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91.config
cp build/app/zephyr/zephyr.signed.bin artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91-update-signed.bin
cp build/app/zephyr/zephyr.signed.hex artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91-update-signed.hex
cp build/app/zephyr/zephyr.elf artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91.elf
cp build/dfu_application.zip artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91-dfu.zip
cd build
ninja partition_manager_report
ninja partition_manager_report > ../artifacts/pmr-thingy91x-nrf91-default-${{ env.VERSION }}.txt
sed -i '1d' ../artifacts/pmr-thingy91x-nrf91-default-${{ env.VERSION }}.txt

- name: Create partition manager report for nRF91 firmware
working-directory: asset-tracker-template/app/build
- name: Build nrf9151dk firmware
working-directory: asset-tracker-template/app
run: |
mkdir -p artifacts
cp overlay-memfault.conf overlay-memfault-att.conf
echo "CONFIG_MEMFAULT_NCS_PROJECT_KEY=\"${{ secrets.MEMFAULT_PROJECT_KEY }}\"" >> overlay-memfault-att.conf
echo CONFIG_MEMFAULT_NCS_FW_VERSION_STATIC=y >> overlay-memfault-att.conf
echo CONFIG_MEMFAULT_NCS_FW_VERSION=\"${{ env.VERSION }}\" >> overlay-memfault-att.conf
echo CONFIG_MEMFAULT_NCS_FW_TYPE=\"${{ env.MEMFAULT_SW_TYPE }}\" >> overlay-memfault-att.conf
west build -b nrf9151dk/nrf9151/ns -d build -p --sysbuild -- -DEXTRA_CONF_FILE="overlay-memfault-att.conf"
cp build/merged.hex artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91.hex
cp build/app/zephyr/.config artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91.config
cp build/app/zephyr/zephyr.signed.bin artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91-update-signed.bin
cp build/app/zephyr/zephyr.signed.hex artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91-update-signed.hex
cp build/app/zephyr/zephyr.elf artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91.elf
cp build/dfu_application.zip artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91-dfu.zip
cd build
ninja partition_manager_report
ninja partition_manager_report > pmr-nrf91-default-${{ env.VERSION }}.txt
sed -i '1d' pmr-nrf91-default-${{ env.VERSION }}.txt
ninja partition_manager_report > ../artifacts/pmr-nrf9151dk-nrf91-default-${{ env.VERSION }}.txt
sed -i '1d' ../artifacts/pmr-nrf9151dk-nrf91-default-${{ env.VERSION }}.txt

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand All @@ -128,11 +142,10 @@ jobs:
name: firmware-att
if-no-files-found: error
path: |
asset-tracker-template/app/build/asset-tracker-template-*.*
asset-tracker-template/app/artifacts/*

# Asset Tracker Template debug firmware build

- name: Build nrf91 debug firmware
- name: Build thingy91x debug firmware
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also build nrf9151dk debug firmware? I dont know really

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but we can add later if needed.

if: ${{ inputs.build_debug }}
working-directory: asset-tracker-template/app
run: |
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/target-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ jobs:
target_test:
# This will create multiple jobs, one for each target defined in the matrix
strategy:
fail-fast: false # Don't fail all jobs if one fails
fail-fast: false # Don't fail all jobs if one fails
matrix:
include:
- device: cia-trd-thingy91x
- device: nrf9151dk
- device: thingy91x

# Self-hosted runner is labeled according to the device it is linked with
runs-on: ${{ matrix.device }}
runs-on: cia-trd-${{ matrix.device }}
environment: ${{ matrix.device }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of environment: ${{ matrix.device }}?

name: Target Test - ${{ matrix.device }}

permissions:
Expand Down Expand Up @@ -94,6 +96,7 @@ jobs:
pip install -r requirements.txt --break-system-packages

- name: Upload symbol file to Memfault
if: ${{ matrix.device != 'ppk_thingy91x' }}
working-directory: asset-tracker-template/tests/on_target/artifacts
run: |
memfault \
Expand All @@ -103,7 +106,7 @@ jobs:
upload-mcu-symbols \
--software-type asset-tracker-template-ci \
--software-version ${{ inputs.artifact_fw_version }} \
asset-tracker-template-${{ inputs.artifact_fw_version }}-thingy91x-nrf91.elf
asset-tracker-template-${{ inputs.artifact_fw_version }}-${{ matrix.device }}-nrf91.elf

- name: Target Tests
working-directory: asset-tracker-template/tests/on_target
Expand Down Expand Up @@ -133,6 +136,7 @@ jobs:
shell: bash
env:
SEGGER: ${{ env.RUNNER_SERIAL_NUMBER }}
DUT_DEVICE_TYPE: ${{ matrix.device }}
UUID: ${{ env.UUID }}
NRFCLOUD_API_KEY: ${{ secrets.NRF_CLOUD_API_KEY }}
LOG_FILENAME: att_test_log
Expand Down
Binary file not shown.
23 changes: 13 additions & 10 deletions tests/on_target/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
UART_ID = os.getenv('UART_ID', SEGGER)
FOTADEVICE_UUID = os.getenv('UUID')
NRFCLOUD_API_KEY = os.getenv('NRFCLOUD_API_KEY')
DUT_DEVICE_TYPE = os.getenv('DUT_DEVICE_TYPE')

def get_uarts():
base_path = "/dev/serial/by-id"
Expand Down Expand Up @@ -54,14 +55,17 @@ def pytest_runtest_logfinish(nodeid, location):
logger.info(f"Finished test: {nodeid}")

@pytest.fixture(scope="function")
def t91x_board():
def dut_board():
all_uarts = get_uarts()
if not all_uarts:
pytest.fail("No UARTs found")
log_uart_string = all_uarts[0]
uart = Uart(log_uart_string, timeout=UART_TIMEOUT)

yield types.SimpleNamespace(uart=uart)
yield types.SimpleNamespace(
uart=uart,
device_type=DUT_DEVICE_TYPE
)

uart_log = uart.whole_log
uart.stop()
Expand All @@ -70,7 +74,7 @@ def t91x_board():
scan_log_for_assertions(uart_log)

@pytest.fixture(scope="function")
def t91x_fota(t91x_board):
def dut_fota(dut_board):
if not NRFCLOUD_API_KEY:
pytest.skip("NRFCLOUD_API_KEY environment variable not set")
if not FOTADEVICE_UUID:
Expand All @@ -85,35 +89,34 @@ def t91x_fota(t91x_board):
fota.cancel_incomplete_jobs(device_id)

yield types.SimpleNamespace(
**dut_board.__dict__,
fota=fota,
uart=t91x_board.uart,
device_id=device_id,
data=data
)

fota.cancel_incomplete_jobs(device_id)
if data['bundle_id']:
fota.delete_bundle(data['bundle_id'])


@pytest.fixture(scope="module")
def t91x_traces(t91x_board):
def dut_traces(dut_board):
all_uarts = get_uarts()
trace_uart_string = all_uarts[1]
uart_trace = UartBinary(trace_uart_string)

yield types.SimpleNamespace(
**dut_board.__dict__,
trace=uart_trace,
uart=t91x_board.uart
)

uart_trace.stop()

@pytest.fixture(scope="session")
def hex_file():
# Search for the firmware hex file in the artifacts folder
artifacts_dir = "artifacts"
hex_pattern = r"asset-tracker-template-[0-9a-z\.]+-thingy91x-nrf91\.hex"
artifacts_dir = "artifacts/"
hex_pattern = f"asset-tracker-template-{r"[0-9a-z\.]+"}-{DUT_DEVICE_TYPE}-nrf91.hex"

for file in os.listdir(artifacts_dir):
if re.match(hex_pattern, file):
Expand All @@ -125,7 +128,7 @@ def hex_file():
def bin_file():
# Search for the firmware bin file in the artifacts folder
artifacts_dir = "artifacts"
hex_pattern = r"asset-tracker-template-[0-9a-z\.]+-thingy91x-nrf91-update-signed\.bin"
hex_pattern = f"asset-tracker-template-{r"[0-9a-z\.]+"}-{DUT_DEVICE_TYPE}-nrf91-update-signed.hex"

for file in os.listdir(artifacts_dir):
if re.match(hex_pattern, file):
Expand Down
Loading
Loading