Environment Setup & West
This guide walks you through setting up a complete Zephyr development environment from scratch, then covers the west commands you'll use every single day.
You can place your Zephyr workspace anywhere on your machine. Throughout this guide we use /your/workspace/path as a placeholder — replace it with wherever you want to keep your workspace (e.g. /home/john/zephyr_ws on Linux, /Users/john/zephyr_ws on macOS or D:\projects\zephyr_ws on Windows).
Minimum tool versions required:
| Tool | Minimum version |
|---|---|
| CMake | 3.20.5 |
| Python | 3.12 |
Devicetree compiler (dtc) | 1.4.6 |
Step 1 — Install system dependencies
- 🐧 Linux
- 🍎 macOS
- 🪟 Windows
Update your system first:
sudo apt update && sudo apt upgrade
Install all required packages:
sudo apt install --no-install-recommends \
git cmake ninja-build gperf ccache dfu-util \
device-tree-compiler wget python3-dev python3-venv \
python3-tk xz-utils file make gcc gcc-multilib \
g++-multilib libsdl2-dev libmagic1
On ARM64 systems (e.g. Raspberry Pi), omit gcc-multilib and g++-multilib.
Verify your tool versions:
cmake --version # must be >= 3.20.5
python3 --version # must be >= 3.12
dtc --version # must be >= 1.4.6
Install Homebrew if you don't have it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
source ~/.zprofile
Install all required packages:
brew install cmake ninja gperf python3 python-tk \
ccache qemu dtc libmagic wget openocd
echo 'export PATH="'$(brew --prefix)'/opt/python/libexec/bin:$PATH"' >> ~/.zprofile
source ~/.zprofile
x86-64 macOS (Intel) is not supported by the Zephyr SDK installer. Use Apple Silicon (M1/M2/M3) or run Linux in a VM.
Verify your tool versions:
cmake --version
python3 --version
dtc --version
winget is the Windows Package Manager — built into Windows 10 (1709+) and Windows 11.
It installs and updates tools from the command line, similar to apt on Linux or brew on macOS.
Open PowerShell as Administrator and install all required tools in one command:
winget install --id Kitware.CMake --silent
winget install --id Ninja-build.Ninja --silent
winget install --id oss-winget.gperf --silent
winget install --id Python.Python.3.12 --silent
winget install --id Git.Git --silent
winget install --id oss-winget.dtc --silent
winget install --id wget.wget --silent
winget install --id 7zip.7zip --silent
Or chain them all into a single call:
winget install Kitware.CMake Ninja-build.Ninja `
oss-winget.gperf Python.Python.3.12 `
Git.Git oss-winget.dtc wget.wget 7zip.7zip
Close and reopen PowerShell to pick up the new PATH entries before running any of the tools.
Verify:
cmake --version
python --version
dtc --version
Step 2 — Create a virtual environment and install west
West is the meta-tool that ships with Zephyr. It does two things:
- Workspace management — clones Zephyr and all its dependencies at the exact right versions
- Build and flash CLI — wraps
cmake,ninja, and your programmer into single commands
Install it inside a Python virtual environment to keep it isolated from your system Python.
- 🐧 Linux
- 🍎 macOS
- 🪟 Windows
python3 -m venv /your/workspace/path/.venv
source /your/workspace/path/.venv/bin/activate
pip install west
python3 -m venv /your/workspace/path/.venv
source /your/workspace/path/.venv/bin/activate
pip install west
PowerShell:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
python -m venv D:\your\workspace\path\.venv
D:\your\workspace\path\.venv\Scripts\Activate.ps1
pip install west
The virtual environment is not activated automatically. Every time you open a new terminal and want to work with your Zephyr workspace, run the activate command first:
- Linux / macOS:
source /your/workspace/path/.venv/bin/activate - Windows (PowerShell):
D:\your\workspace\path\.venv\Scripts\Activate.ps1
Your prompt will show (.venv) when the environment is active.
Verify west is installed:
west --version
# west, version 1.x.x
Step 3 — Initialize the Zephyr workspace
This step clones Zephyr v4.4.0 and all its dependencies (HALs, modules, bootloader). Expect 2–3 GB of downloads — it only runs once per workspace.
west init -m https://github.com/zephyrproject-rtos/zephyr --mr v4.4.0 /your/workspace/path
cd /your/workspace/path
west update
west zephyr-export
Always use west init instead of git clone. West registers the manifest so that west update always restores the exact dependency tree — your project will build correctly years from now.
Install the Python dependencies:
- 🐧 Linux
- 🍎 macOS
- 🪟 Windows
west packages pip --install
west packages pip --install
PowerShell:
python -m pip install @((west packages pip) -split ' ')
Step 4 — Install the Zephyr SDK
The SDK contains the toolchains for ARM, RISC-V, Xtensa, and all other supported architectures.
cd /your/workspace/path/zephyr
west sdk install
west sdk install automatically downloads and sets up the correct SDK version for your Zephyr checkout.
Step 5 — Verify the installation
Build the blinky sample for your board. Replace <your-board> with your actual board name (e.g. esp32s3_devkitc/esp32s3/procpu, nrf52840dk/nrf52840):
cd /your/workspace/path/zephyr
west build -p always -b <your-board> samples/basic/blinky
If the build completes without errors, your environment is ready.
Serial console — VS Code setup
To read printf / printk output from your board over USB, install the Serial Monitor extension in VS Code and set up the USB serial driver for your platform.
Install the extension:
Open VS Code, go to the Extensions panel (Ctrl+Shift+X / Cmd+Shift+X), and search for Serial Monitor by Microsoft.
- 🐧 Linux
- 🍎 macOS
- 🪟 Windows
On Linux, serial port access requires adding your user to the dialout group:
sudo usermod -aG dialout $USER
Log out and back in for the change to take effect. Then verify:
groups | grep dialout
Linux includes CP210x, CH340, and FTDI drivers in the kernel — no additional installation needed.
Most ESP32 and nRF boards use one of these USB-to-serial chips. Install the driver that matches your board:
| Chip | Common boards | Driver |
|---|---|---|
| CP210x (Silicon Labs) | ESP32-DevKitC, many Espressif boards | silabs.com/developers/usb-to-uart-bridge-vcp-drivers |
| CH340 / CH341 | Cheaper ESP32 clones | wch-ic.com |
After installing, plug in your board and verify the port appears:
ls /dev/cu.*
# e.g. /dev/cu.usbserial-0001
Windows requires a USB-to-serial driver. Install the one that matches your board's chip:
| Chip | Common boards | Driver |
|---|---|---|
| CP210x (Silicon Labs) | ESP32-DevKitC, many Espressif boards | silabs.com/developers/usb-to-uart-bridge-vcp-drivers |
| CH340 / CH341 | Cheaper ESP32 clones | wch-ic.com |
| FTDI | Older and industrial boards | ftdichip.com/drivers/vcp-drivers |
After installing, plug in your board and check Device Manager → Ports (COM & LPT) — your board should appear as a COM port (e.g. COM3).
Check the board's product page or look for a small IC near the USB connector labelled CP2102, CH340, or FT232.
Open the Serial Monitor in VS Code (Terminal → Serial Monitor), select the correct port, set the baud rate to 115200, and connect.