Switch branches/tags
Find file History
chshu and jwhui [nrf52840] fix the k802154Sync timer (#3181)
It may cause the issue that the timestamp provided by nrf_802154_received_timestamp_raw()
is not consistent with otPlatAlarmMicroGetNow().
Latest commit 71d4ad3 Oct 18, 2018
Permalink
..
Failed to load latest commit information.
DIAG.md [nrf52840] add basic gpio diag commands (#2139) Sep 15, 2017
Makefile.am [nrf52840] update drivers to SDK 15.1.0 (#3003) Aug 29, 2018
Makefile.platform.am [nrf52840] update drivers to SDK 15.1.0 (#3003) Aug 29, 2018
README.md [nrf52840] add support for USB bootloader on PCA10059 (#2994) Aug 27, 2018
alarm.c [nrf52840] fix the k802154Sync timer (#3181) Oct 18, 2018
diag.c [radio] union the transmit and receive information in radio frame (#2789 Jun 15, 2018
fem.c [nrf52840] update radio driver to 178ecb3514e5f46282bf2108b56aecf5b8d… Mar 7, 2018
flash.c [types] move types into specific headers (#2946) Aug 8, 2018
flash_nosd.c [types] move types into specific headers (#2946) Aug 8, 2018
flash_sd.c [types] move types into specific headers (#2946) Aug 8, 2018
logging.c [types] move types into specific headers (#2946) Aug 8, 2018
misc.c [examples] Introducing pseudo resets (#2621) Mar 15, 2018
nrf52840.ld [nRF52840] minor platform refactoring (#2305) Oct 31, 2017
nrf52840_bootloader.ld [nrf52840] add support for USB bootloader on PCA10059 (#2994) Aug 27, 2018
openthread-core-nrf52840-config.h [nrf52840] fix typo in log parameter (#3136) Oct 9, 2018
platform-config.h [nrf52840] fix default parameters of FEM (#2945) Aug 9, 2018
platform-fem.h [nrf52840] fix default parameters of FEM (#2945) Aug 9, 2018
platform-nrf5.h [nrf52840] fix NCP radio not working on USB CDC UART (#3169) Oct 17, 2018
platform-softdevice.h [nrf52840] use otSys prefix in the SoftDevice platform API (#3025) Sep 6, 2018
radio.c [platform] attach timestamp in promiscuous mode (#2954) Aug 10, 2018
random.c [code-style] apply clang-format Feb 9, 2018
softdevice.c [nrf52840] use otSys prefix in the SoftDevice platform API (#3025) Sep 6, 2018
softdevice.h [toolchain] fix warnings/errors in Keil compiler (#2286) Oct 25, 2017
spi-slave.c [types] move types into specific headers (#2946) Aug 8, 2018
system.c [nrf52840] fix NCP radio not working on USB CDC UART (#3169) Oct 17, 2018
temp.c [nrf52840] update radio driver to f36aa41 and provide temperature (#2638 Mar 27, 2018
uart.c [nrf52840] fix NCP radio not working on USB CDC UART (#3169) Oct 17, 2018
usb-cdc-uart.c [nrf52840] fix NCP radio not working on USB CDC UART (#3169) Oct 17, 2018

README.md

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 and Zigbee. See Nordic Semiconductor's nRF5 SDK for Thread and Zigbee section for more details.

Toolchain

Download and install GNU toolchain for ARM Cortex-M.

In a Bash terminal, follow these instructions to install the GNU toolchain and other dependencies.

$ cd <path-to-openthread>
$ ./script/bootstrap

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

Native USB support

You can build the libraries with support for native USB CDC ACM as a serial transport. To do so, build the libraries with the following parameter:

$ make -f examples/Makefile-nrf52840 USB=1

Note, that if Windows 7 or earlier is used, an additional USB CDC driver has to be loaded. It can be found in third_party/NordicSemiconductor/libraries/usb/nordic_cdc_acm_example.inf

nRF52840 dongle support (PCA10059)

You can build the libraries with support for USB bootloader present in PCA10059. As this dongle uses native USB support we have to enable it as well. To do so, build the libraries with the following parameter:

$ make -f examples/Makefile-nrf52840 USB=1 BOOTLOADER=1

Please see nRF52840 Dongle Programming for more details about how to use USB bootloader.

Native SPI Slave support

You can build the libraries with support for native SPI Slave. To do so, build the libraries with the following parameter:

$ make -f examples/Makefile-nrf52840 NCP_SPI=1

With this option enabled, SPI communication between the NCP example and wpantund is possible (provided that the wpantund host supports SPI Master). To achieve that, an appropriate SPI device should be chosen in wpantund configuration file, /etc/wpantund.conf. You can find an example below.

Config:NCP:SocketPath "system:/usr/bin/spi-hdlc-adapter --gpio-int /sys/class/gpio/gpio25 /dev/spidev0.0"

spi-hdlc-adapter is a tool that can be used to perform communication between NCP and wpantund over SPI. In the above example it is assumed that spi-hdlc-adapter is installed in /usr/bin.

The default SPI Slave pin configuration for nRF52840 is defined in examples/platforms/nrf52840/platform-config.h.

Note that the native SPI Slave support is not intended to be used with Engineering sample A of the nRF52840 chip due to single transfer size limitation.

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
Done
> ifconfig up
Done
> thread start
Done
  1. After a couple of seconds the node will become a Leader of the network.
> state
Leader
  1. Open a terminal connection on the second board and attach a node to the network.
> panid 0xabcd
Done
> ifconfig up
Done
> thread start
Done
  1. After a couple of seconds the second node will attach and become a Child.
> state
Child
  1. List all IPv6 addresses of the first board.
> ipaddr
fdde:ad00:beef:0:0:ff:fe00:fc00
fdde:ad00:beef:0:0:ff:fe00:9c00
fdde:ad00:beef:0:4bcb:73a5:7c28:318e
fe80:0:0:0:5c91:c61:b67c:271c
  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 README.md.

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.

Verification

The following toolchains have been used for testing and verification:

  • gcc version 4.9.3
  • gcc version 6.2.0

The following OpenThread commits have been verified with nRF52840 examples by Nordic Semiconductor:

  • ec59d7e - 06.04.2018 (the newest checked)
  • a89eb88 - 16.11.2017
  • 6a15261 - 29.06.2017
  • 030efba - 22.04.2017
  • de48acf - 02.03.2017
  • 50db58d - 23.01.2017

Nordic Semiconductor's nRF5 SDK for Thread and Zigbee

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

The nRF5 SDK for Thread and Zigbee includes:

  • a pre-built OpenThread stack for the Nordic nRF52840 SoC with ARM® CryptoCell-310 support,
  • unique Thread/Bluetooth Low Energy dynamic multiprotocol solution which allows for concurrent operation of Thread and Bluetooth Low Energy utilizing OpenThread and SoftDevice (Nordic’s Bluetooth Low Energy stack) with accompanying example applications,
  • Thread/Bluetooth Low Energy switched multiprotocol solution with accompanying example applications,
  • 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 CoAP or MQTT-SN protocols,
  • support for an OpenThread Network Co-Processor (NCP) using either UART or USB transport protocol,
  • Border Router and cloud connectivity example,
  • Thread native commissioning with NFC example,
  • example applications demonstrating the use of FreeRTOS with OpenThread,
  • support for IAR, Keil MDK-ARM and Segger Embedded Studio (SES) IDEs for OpenThread stack and all example applications,
  • range of PC tools including a Thread Topology Monitor,
  • software modules inherited from the nRF5 SDK e.g. peripheral drivers, NFC libraries, Bluetooth Low Energy libraries etc.

CryptoCell 310 support

By default, mbedTLS library is built with support for CryptoCell 310 hardware acceleration of cryptographic operations used in OpenThread. You can disable CryptoCell 310 and use software cryptography instead by building OpenThread with the following parameter:

$ make -f examples/Makefile-nrf52840 DISABLE_CC310=1