My Attempt at Getting Started with Zephyr Project OS on ESP32

Orange Pi Development Boards

Zephyr Project is a real-time operating systems for the Internet of Things (IoT) that was introduced in early 2016, and supported/hosted by the Linux Foundation.

It runs on a fairly large number of MCU boards from different architecture (x86, Arm, RISC-V, etc..), and Linaro even launched 96boards IoT compliant hardware like BLE Carbon board that are designed to run Zephyr Project. More recently, Linaro CEO revealed several commercial products are shipping with Zephyr Project OS, so I thought it might be a good time to give it a try.

Target Board – Wemos Lolin32

I only had STM32 Bluepill, and some ESP32 boards, so I went with the latter since it comes with WiFi. But instead of re-using some of my existing boards, I asked Banggood whether they could send Wemos Lolin32, which they did. They sell it for $7.99 shipped, but any other ESP32 board should do.

Click to Enlarge

The board comes with two headers that you can solder if you wish. I did it with the pins facing upwards, but if you want to insert the board into a breadboard, they should obviously face downwards instead.

Wemos Lolin32 Headers
Click to Enlarge

In the steps below, we’ll mostly use the micro USB port, the reset button, and on-board user LED connected to GPIO 5. I’ll follow the instructions on Zephyr website for Linux, and try a few samples. I’ll do so in Ubuntu 16.04, but they should be easy enough to adapt to Windows or Mac OS, as both OS are also supported.

Install ESP32 Toolchain and SDK

First let’s install xtensa-esp32 toolchain and dependencies in Ubuntu 16.04 64-bit:

We can now add the toolchain folder to the PATH in ~/.profile:

Logout and login again, and you should see the ESP32 toolchain in the path, e.g.:

Next up is the ESP-IDF SDK (Software Development Kit) which we can retrieve from github:

Once it’s done set up IDF_PATH by adding the following line to ~/.profile file:

Zephyr Project RTOS and Samples

The setup part specific to ESP32 is now done, so we can get Zephyr Project OS…

and install the dependencies:

CMake version 3.8.2 or higher is required, so let’s check our version:

Damn! The version in Ubuntu 16.04 is too old, so we need to upgrade it:

and now we can check the version again:

All good.

Since Espressif is constantly working on ESP-IDF SDK, the API may change, so we’re being asked to checkout a specific tag:

We can now export variable for ESP32. If you want to make those permanent add the three lines below to ~/.profile:

The project has many samples on offer, let’s try out some starting with Hello World:

Before you run the last line make sure you have connected your ESP32 board to your computer using a micro USB to USB cable. If everything goes well the output the command should look like:

So it will built the sample, and upload it to the board in one go. Now connect minicom or another serial terminal origram to /dev/ttyUSB0 with 115200 8N1 settings, and press the reset button on the board to check the output:


My next attempt was the Blinky “basic” sample. Should be easy enough, right? Nope. It does not build for ESP32 out of the box, and we are told to update board.h with:


After a directory search, I found ~/zephyr/boards/xtensa/esp32/board.h
(basically empty) and I added two lines for the variables above, based on my guess using samples for other platforms, and knowing the LED is connected to pin 5:

The way to build the app is the same as for all:

The program will load to the flash. As mentioned in the documentation there’s no output in the serial console, but I did not get the user LED to blink either. So I must not have edited board.h properly, and was not able to find a solution in the amount of time I had.

Final test: networking. Our Wemos Lolin32 board has WiFi and Blutetooth, so let’s try at least WiFi with the WiFi Sample:

But sadly the build ends with an error:

The documentation reads

Verify the board and chip you are targeting provide Wi-Fi support.

For instance, Atmel’s Winc1500 chip is supported on top of quark_se_c1000_devboard board.

I had assumed ESP32 WiFi + bluetooth chip would be supported, but there’s a board directory in the sample:

Oops, it looks like only that particular development board may support WiFi with Zephyr Project at this stage.

So Zephyr Project support for ESP32 does exist, but it seems basic/preliminary, and will not work without some serious work. It might be a better idea to get started with boards having their own specific samples like BBC micro:bit, Olimex STM32-E407, or Quark SE C1000 devboard mentioned above.

Leave a Reply

3 Comment threads
1 Thread replies
Most reacted comment
Hottest comment thread
4 Comment authors
halhertaPaul MMike Leist Recent comment authors
newest oldest most voted
Notify of
Mike Leist
Mike Leist

Perhaps you were just curious about Zephyr, but why not use FreeRTOS which is built specifically for the esp32 and runs on just as many boards as Zephyr. It becomes a simple case of using the Espressif instructions. Indeed, even simpler would be to use PlatformIO & FreeRTOS which work hand-in-hand by default.
You could also have saved some bother with Zephyr setup and used PlatformIO with that – it is a much neater, simpler and more robust way going forward.

Paul M

People in the UK who have a bbc microbit can run Zephyr on it. These boards are easy to get because they are given out in schools.


As someone who has used C for over 20 years now, I’d stick with Micropython on the ESP32. Not the IDF + FreeRTOS, Arduino, Zephyr, or anything else….MicroPython. It’s easier to use than C, fast enough and does almost everything (except Bluetooth). In fact, I’d choose the ESP32 as my platform of choice primarily because it has many relatively mature ports (Official, Loboris, WiPy) and because it does WiFi and Bluetooth (MicroPython support incoming)