Getting Started Guide
Follow this guide to:
Set up a command-line Zephyr development environment on Ubuntu, macOS, or Windows (instructions for other Linux distributions are discussed in Install Linux Host Dependencies)
Get the source code
Build, flash, and run a sample application
Select and Update OS
Click the operating system you are using.
This guide covers Ubuntu version 24.04 LTS and later. If you are using a different Linux distribution see Install Linux Host Dependencies.
sudo apt update
sudo apt upgrade
Select andd install any available updates. See this Apple support topic for more details.
Note
x86-64 macOS is not supported.
Select . Click Check for updates and install any that are available.
Install dependencies
Next, install the host tools Zephyr needs to configure and build applications. The instructions below use the recommended package manager for each operating system so the tools are available from your terminal.
The current minimum required versions for the main dependencies are:
Tool |
Min. Version |
|---|---|
3.20.5 |
|
3.12 |
|
1.4.6 |
Note
Python 3.12 is strongly recommended. Using a newer Python release may fail on some systems, for example when installing the required packages on Windows.
Use
aptto install the required dependencies: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
Note
Due to the unavailability of
gcc-multilibandg++-multilibon AArch64 (ARM64) systems, you may need to omit them from the list of packages to install.Verify the versions of the main dependencies installed on your system by entering:
cmake --version python3 --version dtc --version
Check those against the versions in the table in the beginning of this section. Refer to the Install Linux Host Dependencies page for additional information on updating the dependencies manually.
Install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After the Homebrew installation script completes, follow the on-screen instructions to add the Homebrew installation to the path.
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile source ~/.zprofile
Use
brewto install the required dependencies:brew install cmake ninja gperf python3 python-tk ccache qemu dtc libmagic wget openocd
Add the Homebrew Python folder to the path so you can execute
pythonandpipas well aspython3andpip3.(echo; echo 'export PATH="'$(brew --prefix)'/opt/python/libexec/bin:$PATH"') >> ~/.zprofile source ~/.zprofile
Note
Due to issues finding executables, the Zephyr Project doesn’t currently support application flashing using the Windows Subsystem for Linux (WSL) (WSL).
Therefore, we don’t recommend using WSL when getting started.
On modern versions of Windows (10 and later), install Windows Terminal from the
Microsoft Store. The instructions below work in either cmd.exe or
PowerShell.
These instructions use Windows’ official package manager, winget. If winget
isn’t an option, install the dependencies from their respective websites and
make sure their command line tools are on your PATH environment
variable.
In modern Windows versions, winget is already pre-installed by default. You can verify that this is the case by typing
wingetin a terminal window. If that fails, you can then install winget.Open a Command Prompt (
cmd.exe) or PowerShell terminal window. To do so, press the Windows key, typecmd.exeor PowerShell and click on the result.Use
wingetto install the required dependencies:winget install Kitware.CMake Ninja-build.Ninja oss-winget.gperf Python.Python.3.12 Git.Git oss-winget.dtc wget 7zip.7zip
Close the terminal window.
Note
You may need to add the 7zip installation folder to your PATH.
Get Zephyr and install Python dependencies
Next, use west to create a workspace and fetch Zephyr together with its modules.
These commands use zephyrproject as the workspace name; you can choose
another name and location. You will also install Zephyr’s Python dependencies in
a Python virtual environment so they stay separate from your system Python
installation.
Create a new virtual environment:
python3 -m venv ~/zephyrproject/.venv
python3 -m venv ~/zephyrproject/.venv
Open a
cmd.exeor PowerShell terminal window as a regular user.cd %HOMEPATH% py -3.12 -m venv zephyrproject\.venv
cd $Env:HOMEPATH py -3.12 -m venv zephyrproject\.venv
Activate the virtual environment:
source ~/zephyrproject/.venv/bin/activate
source ~/zephyrproject/.venv/bin/activate
Note
Python’s virtual environment activation in PowerShell requires running a script itself, which needs to be allowed.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
zephyrproject\.venv\Scripts\activate.bat
zephyrproject\.venv\Scripts\Activate.ps1
Once activated your shell will be prefixed with
(.venv). The virtual environment can be deactivated at any time by runningdeactivate.Note
Remember to activate the virtual environment every time you start a new terminal session before working with Zephyr. If you don’t, commands such as
westwill not be found, or may run against a different Python environment, leading to confusing errors.Install west:
West is Zephyr’s workspace manager; the next commands use it to create and update the workspace.
pip install west
Get the Zephyr source code:
west initcreates a west workspace and cloneshttps://github.com/zephyrproject-rtos/zephyras its manifest repository.west updatethen fetches the various west projects (modules) listed in Zephyr’s west manifest (hardware abstraction layers (HALs), libraries, etc.).west init -m https://github.com/zephyrproject-rtos/zephyr ~/zephyrproject cd ~/zephyrproject west update
west init -m https://github.com/zephyrproject-rtos/zephyr ~/zephyrproject cd ~/zephyrproject west update
west init -m https://github.com/zephyrproject-rtos/zephyr zephyrproject cd zephyrproject west updateTip
To reduce disk space usage and avoid downloading unnecessary modules or vendor HALs during setup, you may configure Project Groups before running
west update.Export a Zephyr CMake package. This registers your current Zephyr checkout in CMake’s user package registry so
find_package(Zephyr)can locate it automatically when building applications.west zephyr-exportInstall Zephyr’s Python dependencies:
west packagesreads the Python requirements from the checked-out Zephyr workspace (including its modules), so the installed packages match the Zephyr version you fetched.west packages pip --install
west packages pip --install
cmd /c zephyr\scripts\utils\west-packages-pip-install.cmd
python -m pip install @((west packages pip) -split ' ')
Note
Installing these dependencies can downgrade or upgrade west itself.
Install the Zephyr SDK
The Zephyr Software Development Kit (SDK) contains toolchains for each of Zephyr’s supported architectures. Those toolchains include the compiler, assembler, linker, and other programs required to build Zephyr applications for your target hardware.
It also contains additional host tools, such as custom QEMU and OpenOCD builds that are used to emulate, flash and debug Zephyr applications.
Install the Zephyr SDK with west sdk install from the Zephyr repository:
cd ~/zephyrproject/zephyr
west sdk install
cd ~/zephyrproject/zephyr
west sdk install
cd %HOMEPATH%\zephyrproject\zephyr
west sdk install
cd $Env:HOMEPATH\zephyrproject\zephyr
west sdk install
Tip
Use command options to choose the SDK installation destination or install
only selected architecture toolchains. See west sdk install --help for
details.
Note
If you want to install Zephyr SDK without using the west sdk command,
please see Zephyr SDK installation.
Build the Blinky Sample
Note
Blinky is compatible with most, but not all, Supported Boards and Shields. If your board does not meet Blinky’s Requirements, then Hello World is a good alternative.
If you are unsure what name west uses for your board, use west boards to
list all boards Zephyr supports. Your board’s Board Catalog
also shows the exact board target name to pass to west build.
Build the Blinky with west build.
Replace <your-board-name> with the name of your board:
cd ~/zephyrproject/zephyr
west build -p always -b <your-board-name> samples/basic/blinky
cd ~/zephyrproject/zephyr
west build -p always -b <your-board-name> samples/basic/blinky
cd %HOMEPATH%\zephyrproject\zephyr
west build -p always -b <your-board-name> samples\basic\blinky
cd $Env:HOMEPATH\zephyrproject\zephyr
west build -p always -b <your-board-name> samples\basic\blinky
The -p always option forces a pristine build, which removes build output
from any previous configuration. This avoids stale files when you are getting
started. Later, you can use -p auto to let west build heuristics decide
when a pristine build may be needed. See west build -h for details.
Note
A board may contain one or multiple SoCs and each SoC may contain one or more
CPU clusters. When building for such boards, specify the SoC or CPU cluster
for which the sample must be built.
For example to build Blinky for the cpuapp core on
the nRF5340 DK the board must be provided as:
nrf5340dk/nrf5340/cpuapp. See also Board terminology for more
details.
Flash the Sample
Connect your board, usually via USB, and turn it on if there’s a power switch. If in doubt about what to do, check your board’s page in Supported Boards and Shields, as some boards require a specific setup or procedure to flash them.
Flash the sample with west flash. This programs the application you just built onto the connected board:
west flash
Note
You may need to install additional host tools
required by your board. The west flash command will print an error if any
required dependencies are missing.
Note
On Linux, you may need to configure udev rules before flashing with a debug probe for the first time. See Setting udev rules.
If you’re using blinky, the LED will start to blink as shown in this figure:
Phytec reel_board running blinky
Next Steps
Here are some next steps for exploring Zephyr:
Try other Samples and Demos
Learn about Application Development and the west tool
Find out about west’s flashing and debugging features, or more about Flashing and Hardware Debugging in general
Check out Beyond the Getting Started Guide for additional setup alternatives and ideas
Discover Resources for getting help from the Zephyr community
Asking for Help
Before asking for help, search this documentation, the Zephyr project’s GitHub discussions and issues, and Discord chat history. Your question may already have an answer there. You can also ask the chatbot available from every page of this documentation.
Mailing Lists: users@lists.zephyrproject.org is usually the right list to ask for help. Search archives and sign up here.
GitHub: Use GitHub discussions for questions and GitHub issues for bugs and feature requests.
Discord: You can join with this Discord invite.
When asking for help, include:
What you want to do
What you tried, including the commands you ran
What happened, including the full text output
Copy and paste text instead of sharing screenshots. For more than 5 lines of terminal output, source code, or logs on Discord or GitHub, create a snippet using three backticks.