How to install Zephyr RTOS without the non-sense

At the time of writing storage has become slightly expensive, this is a huge problem when dealing with Zephyr due to its notoriously high storage requirements. The main reason is that it tries to download all the modules for all the supported architectures, while usually you are only interested in developing for a single target architecture.

Unfortunately the official docs don’t know which is your target architecture and resolve it by providing a “one size fits all” solution, with the expected drawbacks in storage.

In this guide I’ll demonstrate how to create a T2 topology Zephyr workspace for an RP2040 board on Ubuntu. It can be extended to other boards if necessary.

Dependencies

Source

bash
sudo apt update
sudo apt upgrade
sudo apt-get 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 libmagic1

Install Zephyr SDK

Source

ℹ️ Note

This targets zephyr-sdk-1.0.1, change it according to your needs.

Download

bash
cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v1.0.1/zephyr-sdk-1.0.1_linux-x86_64_gnu.tar.xz

Extract

bash
tar xvf zephyr-sdk-1.0.1_linux-x86_64_gnu.tar.xz

Install

Copy the extracted files to the install directory,

ℹ️ Note

This targets /usr/local

Change it depending on your needs to one of the suggested locations.

bash
sudo mv zephyr-sdk-1.0.1 /usr/local

Register the package

bash
cd /usr/local/zephyr-sdk-1.0.1
sudo ./setup.sh

Follow the instructions.

Create the workspace

ℹ️ Note

I will assume the workspace is in $HOME/projects/zephyr-ws, change it according to your preferences.

Navigate your working directory to the workspace

bash
cd $HOME/projects/zephyr-ws

Initialize and activate the virtual environment

bash zephyr_ws $>
python3 -m venv .venv

Instantiate the virtual environment**

bash zephyr_ws $>
source .venv/bin/activate

! Important

Repeat this operation every time you open a new shell. To make sure everything is configured correctly check the (venv) symbol at the start of your shell.

Install west

bash (venv) zephyr_ws $>
pip install west
west packages pip --install

Create manifest

Create a folder for your manifest

bash zephyr_ws $>
mkdir manifest-repo

Inside the manifest-repo folder create a west.yml with the following content:

yaml manifest-repo/west.yml
manifest:
  remotes:
    - name: zephyrproject
      url-base: https://github.com/zephyrproject-rtos
  projects:
    - name: zephyr
      repo-path: zephyr
      remote: zephyrproject
      revision: "v4.4-branch"
      clone-depth: 1
      import:
        path-prefix: external
        name-allowlist:
          - cmsis_6
          - picolibc
          - hal_rpi_pico

You can select different modules depending on your board, check the official modules list (or alternativelly).

In general try to have at least the HAL for your board.

ℹ️ Note

This example targets Zephyr 4.4, change it depending on your needs

Initialize the workspace

Back in the workspace folder:

bash (venv) zephyr_ws $>
west init

This will create a .west folder, inside edit the config file to:

ini zephyr_ws/.west/config
[manifest]
path = manifest-repo
file = west.yml

This will pull all the dependencies of your project

bash (venv) zephyr_ws $>
west update

First project

You can now test the installation by compiling an example project:

Copy the blinky example from zephyr_ws/external/samples/basic/blinky

bash (venv) zephyr_ws $>
cp zephyr_ws/external/samples/basic/blinky .
cd blinky

Compile for your board

bash (venv) zephyr_ws/blinky $>
west build -b=rpi_pico

If it compiles successfully then you’re done.

To start a new project just create a new folder in zephyr_ws/ with the necessary file structure.