nRF5 SDK for Thread and Zigbee v3.1.0
Building the latest OpenThread libraries

Table of Contents

Note
OpenThread is still in prerelease phase and its API changes frequently. Keep in mind that when the API changes, the examples might not compile with the latest OpenThread version right away without fixes.

It is recommended to use the provided, precompiled version of the OpenThread library. However, you can also compile the latest version from GitHub. You can either:

Before building the latest OT libraries, you can define your own MA-L (MAC Address Block Large), formerly called OUI, by configuring the device's IEEE EUI-64 address.

Building the library with GCC on Linux or Mac (recommended)

Follow the following steps to build the library:

  1. Make sure you have GNU Autotools installed on your system. Refer to the documentation of your distribution for information on how to download and install them.
  2. Download or clone the OpenThread stack repository.
  3. Navigate into the repository root folder.
  4. Depending on your SoC, run one of the following commands:
    • nRF52840 - UART transport:
      $ ./bootstrap
      $ make -f examples/Makefile-nrf52840 BORDER_AGENT=1 BORDER_ROUTER=1 COAP=1 COMMISSIONER=1 DNS_CLIENT=1 JOINER=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1 SERVICE=1 UDP_FORWARD=1 ECDSA=1 SNTP_CLIENT=1 COAPS=1
    • nRF52840 - USB transport:
      $ ./bootstrap
      $ make -f examples/Makefile-nrf52840 BORDER_AGENT=1 BORDER_ROUTER=1 COAP=1 COMMISSIONER=1 DNS_CLIENT=1 JOINER=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1 SERVICE=1 UDP_FORWARD=1 ECDSA=1 SNTP_CLIENT=1 COAPS=1 USB=1
      Note
      For PCA10059 support in a bare OpenThread environment, you need to add BOOTLOADER=1 flag.
    • nRF52840 - SPI transport:
      $ ./bootstrap
      $ make -f examples/Makefile-nrf52840 BORDER_AGENT=1 BORDER_ROUTER=1 COAP=1 COMMISSIONER=1 DNS_CLIENT=1 JOINER=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1 SERVICE=1 UDP_FORWARD=1 ECDSA=1 SNTP_CLIENT=1 COAPS=1 NCP_SPI=1
    • nRF52811 - UART transport:
      $ ./bootstrap
      $ make -f examples/Makefile-nrf52811 BORDER_ROUTER=1 COAP=1 DNS_CLIENT=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1
    • nRF52811 - SPI transport:
      $ ./bootstrap
      $ make -f examples/Makefile-nrf52811 BORDER_ROUTER=1 COAP=1 DNS_CLIENT=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1 NCP_SPI=1
      You can experiment with the build parameters, but make sure you include the parameters presented above. Otherwise, some examples might not compile or work properly. To create libraries suitable for performing Thread certification tests, run make commands above with the following additional parameters: DHCP6_CLIENT=1 DHCP6_SERVER=1 CERT_LOG=1.
  5. Because the SDK provides libraries with USB CDC, UART, and SPI support, rename the following USB and SPI libraries:
    Default name Rename to
    libopenthread-nrf52840-sdk.a libopenthread-nrf52840-sdk-usb.a
    libopenthread-nrf52840-softdevice-sdk.a libopenthread-nrf52840-sdk-softdevice-usb.a
    libopenthread-ncp-ftd.a libopenthread-ncp-ftd-spi.a
    libopenthread-ncp-mtd.a libopenthread-ncp-mtd-spi.a
    libopenthread-ncp-radio.a libopenthread-ncp-radio-spi.a
    libopenthread-nrf52840-sdk.a libopenthread-nrf52840-sdk-spi.a
    libopenthread-nrf52840-softdevice-sdk.a libopenthread-nrf52840-softdevice-sdk-spi.a
    libopenthread-nrf52811-sdk.a libopenthread-nrf52811-sdk-spi.a
    -# Copy the libraries from <OpenThreadFolder>/output/<target>/lib to the SDK folder: /external/openthread/lib/<target>gcc.
  6. Copy the <OpenThreadFolder>/include folder to the /external/openthread folder.
  7. Copy the nRF52840-specific platform-fem.h and platform-softdevice.h files from /external/project/openthread/examples/platforms/nrf52840 to the /external/openthread/include/platform folder.
  8. Copy openthread-system.h file from /external/project/openthread/examples/platforms to the /external/openthread/include/platform folder.

Now you can recompile the examples with the latest libraries.

Building the library with GCC on Windows

  1. Download or clone the OpenThread stack repository to the <InstallFolder>/external/openthread/project/openthread folder.
  2. Run the build_gcc_libs.bat script to build all of the libraries.
  3. After the libraries are built, use the provided script (py -3 <InstallFolder>/external/openthread/project/import_libs.py gcc) to copy the compiled libraries to the output folder.

Now you can recompile the examples with the latest libraries.

Building the library with IAR

Follow these steps to build the library:

  1. Download or clone the OpenThread stack repository to the <InstallFolder>/external/openthread/project/openthread folder.
  2. Open the OpenThread workspace (<InstallFolder>/external/openthread/project/openthread_lib.eww) with IAR Embedded Workbench.
  3. In IAR Embedded Workbench:
    1. Select all of the projects in the left panel.
    2. Right-click on any of them and select Make.
  4. After the libraries are built, use the provided script (py -3 <InstallFolder>/external/openthread/project/import_libs.py iar) to copy the compiled libraries to the output folder.

Now you can recompile the examples with the latest libraries.

Building the library with Keil 5

Follow these steps to build the library:

  1. Download or clone the OpenThread stack repository to the <InstallFolder>/external/openthread/project/openthread folder.
  2. You must build each of the libraries separately. Open the project of a specific OpenThread library (for example, <InstallFolder>/external/openthread/project/lib/openthread/ftd/arm5_no_packsc/openthread_lib_libopenthread_ftd.uvprojx) with Keil µVision 5.
  3. In Keil µVision 5, select Project->Build Target.
  4. After the libraries are built, use the provided script (py -3 <InstallFolder>/external/openthread/project/import_libs.py keil) to copy the compiled libraries to the output folder.

Now you can recompile the examples with the latest libraries.

Note
OpenThread projects for GCC, IAR, and Keil 5 in this SDK were based on a specific OpenThread commit. Refer to the release notes for the commit ID. Using a more recent commit might require some manual changes in the project to compile libraries without errors. Also, the library configuration must be done manually in case a user wants to build the libraries in other configuration than provided.

Documentation feedback | Developer Zone | Subscribe | Updated