Skip to main content

Zephyr Toolchain Installation

This page includes sections from the Golioth docs site that walk through the installation of the SDKs and Toolchains necessary to build Zephyr firmware.


  • Summary:
    1. Install west (the Zephyr meta tool), the Golioth Zephyr SDK, and the Espressif (ESP32) toolchain.
    2. Clone the magtag-demo code repository that will be used for this training
  • Desired Outcome: By the end of this section you will have the software tools you need to build Zephyr projects and flash binaries to the MagTag board.
  • Approximate time: 15-20 minutes

Download Locally Hosted Packages

Internet speeds can be a problem for installing software tools at live training. To help, we have locally-available downloads for the biggest packages.

Step 1: Log onto our wireless router

  • SSID: golioth
  • password: training

Step 2: Navigate to this URL in your browser

  • golioth_zds2022-XXXXXX contains Zephyr SDK and Golioth SDK
  • zephyr-sdk-0.14.2_xxxxxx contains the Zephyr SDK Toolchain

Step 4: Disconnect your computer from our wireless router


Please be certain you have disconnected as we're using a cellular connection for this router and high-bandwidth demands may disrupt the rest of the workshop.

Step 5: Uncompress the archives

  • Uncompress the golioth-zds2022-LINUX.tar.gz archive into your home folder. (All archived files are contained in a folder called golioth-zephyr-workspace)
  • Uncompress the Zephyr SDK toolchain archive (zephyr-sdk-0.14.2_linux-XXXXXXXX.tar.gz) in your home directory (All archived files are contained in a folder called zephyr-sdk-0.14.2)

Install the Golioth Zephyr SDK

Step 1: Install West Meta Tool

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

West requires CMake version 3.20.0 or higher. Check the version that your package manager installed:

$ cmake --version
cmake version 3.16.3

If you have an older version, Ubuntu 20.04 systems can add the Kitware repository which maintains the newest release:

wget -O - 2>/dev/null | sudo apt-key add -
sudo apt-add-repository 'deb focal main'
sudo apt update
sudo apt install cmake
cmake --version

If the Kitware repository doesn't work for you (ie: your system is not running Ubuntu 20.04), you can build the stable version of CMake from source.

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

Step 2: Install Golioth Zephyr SDK

You previously downloaded and unpacked the golioth-zephyr-workspace. Tell west to automatically configure CMake:

cd ~/golioth-zephyr-workspace
west zephyr-export

Install the remaining dependencies:

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

Step 3: Installing the Zephyr SDK Toolchain

You previously downloaded and unpacked the Zephyr SDK Toolchain, now run the installer:

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

Step 4: Sample build

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

cd ~/golioth-zephyr-workspace/zephyr
west build -b esp32 samples/basic/minimal -p

The magtag-demo repository

For the rest of this tutorial we will use the magtag-demo code repository. This repo was already included in the SDK local download and can be found in the golioth-zephyr-sdk/modules/lib/golioth/samples/magtag-demo directory.


That was a lot of steps, thank you for your patience! With the toolchain now installed, we are ready to run some example code on the hardware.