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: Use the MagTag repo as a Zephyr installation
- Option B: Follow the Golioth Quickstart to install Zephyr
- Option C: Follow the Zephyr Getting Started Guide to install 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
- Linux
- MacOS
- Windows
cd ~
mkdir magtag-demo
python3 -m venv magtag-demo/.venv
source magtag-demo/.venv/bin/activate
pip install wheel
pip install west
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
cd ~
mkdir magtag-demo
python3 -m venv magtag-demo/.venv
source magtag-demo/.venv/bin/activate
pip install wheel
pip install west
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
cd %homepath%
mkdir magtag-demo
python -m venv magtag-demo\.venv
magtag-demo\.venv\Scripts\activate.bat
pip install west
Each time you start a new terminal session you need to enable the Python virtual environment:
cd %homepath%\magtag-demo
.venv\Scripts\activate.bat
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.
- Linux
- MacOS
- Windows
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
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
cd %homepath%
west init -m https://github.com/golioth/magtag-demo.git magtag-demo
cd magtag-demo
west update
west zephyr-export
pip install -r 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:
- Linux
- MacOS
- Windows
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
cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.0/zephyr-sdk-0.15.0_macos-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_macos-x86_64.tar.gz
cd zephyr-sdk-0.15.0
./setup.sh
Unpack the archive and run the installer. The SDK will be placed in the %HOMEPATH%\zephyr-sdk-0.14.2
directory:
cd %HOMEPATH%
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.0/zephyr-sdk-0.15.0_windows-x86_64.zip
unzip zephyr-sdk-0.15.0_windows-x86_64.zip
cd zephyr-sdk-0.15.0
setup.cmd
Answer y
to both of the questions asked during the setup process.
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.