Quick Start Guide: nRF52840 Dongle Firmware Development
The nRF52840 Dongle (PCA10059) is a cost-effective USB development board perfect for prototyping BLE, Zigbee, and Thread applications. Since it does not feature an onboard J-Link debugger, the development workflow differs slightly from standard Nordic Development Kits (DKs).
This guide outlines the standard workflow based on macOS and the nRF Connect SDK (NCS): Build -> Generate DFU Package -> USB Flashing.
1. Environment Preparation
Essential Tools
- nRF Connect for Desktop: Download from Nordic Official Site. After installation, it is recommended to add the Programmer and Serial Terminal apps.
- nrfutil: Required for packaging and flashing firmware.
1
pip3 install nrfutil
- nRF Connect SDK: Recommended to install via the VS Code Extension (“nRF Connect for VS Code”) for a one-click setup of the SDK and Toolchain.
2. Minimal Project Configuration (Hello World)
We will create a minimal project that supports the USB Virtual Serial Port (CDC ACM).
prj.conf (Key Configuration)
1 | # Enable USB Stack and CDC ACM Class |
src/main.c
1 |
|
3. Build and Package
3.1 Build
In VS Code, add a Build Configuration. Select nrf52840dongle_nrf52840 as the Board, then click Build.
Alternatively, use the command line:
1 | west build -b nrf52840dongle_nrf52840 |
The build artifact is located at build/zephyr/zephyr.hex.
3.2 Generate DFU Package
The Dongle can only be updated via its Bootloader. The .hex file must be packaged into a .zip archive:
1 | nrfutil pkg generate --hw-version 52 --sd-req 0x00 \ |
4. Enter DFU Mode and Flash
Enter DFU Mode
- Press the sideways Reset button.
- Insert the Dongle into a USB port.
- Release the button. The Red LED should pulse, indicating DFU mode is active.
Flash Firmware
- Find Device Port:
1
2ls /dev/tty.usbmodem*
# Example Output: /dev/tty.usbmodemXXXX - Flash:Note: Replace the port number in the command with the actual one observed.
1
nrfutil dfu usb-serial -pkg app.zip -p /dev/tty.usbmodemXXXX
Upon successful flashing, the device will automatically reboot and run the new firmware.
5. FAQ
- Q: Flashing fails with
No DFU devices found- A: Ensure the Red LED is pulsing (DFU mode). Verify the port number (the port in DFU mode may differ from the application runtime port).
- Q: No output on Serial Port
- A: The serial tool must enable the DTR signal (the code waits for DTR). We recommend using the Serial Terminal in nRF Connect for Desktop, which handles DTR automatically.
- Q:
nrfutilcommand not found- A: Ensure the Python
bindirectory is in your systemPATH.
- A: Ensure the Python
6. Advanced References
- Custom LED: Use an
.overlayfile to modify the Device Tree. - Reduce Firmware Size: Add
CONFIG_SIZE_OPTIMIZATIONS=ytoprj.conf. - Official Documentation: nRF52840 Dongle User Guide