You may have heard of Zephyr, the open-source RTOS hosted on GitHub.  In fact, Zephyr claims to be the most popular open-source RTOS, with the highest commit traffic of any of its peers.

Zephyr's history is a bit complex, traversing several different companies and name changes before maturing to its current state.  In a nutshell, Zephyr was a product of Wind River.  During the time in which Wind River was a subsidiary of Intel, Zephyr was spun out as an independent open-source project and soon thereafter became a hosted project of the Linux Foundation.  This is a simplification, so if you want the detailed historical twists and turns the product has taken, you can read about it on Wikipedia.

Zephyr is supported by a wealth of partners, including Intel, Google, NXP, Texas Instruments, and others.  The technology is found in many different devices, everything from wearables, like hearing aids and smart watches, to IoT wireless devices and embedded applications of all types.

Zephyr supports many popular microcontroller instruction-set architectures, for example x86, ARM, ARC, RISC-V, Xtensa, and MIPS.  The kernel supports multi-threading, interrupt services, memory allocation, and power management, and can run in as little as 2KB memory.  There are several possible scheduling algorithms from which to choose.  Hardware is described by DeviceTree.  Support for hundreds of sensors is already integrated.  Finally, Zephyr makes safety and security a priority:

Intersection with ECs

Zephyr is a fully-featured RTOS with many use cases.  However, the use case I'd like to focus on here is its role running embedded controllers (ECs).  The EC is, and has been for many years, a key component in PC system architecture.  The EC's role is typically to handle tasks related to power sequencing, thermal control, keyboard support, and battery management, among other duties.

Several industry titans, Intel and Google first among them, envision a future where the PC EC design is standardized around Zephyr, as opposed to either a) a bunch of competing RTOS implementations, or b) a vendor-specific "round robin" scheduler.  The benefits of standardizing on Zephyr include:
  • agnostic to EC vendor
    • Zephyr supports all the major EC vendors, like Nuvoton, Microchip, ITE, etc.  PC manufacturers can therefore switch between EC vendors while keeping their same source code.  Zephyr acts like an abstraction layer.
  • modular architecture:  only compile in the components you need
    • If you need Wi-Fi support, it's there.  If not, you don't need to include it.  Same for many other modules, for example Bluetooth, USB, and CAN bus.

Zephyr at Google

Google has already transitioned their Chromebook designs away from their proprietary EC design to Zephyr.  Here are a couple good resources if you want to explore that further:

Zephyr at Intel

Intel has started an initiative they're calling Zephyr-based Embedded controller firmware.

Let's attempt a build in Ubuntu 22.04.  The process is quite involved, especially since the Intel documentation needs some updating.  The problem is that the Intel instructions reference the Zephyr Getting Started Guide, but the Getting Started Guide has significantly changed and Intel's instructions have not kept up.  For example, the Intel instructions refer to numbered steps in the Zephyr Getting Started Guide, but the Guide has removed all those numbers.  Anyway, in the end I did get it to work, more or less. 😀  Here's how:

Step 1: install some prereqs
sudo apt 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

Step 2: install west, make sure PATH is set
pip3 install --user -U west
echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
source ~/.bashrc
Step 3:  get Zephyr source
west init ~/zephyrproject
cd ~/zephyrproject
west update
Step 4:  Export a Zephyr CMake package
west zephyr-export
Step 5:  install Python dependencies
pip3 install --user -r ~/zephyrproject/zephyr/scripts/requirements.txt
Step 6:  download the SDK installer
cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.0/zephyr-sdk-0.16.0_linux-x86_64.tar.xz
wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.0/sha256.sum | shasum --check --ignore-missing

Step 7:  install the SDK
tar xvf zephyr-sdk-0.16.0_linux-x86_64.tar.xz
cd zephyr-sdk-0.16.0
./setup.sh
Step 8:  get some SPI tools
wget https://github.com/MicrochipTech/CPGZephyrDocs/tree/master/MEC152x/SPI_image_gen/spi_cfg.txt

wget https://github.com/MicrochipTech/CPGZephyrDocs/tree/master/MEC152x/SPI_image_gen/everglades_spi_gen_RomE


export EVERGLADES_SPI_GEN=~/SPI_image_gen/everglades_spi_gen_RomE

Step 9:  get the EC FW framework code
mkdir ~/sandbox
cd ~/sandbox
git clone https://github.com/intel/ecfw-zephyr
Step 10:  obtain dependencies and reinitialize
cd ecfw-zephyr
west init -l
Step 11: retrieve external dependencies
west update
Step 12:  update active path
cd ~/sandbox/zephyr_fork
source zephyr-env.sh
Step 13: build
cd ~/sandbox/ecfw-zephyr
# Building for ADL-S (on-board EC)
west build -c -p auto -b mec1501_adl

After all that, and some debugging of the build process, I did manage to get a zephyr.bin file:

The .bin files: (I am missing the ksc.bin file)

More Resources

Intel has announced that their Raptor Lake and Meteor Lake reference boards will have support for Zephyr-based EC FW.  So, we'll have to wait and see how plans for Zephyr to standardize ECs ultimately plays itself out.  Either way, I hope you'll agree that staying on top of industry developments such as this is important.

A good high-level introduction to the Zephyr project can be found:  Introduction to Zephyr (June 2021).  Not only that, but Zephyr's YouTube channel has over 100 videos on various aspects of the project.  Also:  Zephyr Project Documentation.

Follow the Zephyr project on Twitter:  https://twitter.com/ZephyrIoT.  Zephyr also has a Discord you can join.

My intent here was to raise awareness of the initiative to migrate ECs to Zephyr, and provide some resources where you can deepen your knowledge.  I hope you found this worthwhile!

Post a Comment

Be sure to select an account profile (e.g. Google, OpenID, etc.) before typing your comment!