STM32WB OpenThread Border Router Application

Revision as of 14:15, 21 December 2021 by Registered User

1. Introduction

Regarding Thread implementation, each node forming the 802.15.4 network can act with different roles: Leader, Router, End device or Sleepy End Device (SED). A special role named Border Router allows the Thread nodes to access the outside world through an end-to-end IPv6 connection. A Thread Border Router (i.e., Thread BR) connects a Thread network to other IP-based networks, such as Wi-Fi or Ethernet. A Thread network requires a Border Router to connect to other networks. It is basically a bridge between Thread network and a Wi-Fi or ethernet interface.

OpenThread Border Router


A Thread Border Router minimally supports the following functions:

  • Bidirectional IP connectivity between Thread and Wi-Fi/Ethernet networks.
  • Bidirectional service discovery via mDNS (on a Wi-Fi/Ethernet link).
  • Thread-over-infrastructure that merges Thread partitions over IP-based links.
  • External Thread Commissioning (for example, a mobile phone) to authenticate and join a Thread device to a Thread network.

2. STM32WB Radio system

BLE and 802.15.4 protocols share the same radio IP.

STM32WB Radio system

3. OpenThread Border Router (OTBR) Application Setup

The border router is based on a Raspberry Pi (RPi) loaded with OTBR and a Dory acting as RCP (Radio co-processor). The RCP is controlled by the RPi as a remote Radio and all commands and data packets are send from RPi to RCP and vice versa. OTBR includes:

  • Bridge ethernet/WiFi to Thread
  • Open Thread stack (above MAC)
  • Local web server to server Web pages through WiFi AP

OTBR comes in Raspberry Pi image which embeds a list of services.

The OpenThread stack partitioning between RPi and STM32WB is as follow: Host processor RPi is running the OpenThread core stack (OTBR), and the RCP is handling the low radio layers (sub-MAC and radio drivers). The host processor typically does not sleep in this design, in part to ensure reliability of the Thread network. The advantage here is that OpenThread can utilize the resources on the more powerful processor. This design is useful for devices that are less sensitive to power constraints.

OpenThread stack partitioning

3.1. Hardware requirements

To setup a minimal running network we need at least:

  • 2 STM32WB are needed to demonstrate Thread BR (one attached with the RPi as RCP and another one forming a Thread network together with Thread BR).
  • 1 FTDI cable (TTL-232R-RPi), used to allow communication RPi and STM32WB RCP.
  • Regarding RPi:
    • A Raspberry Pi 3B or newer
    • Rpi’s External 5V AC adapter for power
    • A microSD card of at least 64GB ("SD card" in this guide). Please choose a Samsung or Sandisk SD card brand as it has been demonstrated by the RPi community to be much more reliable than the other manufacturers
    • A direct internet connection with no VPN through ethernet
    • USB keyboard
    • HDMI capable screen
    • Ethernet cable to directly connect to an internet ISP box

The following picture depicts 4 nodes OpenThread network.

4 Nodes OpenThread Network

3.2. STM32WB RCP setup

3.2.1. STM32WB RCP hardware connection

The communication with RPi is done through a serial connection. For RCP implementation, UART Rx/Tx are routed to external connector CN10 pin 35 (Tx) and pin 37 (Rx). So please use the FTDI cable to connect its Rx connector (usually the yellow one) to CN10 pin 35 and its Tx connector (usually the orange one) to CN10 pin 37. Black connector (i.e. ground) can be found on CN10 pin 32.

STM32WB RCP hardware connection

3.2.2. STM32WB RCP software setup

There is a dedicated application called Thread_RCP to be flashed. Thread_RCP Application is available since STM32Cube_FW_WB V1.12.0. This application requires stm32wb5x_Thread_RCP_fw.bin binary to be flashed on the Wireless Coprocessor. If it is not the case, you need to use STM32CubeProgrammer to load the appropriate binary. All available binaries are located under /Projects/STM32_Copro_Wireless_Binaries directory. Please, refer to UM2237 to learn how to use/install STM32CubeProgrammer. Refer to /Projects/STM32_Copro_Wireless_Binaries/ReleaseNote.html for the detailed procedure to change the Wireless Coprocessor binary. Once the wireless coprocessor flashed, you need to build and flash the Thread_RCP application, to do so:

  • Connect an STM32WB55xx_Nucleo board to your PC.
  • Open your preferred toolchain.
  • Rebuild all files and load your image, or use the Thread_RCP_reference.hex from Binary directory.
  • Connect one HyperTerminal (ST_Link) to be able to get the RCP running logs.

On joiner node side, the stm32wb5x_Thread_FTD_fw.bin is to be flashed using STM32CubeProgrammer. The dedicated application to be used is the following:

  • Thread_Cli_Cmd.bin: if using v1.12.0, which will require CLI commands typing.
  • Thread_RCP_Cli_Cmd.bin: if using v1.13.0 or newer, which enables a 1 push button commissioning feature.

Both usages are depicted in the “how to launch the demo” section.

3.3. RPi setup

3.3.1. RPi hardware connection

Please connect USB part of the FTDI cable to one of the available RPi USB port. Also use USB ports to connect a mouse and a keyboard. HDMI cable to dedicated screen. Please wait before providing power supply through microUSB. SD card must first be flash with OTBR_CLI_RPi_1.0.img.

RPi hardware connection

3.3.2. RPi software setup

A full configured RPi image is provided by ST. Please get the OTBR_CLI_RPi_1.0.img. To flash this image onto your SD Card, please download and install Win32DiskImager from the Win32DiskImager [1].

  • Insert the SD Card to be Flashed.

Insert a blank (or used and nuked) SD card into the SD card reader on your Windows computer.

  • Prepare the SD Card to be Flashed.

Click on the Start menu icon and type disk management and press the Return key to locate and open the Disk Management program. Prepare the SD Card to be Flashed

SD Card Preparation

Secondary-click on the volume to bring up the context-sensitive menu and delete all the partitions on the SD card (if there are any). Format the SD Card as FAT–32 or NTFS, as these filesystems are recognized by Windows computers, by secondary-clicking to bring up the context-sensitive menu and select Format.

  • Flash a Disk Image to an SD Card

Launch Win32DiskImager. Click on the blue folder icon and browse to the location where you previously saved your Raspberry Pi SD card image file, ending .img, in my example OTBR_CLI_RPi_1.0.img. Under Device, select the drive letter of your SD card, in my example E: and click Write button. You will see a warning dialogue box saying: Writing to a physical device can corrupt the device. (Target device [E:] “RPI”) Are you sure you want to continue?
Double-check you have selected the correct destination for your SD card and click the Yes button. Again, the progress bar will be shown to give you an indication of how long the process will take to complete. When completed, eject the SD card from the SD card reader and insert it in your RPi.

3.4. Thread nodes setup

You need at least one spare Thread node. To do so please refer to the Thread_Cli_Cmd (with v1.12.0) or Thread_RCP_Cli_Cmd.bin (with v1.13.0) application readme.txt to setup properly your nodes. Also open a terminal (like Teraterm or Putty) and connect it to the COM port of your node.

4. Acronyms and definitions

Term Definition
RCP Radio Co-Processor

5. References