Development Environment Setup on Linux¶
Important
This section only describes OS-specific setup instructions; it is the first step in the complete Zephyr Getting Started Guide.
This section describes how to set up a Zephyr development environment on the following Linux distributions:
- Ubuntu 16.04 LTS or 18.04 LTS 64-bit
- Fedora 28 64-bit
- Clear Linux
- Arch Linux
Where needed, instructions are given which only apply to specific Linux distributions.
Update Your Operating System¶
Ensure your host system is up to date before proceeding.
On Ubuntu:
sudo apt-get update
sudo apt-get upgrade
On Fedora:
sudo dnf upgrade
Note that having a newer version available for an installed package
(as reported by dnf check-update
) does not imply a subsequent
dnf upgrade
will install it, because it must also ensure dependencies
and other restrictions are satisfied.
On Clear Linux:
sudo swupd update
On Arch Linux:
sudo pacman -Syu
Install Requirements and Dependencies¶
Install the following packages using your system’s package manager. Note that both Ninja and Make are installed; you may prefer only to install one.
On Ubuntu:
sudo apt-get install --no-install-recommends git cmake ninja-build gperf \
ccache dfu-util device-tree-compiler wget \
python3-pip python3-setuptools python3-wheel xz-utils file make gcc \
gcc-multilib
On Fedora:
sudo dnf group install "Development Tools" "C Development Tools and Libraries"
dnf install git cmake ninja-build gperf ccache dfu-util dtc wget \
python3-pip xz file glibc-devel.i686 libstdc++-devel.i686
On Clear Linux:
sudo swupd bundle-add c-basic dev-utils dfu-util dtc \
os-core-dev python-basic python3-basic
On Arch:
sudo pacman -S git cmake ninja gperf ccache dfu-util dtc wget \
python-pip python-setuptools python-wheel xz file make
Important
Zephyr requires a recent version of CMake. Read through the rest of the section below to verify the version you have installed is recent enough to build Zephyr.
CMake version 3.13.1 or higher is required. Check what version you have by using
cmake --version
. If you have an older version, there are several ways
of obtaining a more recent one:
Use
pip
:pip3 install --user cmake
Download and install from the pre-built binaries provided by the CMake project itself in the CMake Downloads page. For example, to install version 3.13.1 in
~/bin/cmake
:mkdir $HOME/bin/cmake && cd $HOME/bin/cmake wget https://github.com/Kitware/CMake/releases/download/v3.13.1/cmake-3.13.1-Linux-x86_64.sh yes | sh cmake-3.13.1-Linux-x86_64.sh | cat echo "export PATH=$PWD/cmake-3.13.1-Linux-x86_64/bin:\$PATH" >> $HOME/.zephyrrc
Check your distribution’s beta or unstable release package library for an update.
Note
If you have installed a recent version of CMake using one of the approaches
listed above, you might want to uninstall the one provided by your
distribution’s package manager (apt
, dnf
, swupd
, pacman
,
etc.) in order to avoid version conflicts.
Install the Zephyr Software Development Kit (SDK)¶
Note
Use of the Zephyr SDK is optional, but recommended. Some of the requirements and dependencies in the previous section are only needed for installing the SDK.
Zephyr’s SDK contains all necessary tools and cross-compilers needed to build Zephyr on all supported architectures. Additionally, it includes host tools such as custom QEMU binaries and a host compiler for building host tools if necessary. The SDK supports the following target architectures:
- X86
- X86 IAMCU ABI
- Arm
- ARC
- Nios II
- Xtensa
- RISC-V
Follow these steps to install the SDK on your Linux host system.
Download the latest SDK as a self-extracting installation binary:
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.10.0/zephyr-sdk-0.10.0-setup.run
(You can change 0.10.0 to another version if needed; the Zephyr Downloads page contains all available SDK releases.)
Run the installation binary:
cd <sdk download directory> sh zephyr-sdk-0.10.0-setup.run
Important
If this fails, make sure Zephyr’s dependencies were installed as described in Install Requirements and Dependencies.
Follow the installation instructions on the screen. The toolchain’s default installation location is
/opt/zephyr-sdk/
, but it is recommended to install the SDK under your home directory instead.To install the SDK in the default location, you need to run the installation binary as root.
To use the Zephyr SDK, export the following environment variables and use the target location where SDK was installed:
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr export ZEPHYR_SDK_INSTALL_DIR=<sdk installation directory>
Building on Linux without the Zephyr SDK¶
The Zephyr SDK is provided for convenience and ease of use. It provides toolchains for all Zephyr target architectures, and does not require any extra flags when building applications or running tests. In addition to cross-compilers, the Zephyr SDK also provides prebuilt host tools. It is, however, possible to build without the SDK’s toolchain by using another toolchain as as described in the main Getting Started Guide document.
As already noted above, the SDK also includes prebuilt host tools. To use the
SDK’s prebuilt host tools with a toolchain from another source, keep the
ZEPHYR_SDK_INSTALL_DIR
environment variable set to the Zephyr SDK
installation directory. To build without the Zephyr SDK’s prebuilt host tools,
the ZEPHYR_SDK_INSTALL_DIR
environment variable must be unset before
you run source zephyr-env.sh
later on in the Getting Started Guide.
To make sure this variable is unset, run:
unset ZEPHYR_SDK_INSTALL_DIR