nRF5 SDK for Thread and Zigbee v4.0.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 DISABLE_BUILTIN_MBEDTLS=1 DNS_CLIENT=1 DIAGNOSTIC=1 EXTERNAL_HEAP=1 JOINER=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1 SERVICE=1 UDP_FORWARD=1 ECDSA=1 SNTP_CLIENT=1 COAPS=1 DHCP6_SERVER=1 DHCP6_CLIENT=1
    • nRF52840 - USB transport:
      $ ./bootstrap
      $ make -f examples/Makefile-nrf52840 BORDER_AGENT=1 BORDER_ROUTER=1 COAP=1 COMMISSIONER=1 DISABLE_BUILTIN_MBEDTLS=1 DNS_CLIENT=1 DIAGNOSTIC=1 EXTERNAL_HEAP=1 JOINER=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1 SERVICE=1 UDP_FORWARD=1 ECDSA=1 SNTP_CLIENT=1 COAPS=1 DHCP6_SERVER=1 DHCP6_CLIENT=1 USB=1
      Note
      For PCA10059 support in a bare OpenThread environment, you need to add BOOTLOADER=USB flag.
    • nRF52840 - SPI transport:
      $ ./bootstrap
      $ make -f examples/Makefile-nrf52840 BORDER_AGENT=1 BORDER_ROUTER=1 COAP=1 COMMISSIONER=1 DISABLE_BUILTIN_MBEDTLS=1 DNS_CLIENT=1 DIAGNOSTIC=1 EXTERNAL_HEAP=1 JOINER=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1 SERVICE=1 UDP_FORWARD=1 ECDSA=1 SNTP_CLIENT=1 COAPS=1 DHCP6_SERVER=1 DHCP6_CLIENT=1 NCP_SPI=1
    • nRF52811 - UART transport:
      $ ./bootstrap
      $ make -f examples/Makefile-nrf52811 BORDER_ROUTER=1 COAP=1 DIAGNOSTIC=1 DNS_CLIENT=1 EXTERNAL_HEAP=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1
    • nRF52811 - SPI transport:
      $ ./bootstrap
      $ make -f examples/Makefile-nrf52811 BORDER_ROUTER=1 COAP=1 DIAGNOSTIC=1 DNS_CLIENT=1 EXTERNAL_HEAP=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.
  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-rcp.a libopenthread-rcp-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 platform specific platform-fem.h and platform-softdevice.h files from /external/project/openthread/examples/platforms/nrf528xx/src 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 following script to build all of the GCC libraries: py -3 <InstallFolder>/external/openthread/project/build_gcc_libs.py.
  3. After the libraries are built for all devices, use the following script to copy the compiled libraries to the output folder: py -3 <InstallFolder>/external/openthread/project/import_libs.py gcc.

Note that you can use the following script for a clean build of all GCC libraries:
py -3 <InstallFolder>/external/openthread/project/clean_gcc_libs.py

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 workspaces for all devices, for example <InstallFolder>/external/openthread/project/nrf52840/ot_nrf52840.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 for all devices, use the following script to copy the compiled libraries to the output folder: py -3 <InstallFolder>/external/openthread/project/import_libs.py iar.

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/nrf52833/openthread/ftd/arm5_no_packsc/openthread_lib_libopenthread_ftd.uvprojx) with Keil µVision 5.
    Note
    For nRF52840, the correct path is different for the Keil compiler, because of missing nrf_security support: <InstallFolder>/external/openthread/project/keil.
  3. In Keil µVision 5, select Project->Build Target.
  4. After the libraries are built for all devices, use the following script to copy the compiled libraries to the output folder: py -3 <InstallFolder>/external/openthread/project/import_libs.py keil.

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