It’s been a while since I’ve had time to play with the Zephyr RTOS project and the project has evolved greatly since so I thought I’d document the process I went through while playing with Zephyr 2.1 on Fedora using the Fedora native cross toolchains rather than the various ones suggested by the Zephyr Project docs.
I’m going to do a couple of posts in this series to break it up a little. This first one will be getting a generic build environment setup. I’ll go into more detail on the specific devices I’m playing with but the ones I have handy are ARM Cortex-M based so that’s what I’ll be focusing on even though Zephyr RTOS supports numerous architectures.
As before it’s worth reading the latest Zephyr Getting Started guide. This time around I’m using a AWS aarch64 a1.medium instance running a Fedora 31 cloud instance but I’ve also tested that a DigitalOcean Droplet with 2Gb RAM works with the later ZephyrRTOS releases too.
Once you have a Fedora instance up and running install the required dependencies:
# disable modularity, mostly just slows things down. $ sudo sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/fe*mod* # install core utils, git and cross compilers $ sudo dnf install git-core cmake ninja-build gperf dfu-util dtc \ xz file python3-pyelftools arm-none-eabi-gcc-cs python3-pip # requirements for the west (Zephyr meta build tool) $ sudo dnf install python3-colorama python3-configobj \ python3-configobj python3-docopt python3-pykwalify \ python3-dateutil python3-colorama python3-docopt \ python3-pykwalify python3-packaging
We now install west:
$ pip3 install --user --upgrade west
We now have key build dependencies installed so we can initialise west and clone key repos using west (this will take a little while to do an initial clone run):
$ west init zephyr $ cd zephyr $ west update
Setup the Zephyr environment for cross compiling with the distribution tools:
$ export ZEPHYR_TOOLCHAIN_VARIANT=cross-compile $ export CROSS_COMPILE=/usr/bin/arm-none-eabi- $ source zephyr-env.sh $ mkdir builds
By default the above uses the git master branch of the Zephyr git repo. If you wish to use a stable branch you can just check it out. The latest stable release is, currently, 2.1 so to use this you can check out the stable branch:
$ git checkout v2.1-branch
With this we now have a Zephyr RTOS development environment setup for building for Arm Cortex-M based devices on Fedora using the distribution’s cross toolchains.