djpx
November 20, 2024, 4:13pm
1
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:
opened 11:23AM - 21 Oct 20 UTC
RFC
platform: ESP32
Meta
## ESP32 Development Status
| PERIPHERAL | ESP32 | ESP32-S2 | ESP32-C3 | E… SP32-S3 | ESP32-C6 | ESP32-C2 |
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
| CPU | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| IRQ | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| TIMERS | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: |
| UART | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| I2C | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |:heavy_check_mark:| :x: | :x: |
| SPI FLASH | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
| SPI FLASH (Octal) | N/A | N/A | N/A | :heavy_check_mark: | N/A | N/A |
| SPI RAM | :heavy_check_mark: | :heavy_check_mark: | N/A | :heavy_check_mark: | N/A | :heavy_check_mark: |
| SPI RAM (Octal) | N/A | N/A | N/A | :heavy_check_mark: | N/A | N/A |
| SPI | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |:heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: |
| Cryptography | :x: | :x: | :x: | :x: | :x: | :x: |
| Wi-Fi | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| BLUETOOTH | :heavy_check_mark: | N/A | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
| IEEE802.15.4 | N/A | N/A | N/A | N/A| :x: | N/A |
| BT Mesh | :x: | :x: | :x: | :x: | :x: | :x: |
| GPIO | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| TWAI | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
| E-FUSE | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: | :heavy_plus_sign: |
| ADC | :heavy_check_mark:| :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: | :heavy_plus_sign: |
| ADC DMA | :heavy_plus_sign:| :heavy_plus_sign: | :heavy_plus_sign: | :heavy_plus_sign: | :heavy_plus_sign: | :heavy_plus_sign: |
| DAC | :heavy_check_mark: | :heavy_check_mark: | N/A | N/A | N/A | N/A |
| DAC DMA | :x: | :x: | N/A | N/A | N/A | N/A |
| MCPWM | :heavy_check_mark: | N/A | N/A | :heavy_check_mark: | :x: | N/A |
| LEDPWM | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: |
| PCNT | :heavy_check_mark: | :heavy_check_mark: | N/A | :heavy_check_mark: | :x: | N/A |
| TRNG | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
| LCD | N/A| N/A | N/A | :x: | N/A |N/A|
| DMA SPI | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: |
| WATCHDOG | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: |
| LOW POWER <br />Light sleep/Deep sleep | :heavy_plus_sign: | :heavy_plus_sign: | :heavy_plus_sign: | :heavy_plus_sign: | :heavy_plus_sign: | :heavy_plus_sign: |
| RTC | :x: | :x: | :x: | :x: | :x: | :x: |
| USB OTG | N/A | :x: | N/A | :x: | :x: | :x: |
| USB CDC | N/A | N/A | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: |
| ETH MAC | :heavy_check_mark: | N/A | N/A | N/A | N/A | N/A |
| SDHC | :heavy_check_mark: | N/A | N/A | :heavy_check_mark: | :x: | N/A |
| SDIO<br /> slave | :x: | :x: | :x: | :x: | :x: | :x: |
| CAMERA| N/A | N/A | N/A | :heavy_check_mark: | N/A | N/A |
| I2S | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
| ULP | N/A | :x: | N/A | :x: | :x: | :x: |
| SMP | :x: | N/A | N/A | :x: | N/A | N/A |
| AMP | :heavy_plus_sign: | N/A | N/A | :heavy_plus_sign: | N/A | N/A |
| FLASH ENCRYPTION | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: |
| DFS | :x: | :x: | :x: | :x: | :x: | :x: |
| OPENOCD | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: |
| MCUBOOT <br /> (Zephyr port, basic cyber security) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: |
| MCUBOOT <br /> (Espressif port, secure boot V2) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_plus_sign: |
Last update: 24/Sep/2024
- :heavy_check_mark: Feature is supported.
- :heavy_plus_sign: Work in progress.
- :x: Feature is not supported
- N/A: Not applicable to this device.
## Introduction
This RFC gives an overview of features and enhancements we plan to contribute for Espressif's ESP32 SoC device. It is not intended to be a proper roadmap but it gives some information about our effort on having more support for Zephyr RTOS.
### Problem description
Currently, ESP32 support consists of a few peripheral implementations as such as GPIO, UART and I2C, which limits device usage on Zephyr. There are missing peripheral drivers as such as WiFi and BLE that are very often requested by the community, but lack implementation.
### Proposed change
The proposal is to enable the powerful features that ESP32 SoC can offer, starting by bringing up WiFi subsystem. Meanwhile, we shall also work on developing yet unsupported peripheral drivers.
## Detailed RFC
### Initial Development
As there have already been some work on the WiFi bring up, a few modifications can be listed below describing initial requirements:
* Add ESP-IDF bootloader that handles SoC initialization (cache, MMU and partition tables). In long term, Zephyr's bootloader might be supported as well.
* Set XIP support by default to support ESP-IDF bootloader.
* Update linker script with proper flash, ram sections and symbols map.
* Update clock settings and entropy drivers.
* Add timer/counter support.
* Add NVS support.
* Add Wifi sources and network drivers.
### WiFi Driver and Network Integration
We have already implemented the WiFi adapter driver, which binds ESP32 internal WiFi to Zephyr's `ETHERNET_L2` layer. However, Zephyr has yet no support for WiFI SoC that runs as `non-offloaded` driver. It means that creating a network device following `subsys/net/l2/wifi/wifi_mgmt.c` API does not allow binding to the `ETHERNET_L2`. There is no such implementation for a `WIFI_L2` layer, which would allow using `WIFI_MGMT` API to integrate with `ETHERNET_L2` layer.
This will be addressed in another issue focused on network integration and user API.
### ESP32 HAL Module
To keep the folder structure in sync with other vendors, and to update ESP-IDF source to version 4.2, repository `modules/hal/esp-idf` shall be updated to `modules/hal/espressif`. Only minimal and necessary ESP-IDF sources shall be included in this repository, which includes source files, adapter layers and symbols to handle internal calls.
It will require changing `west.yml` to point to this new branch.
### Peripherals
The list below shows currently unsupported peripherals. We plan to start developing a few drivers in long term. Porting all the components is tricky due to FreeRTOS dependency in the current ESP-IDF implementation. SPI related code has special considerations due to dual-core SoC architecture and XIP (code execution from Flash). BLE and WiFi share the same RF radio, which implies handling their coexistence by hardware or software. ESP-IDF already takes care of everything but the porting is not straightforward. Also, we still have to analyze issues regarding multi-core support, SMP and power management.
* SMP
* DMA
* ULP
* ADC
* DAC
* CAN
* I2S
## Future Plans
### Future Devices
It is well known that Espressif has other chipsets on its platforms. We plan to add support to them as well when a reasonable ESP32 support on Zephyr is achieved for product level usage. For the time being, there are plans to add support for (not in any chronological order):
- ESP32-H2 (TBD)
- ESP32-H4 (TBD)
- ESP32-P4 (TBD)
More may be added to the list as Espressif adds more chipsets to its linecard.
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.
djpx
November 26, 2024, 2:45pm
3
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…