This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
Test nrf52840dk #1372
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
name: Test nrf52840dk | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
schedule: | |
# Run workflow at the start of every day (12 AM UTC) | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
jobs: | |
build_for_hw_test: | |
runs-on: ubuntu-latest | |
container: | |
image: zephyrprojectrtos/ci:v0.26.5 | |
env: | |
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-0.16.3 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: modules/lib/golioth | |
- name: Init and update west | |
run: | | |
mkdir -p .west | |
cat <<EOF > .west/config | |
[manifest] | |
path = modules/lib/golioth | |
file = .ci-west-zephyr.yml | |
EOF | |
west update -o=--depth=1 -n | |
git config --global user.email user@git-scm.com | |
git config --global user.name "Git User" | |
west patch | |
- name: Build samples/test | |
run: | | |
cd modules/lib/golioth/samples/test | |
west build -b nrf52840dk_nrf52840 . -p | |
- name: Create build tarball | |
run: | | |
cd modules/lib/golioth/samples/test | |
tar czf build.tar.gz build/zephyr/zephyr.hex | |
- name: Upload tarball | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build.tar.gz | |
path: modules/lib/golioth/samples/test/build.tar.gz | |
# Assumptions made about the self-hosted runner: | |
# | |
# 1. Has installed the GitHub Actions self-hosted runner service | |
# 2. Has nrfjprog already installed | |
# 3. Has an environment variable defined for the serial port: CI_NRF52840DK_PORT | |
# 4. Has credentials defined in the file $HOME/credentials_nrf52840dk.yml | |
# 5. Has an environment variabled defined for the JTAG serial number of the nRF52. | |
# | |
# It is the responsibility of the self-hosted runner admin to ensure | |
# these pre-conditions are met. | |
# | |
# For item 1, GitHub provides instructions when you add a new self-hosted runner | |
# in Settings -> Actions -> Runners. | |
# | |
# For item 2, you'll need to install jlink and nrf-command-line-tools: | |
# https://www.segger.com/downloads/jlink/ | |
# https://www.nordicsemi.com/Products/Development-tools/nrf-command-line-tools/download | |
# | |
# For item 3, this environment variable can be added to $HOME/runner_env.sh: | |
# export CI_NRF52840DK_PORT=/dev/ttyACM0 | |
# | |
# For item 4, the file needs to have contents like: | |
# | |
# settings: | |
# wifi/ssid: mywifissid | |
# wifi/psk: mywifipassword | |
# golioth/psk-id: device@project | |
# golioth/psk: supersecret | |
# | |
# The golioth credentials need to match a device on coap.golioth.dev | |
# | |
# For item 5, you can discover the serial number of the nRF52 using this command: | |
# nrfjprog --ids | |
# Once you know the serial number, you can add this to $HOME/runner_env.sh: | |
# export CI_NRF52840DK_SNR=723769314 | |
hw_flash_and_test: | |
needs: build_for_hw_test | |
runs-on: [is_active, has_nrf52840dk] | |
defaults: | |
run: | |
working-directory: connection_tests | |
container: | |
image: golioth/golioth-twister-base:8307b9c | |
env: | |
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-0.16.3 | |
volumes: | |
- /dev:/dev | |
- /home/golioth/credentials:/opt/credentials | |
options: --privileged | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
path: connection_tests | |
- name: Power On USB Hub | |
run: python3 /opt/golioth-scripts/usb_hub_power.py on | |
- name: Download build tarball | |
uses: actions/download-artifact@v3 | |
with: | |
name: build.tar.gz | |
path: connection_tests/samples/test | |
- name: Untar | |
run: | | |
cd samples/test | |
tar xvf build.tar.gz | |
- name: Copy credentials to samples/test | |
run: | | |
cp /opt/credentials/credentials_nrf52840dk.yml samples/test/credentials.yml | |
- name: Flash and Verify Test Results | |
shell: bash | |
run: | | |
cd samples/test | |
source /opt/credentials/runner_env.sh | |
nrfjprog --recover -f NRF52 --snr $CI_NRF52840DK_SNR | |
nrfjprog --program build/zephyr/zephyr.hex --sectoranduicrerase --verify -f NRF52 --snr $CI_NRF52840DK_SNR | |
nrfjprog --pinresetenable -f NRF52 --snr $CI_NRF52840DK_SNR | |
nrfjprog --pinreset -f NRF52 --snr $CI_NRF52840DK_SNR | |
sleep 3 | |
python3 verify.py $CI_NRF52840DK_PORT | |
- name: Erase flash | |
if: always() | |
shell: bash | |
run: | | |
source /opt/credentials/runner_env.sh | |
nrfjprog --recover --snr ${CI_NRF52840DK_SNR} | |
- name: Power Off USB Hub | |
if: always() | |
run: python3 /opt/golioth-scripts/usb_hub_power.py off |