Zephyr Hello World

Throw-Away Environment

docker run -it --rm --name=zephyr_hello ubuntu:18.04 bash
apt update
apt install -y apt-transport-https ca-certificates gnupg software-properties-common wget
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'

apt update
apt install -y python3 virtualenv git curl cmake pkg-config flex bison gperf ninja-build

git clone git://git.kernel.org/pub/scm/utils/dtc/dtc.git ~/dtc
cd ~/dtc
make && make install PREFIX=/

groupadd -g 1000 attie
useradd -u 1000 -g 1000 -m attie
usermod -aG sudo attie
echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

Then detach with ^P, ^Q...

docker exec -it -u attie zephyr_hello bash

Setup Toolchain

Steps from 3rd Party Toolchain - GNU ARM Embedded

mkdir ~/arm-gcc
curl 'https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/8-2019q3/RC1.1/gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2' | bzip2 -d | tar -xvC ~/arm-gcc

Setup West & Checkout

Steps from Getting Started

virtualenv -p python3.6 ~/venv
. ~/venv/bin/activate

pip install west
west init ~/hello
pip install -r ~/hello/zephyr/scripts/requirements.txt

export ZEPHYR_TOOLCHAIN_VARIANT="gnuarmemb"
export GNUARMEMB_TOOLCHAIN_PATH="$(readlink -f ~/arm-gcc/gcc-arm-none-*)"

cd ~/hello/zephyr/
git checkout zephyr-v1.14.0
. zephyr-env.sh
cmake -B build -GNinja -DBOARD=reel_board samples/hello_world

Re-Activate

. ~/venv/bin/activate
export ZEPHYR_TOOLCHAIN_VARIANT="gnuarmemb"
export GNUARMEMB_TOOLCHAIN_PATH="$(readlink -f ~/arm-gcc/gcc-arm-none-*)"

cd ~/hello/zephyr/
. zephyr-env.sh

Build

ninja -C build

Flash

ninja -C build flash

Note

At this point I got bored of addressing problems, and walked away.