nRF52840 Dongle

Overview

The nRF52840 Dongle (PCA10059) hardware provides support for the Nordic Semiconductor nRF52840 ARM Cortex-M4F CPU and the following devices:

  • ADC

  • CLOCK

  • FLASH

  • GPIO

  • I2C

  • MPU

  • NVIC

  • PWM

  • RADIO (Bluetooth Low Energy and 802.15.4)

  • RTC

  • SPI

  • UART

  • USB

  • WDT

More information about the board can be found at the nRF52840 Dongle website [1]. The nRF52840 Dongle guide [2] contains the processor’s information and the datasheet.

Hardware

The nrf52840dongle/nrf52840 has two external oscillators. The frequency of the slow clock is 32.768 kHz. The frequency of the main clock is 32 MHz.

Supported Features

The nrf52840dongle board supports the hardware features listed below.

on-chip / on-board
Feature integrated in the SoC / present on the board.
2 / 2
Number of instances that are enabled / disabled.
Click on the label to see the first instance of this feature in the board/SoC DTS files.
vnd,foo
Compatible string for the Devicetree binding matching the feature.
Click on the link to view the binding documentation.
nrf52840dongle
/
nrf52840

Type

Location

Description

Compatible

CPU

on-chip

ARM Cortex-M4F CPU1

arm,cortex-m4f

ADC

on-chip

Nordic Semiconductor nRF family SAADC node1

nordic,nrf-saadc

ARM architecture

on-chip

Nordic UICR (User Information Configuration Registers)1

nordic,nrf-uicr

on-chip

Nordic EGU (Event Generator Unit)6

nordic,nrf-egu

on-chip

Nordic nRF family ACL (Access Control List)1

nordic,nrf-acl

on-chip

Nordic nRF family MWU (Memory Watch Unit)1

nordic,nrf-mwu

Audio

on-chip

Nordic PDM (Pulse Density Modulation interface)1

nordic,nrf-pdm

Clock control

on-chip

Nordic nRF clock control node1

nordic,nrf-clock

Comparator

on-chip

Nordic nRF COMP (analog COMParator)1

nordic,nrf-comp

Counter

on-chip

Nordic nRF timer node5

nordic,nrf-timer

Cryptographic accelerator

on-chip

Nordic ECB (AES electronic codebook mode encryption)1

nordic,nrf-ecb

on-chip

Nordic nRF family CCM (AES CCM mode encryption)1

nordic,nrf-ccm

on-chip

ARM TrustZone CryptoCell 3101

arm,cryptocell-310

Debug

on-chip

ARMv7 instrumentation trace macrocell1

arm,armv7m-itm

Flash controller

on-chip

Nordic NVMC (Non-Volatile Memory Controller)1

nordic,nrf52-flash-controller

on-chip

Properties defining the interface for the Nordic QSPI peripheral1

nordic,nrf-qspi

GPIO & Headers

on-chip

NRF5 GPIOTE1

nordic,nrf-gpiote

on-chip

NRF5 GPIO2

nordic,nrf-gpio

I2C

on-chip

Nordic nRF family TWI (TWI master)1 1

nordic,nrf-twi

I2S

on-chip

Nordic I2S (Inter-IC sound interface)1

nordic,nrf-i2s

IEEE 802.15.4

on-chip

Nordic nRF IEEE 802.15.4 node1

nordic,nrf-ieee802154

Input

on-board

Group of GPIO-bound input keys1

gpio-keys

Interrupt controller

on-chip

ARMv7-M NVIC (Nested Vectored Interrupt Controller)1

arm,v7m-nvic

LED

on-board

Group of GPIO-controlled LEDs1

gpio-leds

on-board

Group of PWM-controlled LEDs1

pwm-leds

Miscellaneous

on-chip

Nordic FICR (Factory Information Configuration Registers)1

nordic,nrf-ficr

on-chip

Nordic nRF family PPI (Programmable Peripheral Interconnect)1

nordic,nrf-ppi

MTD

on-chip

Flash node1

soc-nv-flash

on-board

Fixed partitions of a flash (or other non-volatile storage) memory1

fixed-partitions

Networking

on-chip

Nordic nRF family RADIO peripheral1

nordic,nrf-radio

on-chip

Nordic nRF family NFCT (Near Field Communication Tag)1

nordic,nrf-nfct

Pin control

on-chip

The nRF pin controller is a singleton node responsible for controlling pin function selection and pin properties1

nordic,nrf-pinctrl

Power management

on-chip

Nordic nRF power control node1

nordic,nrf-power

PWM

on-chip

nRF PWM1 3

nordic,nrf-pwm

on-chip

nRFx S/W PWM1

nordic,nrf-sw-pwm

Regulator

on-chip

Nordic nRF5X regulator (fixed stage of the core supply)1

nordic,nrf5x-regulator

on-chip

Nordic nRF52X regulator (high voltage stage of the main supply)1

nordic,nrf52x-regulator-hv

Retained memory

on-chip

Nordic GPREGRET (General Purpose Register Retention) device2

nordic,nrf-gpregret

RNG

on-chip

Nordic nRF family RNG (Random Number Generator)1

nordic,nrf-rng

RTC

on-chip

Nordic nRF RTC (Real-Time Counter)3

nordic,nrf-rtc

Sensors

on-chip

Nordic nRF family TEMP node1

nordic,nrf-temp

on-chip

Nordic nRF quadrature decoder (QDEC) node1

nordic,nrf-qdec

Serial controller

on-chip

Nordic nRF family UARTE (UART with EasyDMA)1 1

nordic,nrf-uarte

SPI

on-chip

Nordic nRF family SPI (SPI master)1 1

nordic,nrf-spi

on-chip

Nordic nRF family SPIM (SPI master with EasyDMA)2

nordic,nrf-spim

SRAM

on-chip

Generic on-chip SRAM1

mmio-sram

Timer

on-chip

ARMv7-M System Tick1

arm,armv7m-systick

USB

on-chip

Nordic nRF52 USB device controller1

nordic,nrf-usbd

Watchdog

on-chip

Nordic nRF family WDT (Watchdog Timer)1

nordic,nrf-wdt

See nRF52840 Dongle website [1] and nRF52840 Dongle Hardware description [3] for a complete list of nRF52840 Dongle board hardware features.

Connections and IOs

LED

  • LED0 (green) = P0.6

  • LED1 (red) = P0.8

  • LED1 (green) = P1.9

  • LED1 (blue) = P0.12

Push buttons

  • BUTTON1 = SW1 = P1.6

  • RESET = SW2 = P0.18

Programming and Debugging

The nrf52840dongle board supports the runners and associated west commands listed below.

flash debug rtt attach debugserver
jlink ✅ (default)
nrfjprog
nrfutil ✅ (default)
pyocd

Applications for the nrf52840dongle/nrf52840 board configuration can be built in the usual way (see Building an Application for more details).

Flashing

The board supports the following programming options:

  1. Using the built-in bootloader only

  2. Using MCUboot in serial recovery mode

  3. Using an external debug probe

These instructions use the west tool and assume you are in the root directory of your west installation.

Option 1: Using the Built-In Bootloader Only

The board is factory-programmed with Nordic’s bootloader from Nordic’s nRF5 SDK. With this option, you’ll use Nordic’s nrfutil [5] program to create firmware packages supported by this bootloader and flash them to the device. Before proceeding make sure:

  • nrfutil is installed.

  • The nrf5sdk-tools command is installed within nrfutil.

  1. Reset the board into the Nordic bootloader by pressing the RESET button.

    The push button is on the far side of the board from the USB connector. Note that the button does not face up. You will have to push it from the outside in, towards the USB connector:

    Location of RESET button and direction of push

    The red LED should start a fade pattern, signalling the bootloader is running.

  2. Compile a Zephyr application; we’ll use Blinky.

    west build -b nrf52840dongle/nrf52840 zephyr/samples/basic/blinky
    
  3. Package the application for the bootloader using nrfutil:

    nrfutil nrf5sdk-tools pkg generate \
             --hw-version 52 \
             --sd-req=0x00 \
             --application build/zephyr/zephyr.hex \
             --application-version 1 \
             blinky.zip
    
  4. Flash it onto the board. Note /dev/ttyACM0 is for Linux; it will be something like COMx on Windows, and something else on macOS.

    nrfutil nrf5sdk-tools dfu usb-serial -pkg blinky.zip -p /dev/ttyACM0
    

    When this command exits, observe the green LED on the board blinking, instead of the red LED used by the bootloader.

For more information, see Nordic Semiconductor USB DFU [4].

Option 2: Using MCUboot in Serial Recovery Mode

It is also possible to use the MCUboot bootloader with this board to flash Zephyr applications. You need to do some one-time set-up to build and flash MCUboot on your board. From that point on, you can build and flash other Zephyr applications using MCUboot’s serial recovery mode. This process does not overwrite the built-in Nordic bootloader, so you can always go back to using Option 1 later.

Install nrfutil [5] and mcumgr [7] first, and make sure MCUboot’s imgtool is available for signing your binary for MCUboot as described on Signing Binaries.

Next, do the one-time setup to flash MCUboot. We’ll assume you’ve cloned the MCUboot [6] repository into the directory mcuboot, and that it is next to the zephyr repository on your computer.

  1. Reset the board into the Nordic bootloader as described above.

  2. Compile MCUboot as a Zephyr application.

    west build -b nrf52840dongle/nrf52840 -d build/mcuboot mcuboot/boot/zephyr
    
  3. Package the application for the bootloader using nrfutil:

    nrfutil nrf5sdk-tools pkg generate \
             --hw-version 52 \
             --sd-req=0x00 \
             --application build/mcuboot/zephyr/zephyr.hex \
             --application-version 1 \
             mcuboot.zip
    
  4. Flash it onto the board. Note /dev/ttyACM0 is for Linux; it will be something like COMx on Windows, and something else on macOS.

    nrfutil nrf5sdk-tools dfu usb-serial -pkg mcuboot.zip -p /dev/ttyACM0
    

You can now flash a Zephyr application to the board using MCUboot’s serial recovery mode. We’ll use the SMP server sample since it’s ready to be compiled for chain-loading by MCUboot (and itself supports firmware updates over Bluetooth).

  1. Boot into MCUboot serial recovery mode by plugging the board in with the SW1 button pressed down. See above for a picture showing where SW1 is.

    Do not press RESET; that will run the Nordic bootloader, which is different than MCUboot.

    A serial port will enumerate on your board. On Windows, “MCUBOOT” should appear under “Other Devices” in the Device Manager (in addition to the usual COMx device). On Linux, something like /dev/serial/by-id/usb-ZEPHYR_MCUBOOT_0.01-if00 should be created.

    If no serial port appears, try plugging it in again, making sure SW1 is pressed. If it still doesn’t appear, retry the one-time MCUboot setup.

  2. Compile smp_svr.

    west build -b nrf52840dongle/nrf52840 -d build/smp_svr zephyr/samples/subsys/mgmt/mcumgr/smp_svr
    
  3. Sign smp_svr for chain-loading by MCUboot.

    west sign -t imgtool --bin --no-hex -d build/smp_svr \
              -B smp_svr.signed.bin -- --key mcuboot/root-rsa-2048.pem
    
  4. Flash the application to the MCUboot serial port using mcumgr:

    mcumgr --conntype=serial --connstring='dev=/dev/ttyACM0,baud=115200' \
           image upload -e smp_svr.signed.bin
    
  5. Reset the device:

    mcumgr --conntype=serial --connstring='dev=/dev/ttyACM0,baud=115200' reset
    

You should now be able to scan for Bluetooth devices using a smartphone or computer. The device you just flashed will be listed with Zephyr in its name.

Note

This board supports building other Zephyr applications for flashing with MCUboot in this way also. Just make sure CONFIG_BOOTLOADER_MCUBOOT is set when building your application. For example, to compile blinky for loading by MCUboot, use this:

west build -b nrf52840dongle/nrf52840 -d build/blinky zephyr/samples/basic/blinky -- -DCONFIG_BOOTLOADER_MCUBOOT=y

You can then sign and flash it using the steps above.

Option 3: Using an External Debug Probe

If you have one, you can also use an external debug probe to flash and debug Zephyr applications, but you need to solder an SWD header onto the back side of the board.

For Segger J-Link debug probes, follow the instructions in the Nordic nRF5x Segger J-Link page to install and configure all the necessary software. Further information can be found in Flashing.

Locate the DTS file: boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts. This file requires a small modification to use a different partition table. Edit the include directive to include “fstab-debugger” instead of “fstab-stock”.

In addition, the Kconfig file in the same directory must be modified by setting BOARD_HAS_NRF5_BOOTLOADER to be default n, otherwise the code will be flashed with an offset.

Then build and flash applications as usual (see Building an Application and Run an Application for more details).

Here is an example for the Blinky application.

# From the root of the zephyr repository
west build -b nrf52840dongle/nrf52840 samples/basic/blinky
west flash

Observe the LED on the board blinking.

Debugging

The nrf52840dongle/nrf52840 board does not have an on-board J-Link debug IC as some nRF5x development boards, however, instructions from the Nordic nRF5x Segger J-Link page also apply to this board, with the additional step of connecting an external debugger.

Testing the LEDs and buttons on the nRF52840 Dongle

There are 2 samples that allow you to test that the buttons (switches) and LEDs on the board are working properly with Zephyr:

You can build and program the examples to make sure Zephyr is running correctly on your board.

References