How can I use Zephyr with ESP32-(S3) with Platformio

I just noticed that it seems to be possible to use Zephyr on ESP32 controllers and I might be interested to switch from FREERTOS to Zephyr to port code more easily.
Thats what I found:

And on github the say that they already support alot of features:

And I tried to see if it is possible by using creating a config:

[env:Zephyr-esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = zephyr
monitor_speed = 115200

But I get confirmed that it is currently not supported:

Error: This board doesn't support zephyr framework!

Does it really got no support or does PlatformIO just does not support it at the moment?

Is there a way which allows me to use it? Like a board configuration/definition or something like that?

Did someone tried it before I would be really thankful if someone could share their experience.

Open issue:

I found that too but there were no updates since years so I thought maybe they already added it. I guess it is still not implemented?
Can I do some own definitions to use Zephyr or is it not possible?
Thank you for your time.

There is a PlatformIO builder script for Zephyr since it’s used in e.g. STM32, but it’s by far one of the most complicated builder scripts in PlatformIO. You would need a very in-depth knowledge of PlatformIO, SCons, Zephyr, CMake and ESP32 in order to debug if something goes wrong or needs to be adapted for ESP32.

If the situation is like Nuttx, just use the build system provided with the OS and don’t try to reimplement it in Platformio. Use it as an editor and maybe a debugger - maybe - if you must.

The build system is already implemented in framework-zephyr/scripts/platformio

IMO what is missing is porting what is present in other platform to launch the build script in the framework as @maxgerhardt was saying.

It would be nice to have a separate git for the build scripts, for now it seems that they are not online somehow…

So I guess it is not recommended to use at the current state?

I started using Zephry as “Standalone” I think now I got the basics of it so I wonder is it such complicated because of the device trees?

If you build on top of west, is it then really that complicated or are there other stuff which you also need to do?

I can imagine that debugging may could be more difficult, but just building shouldn´t be that hard but I might be wrong.

How stable is the STM32 implementation, is it production ready or more like a beta? It could be interesting too since I could get an STM32 and develop it there and port it later to other controllers.

What is the current situation in Nuttx I never used that so far?

Indeed it would be nice too have, that would also make it easier to modify the build scripts.

Maybe we will see it in the future

Though I know Nuttx way better than Zephyr, from what I can tell Nuttx and Zephyr are similar in this regard; they are complete, small OSes that support multiple SOCs. They both have strong support for ESP32 (xtensa and RISC-V) and STM32 and others. They’re also relatively small, niche developer communities with tooling that works for them. It’s not like they NEED their editor to demand load libraries and change the build system to link against them; they consider that a solved problem.

I don’t think that Platformio/VSCode offer any support for Nuttx, so I think the parallel with Zephyr is fitting. It has its own build/configuration system, and a single command hocks up an image ready to flash to your board.

My point was that you don’t HAVE to have your RTOS supported by your editor. You could use VSCode – or any other editor you like – in one window and flip to another to build, upload, and run scripts on hardware.

One might correctly argue that this leaves out the “I” of “IDE”, but if you’re trying to preserve muscle memory for an editor you use and still get real work done on a chip/OS combination that you care about, it’s a viable way to work. Sounds easier than porting a pile of python and scons to a new OS, testing it on three hosts, and trying to get it committed to the master tree. “Not all things worth doing are worth doing well.”

You could probably bolt in running those scripts to do this in PlatformIO if you wanted to. Never tried. But we know that PlatformIO knows how to run different things for different targets, so we can infer there’s a table or script omewhere that tells it what command to run to build, what to run, what to debug, and so on.

I do the opposite. I work on a project that uses PIO as a build system. I use the editor I like and then script “pio run upload” in another window. The less I interact with PIO, generally, the happier I am.

For the question you didn’t ask, it’s not using FreeRTOS and they don’t use the Espressif or STM HALs. They write to bare metal. For the ESP case where they can’t get documentation for the radios, they run a binary blob for the BT/WiFi/Matter stacks and just hook the memory allocators, interrupt logic, etc.

If you like the UNIX kernel model and the ability to build and debug a lot of apps natively on a real computer (better for, say, a tiny web server than a custom DMA-heavy waveform generator, obviously), it’s nice to build and run your application-y code in the simulator and THEN move it to your tiny computer. Almost all the APIs use the POSIX API models, so if you’re comfortable with sockets and threads and file handles and other UNIX-y stuff, you’ll be at home.

This sounds a bit more of a commercial than I’d intended. I rally was just saying that Nuttx, like Zephyr, is a complete replacement for the freertos stuff that underlies ESP-IDF which, in turn, is what the Arduino layer is smeared upon. It’s OK to use VS-Code as your editor and use tiny scripts around make/cmake/openocd whatever to automate things.

The choices aren’t strictly between waiting for someone to build Zephyr support for PlatformIO or building it yourself. Using the part of PlatformIO you touch and the part of Zephyr (or any other OS/“framework” you need) is a totally legit survival strategy.