Setting up the environment¶
To start developing with the Zephyr RTOS, you should set up your development environment. This guide shows you how to set up a command-line Zephyr development environment on Ubuntu, macOS, or Windows manually.
For more details, please refer to the latest Zephyr Project Documentation
Select and Update OS¶
Install available updates for your operating system:
Select Start > Settings > Update & Security > Windows Update. Click Check for updates and install any that are available.
On macOS Mojave or later, select System Preferences... > Software Update. Click Update Now if necessary.
On other versions, see this Apple support topic.
Install dependencies¶
Next, you’ll install some host dependencies using your package manager.
The current minimum required version for the main dependencies are:
Tool | Min. Version |
---|---|
CMake | 3.20.5 |
Python | 3.10 |
Devicetree compiler | 1.4.6 |
We use Chocolatey to install dependencies here. If Chocolatey isn’t an option, you can install dependencies from their respective websites and ensure the command line tools added in your PATH
environment variable.
-
Open a
cmd.exe
window as Administrator. To do so, press the Windows key Win , typecmd.exe
, right-click the result, and choose Run as Administrator. -
Disable global confirmation to avoid having to confirm the installation of individual programs:
-
Use
choco
to install the required dependencies: -
Close the window and open a new
cmd.exe
window as a regular user to continue.
Tip
To check the list of installed packages and their versions, run the following command:
-
Install Homebrew:
-
After the Homebrew installation script completes, follow the on-screen instructions to add the Homebrew installation to the path.
-
On macOS running on Apple Silicon, this is achieved with:
-
On macOS running on Intel, use the command for Apple Silicon, but replace
/opt/homebrew/
with/usr/local/
.
-
-
Use
brew
to install the required dependencies: -
Add the Homebrew Python folder to the path, in order to be able to execute
python
andpip
as wellpython3
andpip3
.
Tip
To check the versions of these dependencies installed, run the following command:
-
If using an Ubuntu version older than 22.04, it is necessary to add extra repositories to meet the minimum required versions for the main dependencies listed above. In that case, download, inspect and execute the Kitware archive script to add the Kitware APT repository to your sources list. A detailed explanation of
kitware-archive.sh
can be found here kitware third-party apt repository: -
Use
apt
to install the required dependencies: -
Verify the versions of the main dependencies installed on your system by entering:
Get the code and install Python dependencies¶
To help you quickly build and run the samples on iMX RT1011 Nano Kit, the primary imxrt1011-nanokit repository contains the Zephyr manifest repositories, additional hardware drivers and tested samples, etc.
Tip
It is easy to run into Python package incompatibilities when installing dependencies at a system or user level. This situation can happen, for example, if working on multiple Zephyr versions or other projects using Python on the same machine.
For this reason it is suggested to use Python virtual environments.
-
Open a
cmd.exe
terminal window as a regular user -
Change to
%HOMEPATH%
and create a workspace folderzephyrproject
where all the required repositories will be cloned. -
Create a new virtual environment:
-
Activate the virtual environment:
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 working.
-
Install west:
-
Get the source code:
-
Enter the following commands to clone the project repositories:
After all the repositories updated, your workspace folder now looks similar to this:
-
Export a Zephyr CMake package. This allows CMake to automatically load boilerplate code required for building Zephyr applications.
-
Zephyr’s
scripts\requirements.txt
file declares additional Python dependencies. Install them withpip
.
- Open up a terminal window.
- Change to
~
and create a workspace folderzephyrproject
where all the required repositories will be cloned. -
Create a new virtual environment:
-
Activate the virtual environment:
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 working.
-
Install west:
-
Get the source code:
-
Enter the following commands to clone the project repositories:
After all the repositories updated, your workspace folder now looks similar to this:
-
Export a Zephyr CMake package. This allows CMake to automatically load boilerplate code required for building Zephyr applications.
-
Zephyr’s
scripts\requirements.txt
file declares additional Python dependencies. Install them withpip
.
- Open up a terminal window.
- Change to
~
and create a workspace folderzephyrproject
where all the required repositories will be cloned. -
Use
apt
to install Pythonvenv
package: -
Create a new virtual environment:
-
Activate the virtual environment:
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 working.
-
Install west:
-
Get the source code:
-
Enter the following commands to clone the project repositories:
After all the repositories updated, your workspace folder now looks similar to this:
-
Export a Zephyr CMake package. This allows CMake to automatically load boilerplate code required for building Zephyr applications.
-
Zephyr’s
scripts\requirements.txt
file declares additional Python dependencies. Install them withpip
.
Install the Zephyr SDK¶
The Zephyr Software Development Kit (SDK) contains toolchains for each of Zephyr’s supported architectures, which include a compiler, assembler, linker and other programs required to build Zephyr applications.
It also contains additional host tools, such as custom QEMU and OpenOCD builds that are used to emulate, flash and debug Zephyr applications.
- Open a
cmd.exe
terminal window as a regular user. -
Download the Zephyr SDK bundle:
-
Extract the Zephyr SDK bundle archive:
Note
It is recommended to extract the Zephyr SDK bundle at one of the following locations:
%HOMEPATH%
%PROGRAMFILES%
The Zephyr SDK bundle archive contains the
zephyr-sdk-<version>
directory and, when extracted under%HOMEPATH%
, the resulting installation path will be%HOMEPATH%\zephyr-sdk-<version>
. -
Run the Zephyr SDK bundle setup script:
Note
You only need to run the setup script once after extracting the Zephyr SDK bundle.
You must rerun the setup script if you relocate the Zephyr SDK bundle directory after the initial setup.
-
Download and verify the Zephyr SDK bundle:
If your host architecture is 64-bit ARM (Apple Silicon, also known as M1), replace
x86_64
withaarch64
in order to download the 64-bit ARM macOS SDK. -
Extract the Zephyr SDK bundle archive:
Note
It is recommended to extract the Zephyr SDK bundle at one of the following locations:
$HOME
$HOME/.local
$HOME/.local/opt
$HOME/bin
/opt
/usr/local
The Zephyr SDK bundle archive contains the
zephyr-sdk-<version>
directory and, when extracted under$HOME
, the resulting installation path will be$HOME/zephyr-sdk-<version>
. -
Run the Zephyr SDK bundle setup script:
Note
You only need to run the setup script once after extracting the Zephyr SDK bundle.
You must rerun the setup script if you relocate the Zephyr SDK bundle directory after the initial setup.
-
Download and verify the Zephyr SDK bundle:
If your host architecture is 64-bit ARM (for example, Raspberry Pi), replace
x86_64
withaarch64
in order to download the 64-bit ARM Linux SDK. -
Extract the Zephyr SDK bundle archive:
Note
It is recommended to extract the Zephyr SDK bundle at one of the following locations:
$HOME
$HOME/.local
$HOME/.local/opt
$HOME/bin
/opt
/usr/local
The Zephyr SDK bundle archive contains the
zephyr-sdk-<version>
directory and, when extracted under$HOME
, the resulting installation path will be$HOME/zephyr-sdk-<version>
. -
Run the Zephyr SDK bundle setup script:
Note
You only need to run the setup script once after extracting the Zephyr SDK bundle.
You must rerun the setup script if you relocate the Zephyr SDK bundle directory after the initial setup.
-
Install udev rules, which allow you to flash most Zephyr boards as a regular user: