Skip to main content

Install Zephyr on Your Local Machine

The Kasm containers make it easy to start training because the Zephyr workspace is pre-installed and ready to use. But what do you do when you get home and want to give Zephyr another try?

Here are some options for installing a local version of Zephyr.

Option A: The magtag-demo repository as a Zephyr install

At Golioth, we like to add a west manifest file (west.yml) to each of our project repositories. This file locks the project to a specific version of Zephyr, Golioth, and all of the dependencies, and makes it easy to install them. If you want to do more work with the MagTag, here's how to install those tools.

1. Create a Python virtual environment in the working folder

cd ~
mkdir magtag-demo
python3 -m venv magtag-demo/.venv
source magtag-demo/.venv/bin/activate
pip install wheel
pip install west
Reactivating the virtual environment

Each time you start a new terminal session you need to enable the Python virtual environment:

cd ~/magtag-demo
source .venv/bin/activate
cd app

2. Clone and Install

It is important that you do not use git to clone the repository. Zephyr's west meta tool will take care of fetching all of the code.

cd ~
west init -m https://github.com/golioth/magtag-demo.git magtag-demo
cd magtag-demo
west update
west zephyr-export
pip install -r ~/magtag-demo/deps/zephyr/scripts/requirements.txt
west blobs fetch hal_espressif

After fetching the code, the west update command installs necessary modules, followed by steps to install Python dependencies and the binary blobs for Espressif's WiFi radio.

3. Install the Zephyr SDK Toolchain

Up to this point we've been installing a standalone workspace inside the magtag-demo directory. The final piece of the puzzle is to install the Zephyr SDK Toolchain. You only need one copy of these tools on your machine so if you've previously installed them you may skip this section.

Download the latest SDK installer:

cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.0/zephyr-sdk-0.15.0_linux-x86_64.tar.gz

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

tar -xvf zephyr-sdk-0.15.0_linux-x86_64.tar.gz
cd zephyr-sdk-0.15.0
./setup.sh

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.15.0/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
sudo udevadm control --reload

Recap

You have now installed a local Zephyr workspace. Be sure to activate your Python virtual environment each time you start a new coding session, and build the samples from the magtag-demo/app folder.

Option B: Follow the Golioth Quickstart to install a Zephyr workspace

The official Golioth Docs include details about installing a Zephyr workspace. This workspace will also be able to build for other supported hardware like NXP. To build Zephyr projects for Nordic parts, please follow the NCS-focused installation guide.

Option C: Follow the Zephyr Getting Started Guide

The Zephyr project maintains a getting started guide for setting up a local Zephyr workspace. Note that Golioth is a module for Zephyr and if you follow this guide you will need to manually add Golioth to the west manifest file. For more, please see our blog post on adding Golioth to existing Zephyr projects.