Build on Linux/macOS


Install Dependencies

First, make sure you have current versions for the following tools:

cmake --version # must be >= 3.13.1
dtc --version # must be >= 1.4.6
python --version # bust be >= 3.6

Follow the instruction below to install the required tools:

If required, update your system:

sudo apt-get update
sudo apt-get upgrade

Install the required tools

sudo apt-get install --no-install-recommends git cmake ninja-build gperf ccache dfu-util device-tree-compiler wget python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev

Install the ARM Compiler Toolchain

Download the ARM embedded compiler toolchain

cd ~
# Download the package
# Extract
tar -jxvf gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
# Rename the directory to ~\gnuarmemb
mv gcc-arm-none-eabi-9-2020-q2-update gnuarmemb

set required environment variables

# Create ~/.zephyrrc for easy env variables management
echo 'export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb' >> ~/.zephyrrc
echo 'export GNUARMEMB_TOOLCHAIN_PATH="~/gnuarmemb"' >> ~/.zephyrrc

Install the Nordic SDK

the Nordic SDK is managed by the westtool, so we first need to install west: open a terminal and type

# Install west
pip3 install --user -U west
# Make sure the `west`executable is in front of your PATH:
echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
source ~/.bashrc
# Check that west is correctly installed
west --version

In your home directory, create a folder named ncs: we will install the SDK there:

mkdir ~/ncs
cd ~/ncs
# Initialize the folder
west init -m --mr v1.3.0
# Download all required repositories
west update
# Export a Zephyr CMake package. This allows CMake to automatically load the boilerplate code required for building nRF Connect SDK applications:
west zephyr-export

Install required python dependencies

pip3 install -r zephyr/scripts/requirements.txt
pip3 install -r nrf/scripts/requirements.txt
pip3 install -r bootloader/mcuboot/scripts/requirements.txt

Clone the Pebble-Firmware IoTeX repository:

The pebble-firmware IoTeX repository contains the firmware application source and the board definition file:

git clone

Before we can build the firmware we need to replace the default board definition from the nordic SDK with the one for Pebble:

# Delete the default board definition
rm -rf ~/ncs/nrf/boards/arm/thingy91_nrf9160
# Replace with the one from pebble-firmware
cp -rv ~/pebble-firmware-legacy/nrf/boards/arm/thingy91_nrf9160 ncs/nrf/boards/arm/

Before trying to build the project you must set the required environment variables for Zephyr, to do so you can run:

# Load environment variables for the Zephyr SDK
source ~/ncs/zephyr/

Among other things, this will also source your ~/.zephyrrc where the arm toolchain environment variables are set: you can use this file to add any customization to the environment.

Please notice that the environment variables will be lost if you close your terminal window: run source ~/ncs/zephyr/ again to get them back

The project can then be compiled with the following commands:

cd ~
# Make sure to remove any previously created build directory
rm -rf build/
# Start the build process
west build -b thingy91_nrf9160ns ~/pebble-firmware-legacy/nrf/applications/asset_tracker/

After the project is compiled successfully, you can flash the new Pebble firmware that is available at ~/build/zephyr/app_signed.hex.

See how to configure the firmware before the build. See how to flash the firmware.

Last updated