tree: 704c39bff6d155cc89710533ad28e5e541d07e11 [path history] [tgz]
  1. crypto/
  2. alarm.c
  3. diag.c
  5. flash.c
  6. flash_nosd.c
  7. flash_sd.c
  8. logging.c
  10. misc.c
  11. nrf52840.ld
  12. openthread-core-nrf52840-config.h
  13. platform-config.h
  14. platform-nrf5.h
  15. platform-softdevice.h
  16. platform.c
  17. radio.c
  18. random.c
  20. softdevice.c
  21. softdevice.h
  22. uart.c

OpenThread on nRF52840 Example

This directory contains example platform drivers for Nordic Semiconductor nRF52840 SoC.

To facilitate Thread products development with the nRF52840 platform, Nordic Semiconductor provides nRF5 SDK for Thread. See Nordic Semiconductor's nRF5 SDK for Thread section for more details.


Download and install GNU toolchain for ARM Cortex-M.

Building the examples

$ cd <path-to-openthread>
$ ./bootstrap
$ make -f examples/Makefile-nrf52840

After a successful build, the elf files can be found in <path-to-openthread>/output/nrf52840/bin. You can convert them to hex files using arm-none-eabi-objcopy:

$ arm-none-eabi-objcopy -O ihex ot-cli-ftd ot-cli-ftd.hex

Flashing the binaries

Flash the compiled binaries onto nRF52840 using nrfjprog which is part of the nRF5x Command Line Tools.

$ nrfjprog -f nrf52 --chiperase --program output/nrf52840/bin/ot-cli-ftd.hex --reset

Running the example

  1. Prepare two boards with the flashed CLI Example (as shown above).

  2. The CLI example uses UART connection. To view raw UART output, start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:

    • Baud rate: 115200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: RTS/CTS

    On Linux system a port name should be called e.g. /dev/ttyACM0 or /dev/ttyACM1.

  3. Open a terminal connection on the first board and start a new Thread network.

> panid 0xabcd
> ifconfig up
> thread start
  1. After a couple of seconds the node will become a Leader of the network.
> state
  1. Open a terminal connection on the second board and attach a node to the network.
> panid 0xabcd
> ifconfig up
> thread start
  1. After a couple of seconds the second node will attach and become a Child.
> state
  1. List all IPv6 addresses of the first board.
> ipaddr
  1. Choose one of them and send an ICMPv6 ping from the second board.
> ping fdde:ad00:beef:0:0:ff:fe00:fc00
16 bytes from fdde:ad00:beef:0:0:ff:fe00:fc00: icmp_seq=1 hlim=64 time=8ms

For a list of all available commands, visit OpenThread CLI Reference

Logging module

By default, the OpenThread‘s logging module provides functions to output logging information over SEGGER’s Real Time Transfer (RTT).

RTT output can be viewed in the J-Link RTT Viewer, which is available from SEGGER. The viewer is also included in the nRF Tools. To read or write messages over RTT, connect an nRF5 development board via USB and run the J-Link RTT Viewer.

Select the correct target device (nRF52) and the target interface “SWD”.

The intended log level can be set using OPENTHREAD_CONFIG_LOG_LEVEL define.

Disabling the Mass Storage Device

Due to a known issue in Segger’s J-Link firmware, depending on your version, you might experience data corruption or drops if you use the serial port. You can avoid this issue by disabling the Mass Storage Device:

  • On Linux or macOS (OS X), open JLinkExe from the terminal.
  • On Microsoft Windows, open the J-Link Commander application.

Run the following command: MSDDisable

Diagnostic module

nRF52840 port extends OpenThread Diagnostics Module.

You can read about all the features here.

Radio driver documentation

The radio driver comes with documentation that describes the operation of state machines in this module. To open the *.uml sequence diagrams, use PlantUML.


The following toolchains have been used for testing and verification:

  • gcc version 4.9.3
  • gcc version 6.2.0

The nRF52840 example has been verified by Nordic Semiconductor with following commits:

  • 030efba - 22.04.2017 (the newest checked)
  • de48acf - 02.03.2017
  • 50db58d - 23.01.2017

Nordic Semiconductor's nRF5 SDK for Thread

The nRF5 Software Development Kit (SDK) for Thread helps you when developing Thread products with Nordic Semiconductor's advanced nRF52840 System on Chip (SoC).

The nRF5 SDK for Thread includes:

  • a pre-built OpenThread stack for the Nordic nRF52840 SoC with ARM® CryptoCell-310 support,
  • unique support for DFU-over-Thread (Device Firmware Upgrade),
  • examples to demonstrate interactions between nodes performing different Thread roles with the use of OpenThread and built-in CoAP protocol,
  • examples to demonstrate multiprotocol support and switching between BLE peripheral and Thread FTD and MTD roles,
  • support for an OpenThread Network Co-Processor (NCP),
  • Border Router and cloud connectivity example,
  • Thread native commissioning with NFC example,
  • range of PC tools including a Thread Topology Monitor,
  • software modules inherited from the nRF5 SDK e.g. peripheral drivers, NFC libraries etc.

Important notice

Due to legal restrictions support for hardware-accelerated cryptography utilizing ARM CryptoCell-310 is only available in mbedTLS library (libmbedcrypto.a) provided with the nRF5 SDK for Thread. The library available in OpenThread repository does not support hardware acceleration. You can still use it, but the commissioning procedure takes much more time in such case. For the best performance and user experience, use the library provided with the SDK.