Setup the Zephyr Development Environment¶
Set up the toolchain¶
This section describes how to set up the Zephyr development environment on your system. Follow one of the following guides for your host operating system:
For more latest information, see Development Environment Setup in Zephyr’s Getting Started Guide.
macOS¶
Follow the steps below to set up the development environment on macOS:
-
Install the dependencies:
brew install cmake ninja gperf ccache dfu-util dtc python3
-
Download and install the GNU ARM Embedded Toolchain. The
8-2019-q3-update
version is recommended. Then set the following environment variables:- Set
ZEPHYR_TOOLCHAIN_VARIANT
tognuarmemb
. - Set
GNUARMEMB_TOOLCHAIN_PATH
to the toolchain installation directory.
Type the following in your terminal to verify if the variables are set correctly:echo 'export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb' >> ~/.bash_profile echo 'export GNUARMEMB_TOOLCHAIN_PATH="<the toolchain installation directory>/gcc-arm-none-eabi-8-2019-q3-update"' >> ~/.bash_profile source ~/.bash_profile
echo $ZEPHYR_TOOLCHAIN_VARIANT echo $GNUARMEMB_TOOLCHAIN_PATH
- Set
-
Install
west
to manage the combination of repositories and versions:pip3 install west
-
Initialize west and clone the manifest repository
nrf52840-m2-devkit
:cd <sourcecode_root> mkdir m2devkit cd m2devkit west init -m https://github.com/makerdiary/nrf52840-m2-devkit west update
-
The Zephyr repository contains a list of required Python modules. Install these modules by entering the following command:
cd <sourcecode_root>/m2devkit pip3 install -r zephyr/scripts/requirements.txt
Linux¶
This guide covers Ubuntu version 18.04 LTS and later. These steps should be similar for other Linux distributions.
-
Ensure your host system is up to date before proceeding.
sudo apt update sudo apt upgrade
-
Use
apt
to install dependencies:sudo apt install --no-install-recommends git cmake ninja-build gperf \ ccache dfu-util device-tree-compiler wget \ python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \ make gcc gcc-multilib g++-multilib libsdl2-dev
-
Download and install the GNU ARM Embedded Toolchain. The
8-2019-q3-update
version is recommended. Then set the following environment variables:- Set
ZEPHYR_TOOLCHAIN_VARIANT
tognuarmemb
. - Set
GNUARMEMB_TOOLCHAIN_PATH
to the toolchain installation directory.
Type the following in your terminal to verify if the variables are set correctly:echo 'export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb' >> ~/.bashrc echo 'export GNUARMEMB_TOOLCHAIN_PATH="<the toolchain installation directory>/gcc-arm-none-eabi-8-2019-q3-update"' >> ~/.bashrc source ~/.bashrc
3. Install west, and make sureecho $ZEPHYR_TOOLCHAIN_VARIANT echo $GNUARMEMB_TOOLCHAIN_PATH
~/.local/bin
is on your PATH environment variable:pip3 install --user -U west echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc source ~/.bashrc
- Set
-
Initialize west and clone the manifest repository
nrf52840-m2-devkit
:cd <sourcecode_root> mkdir m2devkit cd m2devkit west init -m https://github.com/makerdiary/nrf52840-m2-devkit west update
-
The Zephyr repository contains a list of required Python modules. Install these modules by entering the following command:
cd <sourcecode_root>/m2devkit pip3 install --user -r zephyr/scripts/requirements.txt
Windows¶
The following instructions rely on Chocolatey. If Chocolatey isn’t an option, you can install dependencies from their respective websites and ensure the command line tools are on your PATH environment variable.
-
Open an Administrator
cmd.exe
window -
Disable global confirmation to avoid having to confirm installation of individual programs:
choco feature enable -n allowGlobalConfirmation
-
Use
choco
to install dependencies:choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' choco install ninja gperf python git
-
Open a new
cmd.exe
window as a regular user to continue. -
Install
west
to manage the combination of repositories and versions:pip3 install west
-
Initialize west and clone the manifest repository
nrf52840-m2-devkit
:cd <sourcecode_root> mkdir m2devkit cd m2devkit west init -m https://github.com/makerdiary/nrf52840-m2-devkit west update
-
The Zephyr repository contains a list of required Python modules. Install these modules by entering the following command:
cd <sourcecode_root>/m2devkit pip3 install -r zephyr/scripts/requirements.txt
Next steps¶
If everything works as expected, it's ready to build and run the Zephyr examples to verify the development environment setup.
The steps that are described in Build & Run a first example will walk you through verifying your setup with the simple Blinky example.
Reference¶
Create an Issue¶
Interested in contributing to this project? Want to report a bug? Feel free to click here: