|View source on GitHub|
How to build OpenThread
The steps to build OpenThread vary depending on toolchain, user machine, and target platform.
The most common workflow is:
- Set up the build environment and install the desired toolchain:
- To build directly on a machine, see the Simulation Codelab for detailed instructions
- To use a Docker container with a pre-configured environment,
download and run the OpenThread
docker pull openthread/environment:latest
docker run -it --rm openthread/environment bash
- Within your chosen environment, clone the platform-specific OpenThread Git repository. Taking CC2538 as an example:
git clone https://github.com/openthread/ot-cc2538.git --recursive
- From the cloned repository's root directory:
- Install the toolchain:
- Build the configuration:
./script/build platform-specific-args cmake-options
- Install the toolchain:
- Flash the desired binary to the target platform. All generated binaries are
You can configure OpenThread for different functionality and behavior during the build process. Available configuration options are detailed at the following locations:
|Compile-time constants||Listed in all the header files in
|cmake build options||Listed in
Use cmake build options to enable functionality for the platform. For example, to build the binary for the CC2538 platform with Commissioner and Joiner support enabled:
./script/build -DOT_COMMISSIONER=ON -DOT_JOINER=ON
Or, to build the nRF52840 platform with the Jam Detection feature enabled in its repo:
./script/build nrf52840 UART_trans -DOT_JAM_DETECTION=ON
The following binaries are generated in
./build/bin from the build process. To determine which binaries are generated, use flags with the
./script/build command. For example, to build OpenThread and generate only the FTD CLI binary:
./script/build -DOT_APP_CLI=ON -DOT_FTD=ON -DOT_MTD=OFF -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF -DOT_RCP=OFF
||Full Thread device for SoC designs||
||Minimal Thread device for SoC designs||
||Full Thread device for Network Co-Processor (NCP) designs||
||Minimal Thread device for NCP designs||
||Radio Co-Processor (RCP) design||
By default, all above flags are enabled. If you explicitly disable all flags, applications are not
built but OpenThread library files are still generated in
./build/lib for use in a project.
Check the example Makefiles for each platform to see which flags each platform supports. For more information on FTDs and MTDs, see the Thread Primer. For more information on SoC and NCP designs, see Platforms.
The process to flash these binaries varies across example platforms. See the READMEs in each platform's example folder for detailed instructions.
OpenThread Daemon (OT Daemon) is an OpenThread POSIX build mode that runs OpenThread as a service and is used with the RCP design. For more information on how to build and use it, see OpenThread Daemon.
Build Support Packages
Build Support Packages (BSPs) are found in
/third_party. BSPs are additional third-party code used by OpenThread on each respective platform, generally included when porting OpenThread to a new hardware platform.