|
| 1 | +# .github/workflows/build-raytac-mdbt50q-cx-40.yml |
| 2 | +name: Build Raytac MDBT50Q-CX-40 (Zephyr OpenThread + DFU ZIP) |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: {} # manual run |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + - build-raytac |
| 10 | + pull_request: |
| 11 | + branches: [ main ] |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + name: Build for raytac_mdbt50q_cx_40_dongle |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: "3.12" |
| 26 | + |
| 27 | + - name: Install host dependencies |
| 28 | + run: | |
| 29 | + sudo apt-get update |
| 30 | + sudo apt-get install -y \ |
| 31 | + ninja-build \ |
| 32 | + cmake \ |
| 33 | + gperf \ |
| 34 | + dfu-util \ |
| 35 | + device-tree-compiler \ |
| 36 | + python3-pip |
| 37 | + python -m pip install --upgrade pip |
| 38 | + pip install west nrfutil |
| 39 | +
|
| 40 | + # Create a self-contained Zephyr workspace inside this repo |
| 41 | + - name: Create Zephyr west manifest (pins Zephyr) |
| 42 | + run: | |
| 43 | + mkdir -p raytac-zephyr-workspace |
| 44 | + cat > raytac-zephyr-workspace/west.yml <<'YML' |
| 45 | + manifest: |
| 46 | + remotes: |
| 47 | + - name: zephyrproject-rtos |
| 48 | + url-base: https://github.com/zephyrproject-rtos |
| 49 | + projects: |
| 50 | + - name: zephyr |
| 51 | + remote: zephyrproject-rtos |
| 52 | + revision: v4.2.0 |
| 53 | + import: true |
| 54 | + self: |
| 55 | + path: raytac-zephyr-workspace |
| 56 | + YML |
| 57 | +
|
| 58 | + # This action initializes west, fetches Zephyr + modules (including OpenThread), |
| 59 | + # installs Python requirements, and installs Zephyr SDK toolchain. |
| 60 | + - name: Setup Zephyr workspace + SDK |
| 61 | + uses: zephyrproject-rtos/action-zephyr-setup@v1 |
| 62 | + with: |
| 63 | + app-path: raytac-zephyr-workspace |
| 64 | + toolchains: arm-zephyr-eabi |
| 65 | + |
| 66 | + - name: Show tool versions (debug) |
| 67 | + working-directory: raytac-zephyr-workspace |
| 68 | + run: | |
| 69 | + west --version |
| 70 | + cmake --version |
| 71 | + ninja --version |
| 72 | + arm-zephyr-eabi-gcc --version | head -n 1 |
| 73 | + nrfutil --version || true |
| 74 | +
|
| 75 | + # ----------------------------------------------------------------------- |
| 76 | + # Build 1: "UART CLI" (OpenThread shell sample; default console is UART) |
| 77 | + # ----------------------------------------------------------------------- |
| 78 | + - name: Build Raytac OpenThread UART CLI (shell sample) |
| 79 | + working-directory: raytac-zephyr-workspace |
| 80 | + run: | |
| 81 | + set -euo pipefail |
| 82 | + BOARD="raytac_mdbt50q_cx_40_dongle/nrf52840" |
| 83 | + APP="zephyr/samples/net/openthread/shell" |
| 84 | + west build -b "$BOARD" -d build/ot-shell-uart "$APP" |
| 85 | +
|
| 86 | + # ----------------------------------------------------------------------- |
| 87 | + # Build 2: "USB CLI" (shell sample with USB CDC ACM console snippet) |
| 88 | + # ----------------------------------------------------------------------- |
| 89 | + - name: Build Raytac OpenThread USB CLI (shell sample + cdc-acm-console) |
| 90 | + working-directory: raytac-zephyr-workspace |
| 91 | + run: | |
| 92 | + set -euo pipefail |
| 93 | + BOARD="raytac_mdbt50q_cx_40_dongle/nrf52840" |
| 94 | + APP="zephyr/samples/net/openthread/shell" |
| 95 | + west build -b "$BOARD" -d build/ot-shell-usb -S cdc-acm-console "$APP" |
| 96 | +
|
| 97 | + # ----------------------------------------------------------------------- |
| 98 | + # Build 3: "USB RCP" (OpenThread coprocessor sample in RCP mode + USB CDC) |
| 99 | + # |
| 100 | + # Notes: |
| 101 | + # - The coprocessor sample ships overlay files for USB and for RCP mode. |
| 102 | + # - We reference them via absolute paths from the workspace to avoid cwd issues. |
| 103 | + # ----------------------------------------------------------------------- |
| 104 | + - name: Build Raytac OpenThread USB RCP (coprocessor, RCP, USB CDC) |
| 105 | + working-directory: raytac-zephyr-workspace |
| 106 | + run: | |
| 107 | + set -euo pipefail |
| 108 | + BOARD="raytac_mdbt50q_cx_40_dongle/nrf52840" |
| 109 | + APP_DIR="zephyr/samples/net/openthread/coprocessor" |
| 110 | + OVERLAY_USB="${APP_DIR}/usb.overlay" |
| 111 | + CONF_USB="${APP_DIR}/overlay-usb-nrf-br.conf" |
| 112 | + CONF_RCP="${APP_DIR}/overlay-rcp.conf" |
| 113 | +
|
| 114 | + west build -b "$BOARD" -d build/ot-rcp-usb "$APP_DIR" -- \ |
| 115 | + -DDTC_OVERLAY_FILE="${OVERLAY_USB}" \ |
| 116 | + -DEXTRA_CONF_FILE="${CONF_USB}" \ |
| 117 | + -DCONF_FILE="prj.conf;${CONF_RCP}" |
| 118 | +
|
| 119 | + # ----------------------------------------------------------------------- |
| 120 | + # Collect artifacts under the exact paths/names you requested |
| 121 | + # ----------------------------------------------------------------------- |
| 122 | + - name: Collect artifacts to ot-nrf528xx/build/bin |
| 123 | + run: | |
| 124 | + set -euo pipefail |
| 125 | + mkdir -p ot-nrf528xx/build/bin |
| 126 | +
|
| 127 | + cp raytac-zephyr-workspace/build/ot-shell-uart/zephyr/zephyr.elf \ |
| 128 | + ot-nrf528xx/build/bin/ot-cli-ftd-UART |
| 129 | + cp raytac-zephyr-workspace/build/ot-shell-uart/zephyr/zephyr.hex \ |
| 130 | + ot-nrf528xx/build/bin/ot-cli-ftd-UART.hex |
| 131 | +
|
| 132 | + cp raytac-zephyr-workspace/build/ot-shell-usb/zephyr/zephyr.elf \ |
| 133 | + ot-nrf528xx/build/bin/ot-cli-ftd-USB |
| 134 | + cp raytac-zephyr-workspace/build/ot-shell-usb/zephyr/zephyr.hex \ |
| 135 | + ot-nrf528xx/build/bin/ot-cli-ftd-USB.hex |
| 136 | +
|
| 137 | + cp raytac-zephyr-workspace/build/ot-rcp-usb/zephyr/zephyr.elf \ |
| 138 | + ot-nrf528xx/build/bin/ot-rcp-USB |
| 139 | + cp raytac-zephyr-workspace/build/ot-rcp-usb/zephyr/zephyr.hex \ |
| 140 | + ot-nrf528xx/build/bin/ot-rcp-USB.hex |
| 141 | +
|
| 142 | + ls -lah ot-nrf528xx/build/bin |
| 143 | +
|
| 144 | + # ----------------------------------------------------------------------- |
| 145 | + # Generate DFU ZIP packages (for Raytac "Open Bootloader" USB-serial DFU) |
| 146 | + # ----------------------------------------------------------------------- |
| 147 | + - name: Generate Raytac DFU ZIP packages (nrfutil) |
| 148 | + run: | |
| 149 | + set -euo pipefail |
| 150 | +
|
| 151 | + cd ot-nrf528xx |
| 152 | +
|
| 153 | + gen_zip() { |
| 154 | + local hex="$1" |
| 155 | + local out="$2" |
| 156 | +
|
| 157 | + # Prefer the newer subcommand if available; otherwise fall back. |
| 158 | + if nrfutil nrf5sdk-tools -h >/dev/null 2>&1; then |
| 159 | + nrfutil nrf5sdk-tools pkg generate \ |
| 160 | + --hw-version 52 \ |
| 161 | + --sd-req=0x00 \ |
| 162 | + --application "$hex" \ |
| 163 | + --application-version 1 \ |
| 164 | + "$out" |
| 165 | + else |
| 166 | + nrfutil pkg generate \ |
| 167 | + --hw-version 52 \ |
| 168 | + --sd-req 0x00 \ |
| 169 | + --application "$hex" \ |
| 170 | + --application-version 1 \ |
| 171 | + "$out" |
| 172 | + fi |
| 173 | + } |
| 174 | +
|
| 175 | + gen_zip "build/bin/ot-cli-ftd-UART.hex" "build/bin/ot-cli-ftd-UART-raytac-dfu.zip" |
| 176 | + gen_zip "build/bin/ot-cli-ftd-USB.hex" "build/bin/ot-cli-ftd-USB-raytac-dfu.zip" |
| 177 | + gen_zip "build/bin/ot-rcp-USB.hex" "build/bin/ot-rcp-USB-raytac-dfu.zip" |
| 178 | +
|
| 179 | + ls -lah build/bin/*raytac-dfu.zip |
| 180 | +
|
| 181 | + - name: Upload artifacts |
| 182 | + uses: actions/upload-artifact@v4 |
| 183 | + with: |
| 184 | + name: raytac-mdbt50q-cx-40-openthread |
| 185 | + path: | |
| 186 | + ot-nrf528xx/build/bin/ot-cli-ftd-UART |
| 187 | + ot-nrf528xx/build/bin/ot-cli-ftd-UART.hex |
| 188 | + ot-nrf528xx/build/bin/ot-cli-ftd-USB |
| 189 | + ot-nrf528xx/build/bin/ot-cli-ftd-USB.hex |
| 190 | + ot-nrf528xx/build/bin/ot-rcp-USB |
| 191 | + ot-nrf528xx/build/bin/ot-rcp-USB.hex |
| 192 | + ot-nrf528xx/build/bin/ot-cli-ftd-UART-raytac-dfu.zip |
| 193 | + ot-nrf528xx/build/bin/ot-cli-ftd-USB-raytac-dfu.zip |
| 194 | + ot-nrf528xx/build/bin/ot-rcp-USB-raytac-dfu.zip |
| 195 | +
|
0 commit comments