Skip to main content

Set up Zephyr for nRF9160

Zephyr Setup Overview

Golioth is implemented on IoT devices using Device SDKs. These are based on different embedded Real Time Operating Systems (RTOS). Currently Golioth targets the Zephyr Project and builds upon the APIs & tools of Zephyr. As such, prior experience with Zephyr will be helpful when working with Golioth's Zephyr Device SDK. Refer to Zephyr's detailed documentation when running into issues.

The nRF9160 Feather and all Nordic Semiconductor devices utilizing Zephyr require the nRF Connect SDK (NCS). Nordic Semiconductor maintains a fork of the Zephyr project that includes some distinct features and IP, including the firmware for the cellular modem on the nRF9160. We will install the nRF Connect SDK in a directory in your home location separate from other Zephyr projects shown for Golioth (in a directory called golioth-ncs-workspace)

Install West

west is the Zephyr "meta tool" that will allow you to build firmware, install packages, and flash firmware. There are various dependencies required, depending upon your operating system (OS), because west is Python based.

Choose your OS from the tabs below

Install dependencies with apt:

sudo apt update
sudo apt 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

While the official documentation for Zephyr suggests jumping right into installing west, we suggest creating a python3 virtual environment first, to avoid running into tooling incompatibilities.

Use pip3 to install west (beginning with the wheel dependency):

pip3 install wheel
pip3 install west

Installing the NRF Connect SDK


These directions are mirroring the Zephyr and Python dependency install instructions. Some directions may be slightly modified to fit your nRF91 / Golioth install.

With west installed, grab the Golioth NCS SDK:

cd ~
west init -m --mf west-ncs.yml ~/golioth-ncs-workspace
cd golioth-ncs-workspace
west update

Tell west to automatically configure CMake:

west zephyr-export

Lastly, install the remaining dependencies:

pip3 install -r ~/golioth-ncs-workspace/zephyr/scripts/requirements.txt

Installing the Zephyr SDK Toolchain

The nRF9160 is an ARM based device, so we will use the ARM toolchains (gcc, gdb, etc) included in the Zephyr SDK

Download the latest SDK installer:

cd ~

Unpack the archive and run the installer. The SDK will be placed in the ~/zephyr-sdk-0.14.2 directory:

tar -xvf zephyr-sdk-0.14.2_linux-x86_64.tar.gz
cd zephyr-sdk-0.14.2

Answer y to both of the questions asked during the setup process.

Install udev rules, which allow you to flash most Zephyr boards as a regular user:

sudo cp ~/zephyr-sdk-0.14.2/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d/
sudo udevadm control --reload

Build firmware for the nRF9160

Your system is all set up and ready to start building & flashing with Zephyr. Verify by building a minimal sample for the nRF9160 DK:

cd ~/golioth-ncs-workspace/zephyr
west build -p auto -b nrf9160dk_nrf9160_ns samples/basic/minimal

Flash firmware to the device

If you are using a J-Link hardware programmer and already have the software for that tool set up on your system, flashing firmware is as simple as running:

west flash

The nRF9160 DK acts as a J-Link hardware programmer. west will automatically work with J-Link as long as the supporting software is installed on your system. The next section will walk through installing that software.