Development Environment Setup on Linux

This section describes how to set up a Linux development system.

After completing these steps, you will be able to compile and run your Zephyr applications on the following Linux distributions:

  • Ubuntu 14.04 LTS 64-bit
  • Fedora 22 64-bit

Where needed, alternative instructions are listed for Ubuntu and Fedora.

Installing the Host’s Operating System

Building the project’s software components including the kernel has been tested on Ubuntu and Fedora systems. Instructions for installing these OSes are beyond the scope of this document.

Update Your Operating System

Before proceeding with the build, ensure your OS is up to date. On Ubuntu:

$ sudo apt-get update

On Fedora:

$ sudo dnf update

Installing Requirements and Dependencies

Install the following with either apt-get or dnf.

Install the required packages in a Ubuntu host system with:

$ sudo apt-get install git make gcc gcc-multilib g++ libc6-dev-i386 \

Install the required packages in a Fedora host system with:

$ sudo dnf group install "Development Tools"
$ sudo dnf install git make gcc glib-devel.i686 glib2-devel.i686 \
  glibc-static libstdc++-static glibc-devel.i686

Installing the Zephyr Software Development Kit

Zephyr’s SDK contains all necessary tools and cross-compilers needed to build the kernel on all supported architectures. Additionally, it includes host tools such as a custom QEMU and a host compiler for building host tools if necessary. The SDK supports the following architectures:

  • IA-32
  • ARM
  • ARC

Follow these steps to install the SDK on your Linux host system.

  1. Download the latest SDK self-extractable binary.

    Visit the Zephyr SDK archive to find all available SDK versions, including the latest version.

    Alternatively, you can use the following command to download the desired version, replacing <version> with the version number you wish to download.

    $ wget<version>-i686/zephyr-sdk-<version>
  2. Run the installation binary, follow this example:

    $ chmod +x zephyr-sdk-<version>
    $ ./zephyr-sdk-<version>

    There is no need for sudo if the SDK is installed in the current user’s home directory.

  3. Follow the installation instructions on the screen. The toolchain’s default installation location is /opt/zephyr-sdk/. To install in the default installation location, you will need to use sudo. It is recommended to install the SDK in your home directory and not in a system directory.

  4. To use the Zephyr SDK, export the following environment variables and use the target location where SDK was installed, type:

    $ export ZEPHYR_GCC_VARIANT=zephyr
    $ export ZEPHYR_SDK_INSTALL_DIR=<sdk installation directory>

To use the same toolchain in new sessions in the future you can set the variables in the file $HOME/.zephyrrc, for example:

$ cat <<EOF > ~/.zephyrrc
export ZEPHYR_GCC_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk