Skip to main content

Compiling the Software

Prerequisite

Make sure the Toolchain is set up as described.

Build Configurations

ZSWatch supports different board targets and logging transports. You combine them when creating a build.

Board Targets

TargetBoard stringDescription
WatchDKwatchdk@1/nrf5340/cpuappCurrent development kit
ZSWatch Legacy v5zswatch_legacy@5/nrf5340/cpuappLegacy ZSWatch v5 hardware
ZSWatch Legacy v4zswatch_legacy@4/nrf5340/cpuappLegacy ZSWatch v4 hardware
Native simulatornative_sim/native/64Linux simulator, see Native Simulator

Debug Logging

For debug builds, you need a base config (debug.conf) plus a log transport:

TransportKconfig fragmentOverlay neededNotes
UARTdebug.conf, log_on_uart.conflog_on_uart.overlayLogs via serial
RTTdebug.conf, log_on_rtt.conf(none)Logs via SEGGER RTT (needs J-Link)
USBdebug.conf, log_on_usb.conflog_on_usb.overlayLogs via USB CDC ACM

For release builds (no logging, optimized), use release.conf instead of debug.conf.


Option A: Build from VS Code (nRF Connect Extension)

  1. Open VS Code with the nRF Connect extension.

  2. In the nRF Connect sidebar, under Application, select app.

  3. Click Add build configuration.

    • Target: Select your board (e.g. watchdk@1/nrf5340/cpuapp).
    • Extra Kconfig fragments: Add the config files, e.g.: debug.conf, log_on_uart.conf
    • Extra Devicetree overlays: Add if needed, e.g.: log_on_uart.overlay
    • Build Directory: Optionally name it, e.g. build_devkit.
  4. Click Generate and Build.

Option B: Build from Command Line

Open an nRF Connect Terminal in VS Code (Ctrl+Shift+PnRF Connect: Create Shell Terminal) and run:

# For example WatchDK with UART debug logging
west build --build-dir app/build_dbg_dk app \
--board watchdk@1/nrf5340/cpuapp -- \
-DEXTRA_CONF_FILE="boards/debug.conf;boards/log_on_uart.conf" \
-DEXTRA_DTC_OVERLAY_FILE="boards/log_on_uart.overlay"
More build examples
# WatchDK with RTT debug (no overlay needed)
west build --build-dir app/build_dbg_dk app \
--board watchdk@1/nrf5340/cpuapp -- \
-DEXTRA_CONF_FILE="boards/debug.conf;boards/log_on_rtt.conf"

# Legacy ZSWatch v5 with RTT debug
west build --build-dir app/build_dbg_leg_v5 app \
--board zswatch_legacy@5/nrf5340/cpuapp -- \
-DEXTRA_CONF_FILE="boards/debug.conf;boards/log_on_rtt.conf"

# Native simulator (Linux)
west build --build-dir app/build app \
--board native_sim/native/64 \
-DSB_CONF_FILE="sysbuild_no_mcuboot_no_xip.conf"

Flashing

From VS Code

Use the nRF Connect extension: Actions → Flash.

When hovering the Flash button, an icon to the right will appear "Erase and Flash to Board". Use it as it will be much faster.

From Command Line

west flash --build-dir app/build_dbg_dk
TODO

Document how to flash a locally built firmware image without a debugger, using MCUboot and MCUmgr tools only (USB or BLE).


Debugging

For information on debugging, see the Debugging guide.