Zephyr: ESP32 development overview

Created on 21 Oct 2020  路  6Comments  路  Source: zephyrproject-rtos/zephyr

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.

  • SPI
  • SPIRAM
  • BLE
  • SMP
  • DMA
  • ULP
  • ADC
  • DAC
  • CAN
  • I2S

Future Plans

Future Devices

It is well knwon that Espressif has other chipsets on its plataforms. 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-S2
  • ESP32-S3
  • ESP32-C2
  • ESP32-C3

More may be added to the list as Espressif adds more chipsets to its linecard.

RFC ESP32

Most helpful comment

The items below are implemented. We are a few days of creating a PR for that:

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.

We also expect to start working on SPI for the next days.

All 6 comments

I think after ESP32 WiFi Support a lot of basic stuff will be fixed, like WIFI, Flash Cache, 2nd Stage Bootloader support, Linker script updates.

Could you please tell us if there are any progress on the mentioned drivers ? (for cooperation and avoiding double efforts)

The items below are implemented. We are a few days of creating a PR for that:

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.

We also expect to start working on SPI for the next days.

Could you add some information when/if Secure Boot and Flash Encryption are planned?

Could you add some information when/if Secure Boot and Flash Encryption are planned?

Sure. I can't tell you exactly when but It is on our development backlog. I'll update you once we get ourselves working on it.

Note, I added support for ESP32-S2 in a PR a while back but since it required an unreleased version of the ESP-IDF (v4.2), I stalled work on that PR until Espressif officially released a stable version supporting ESP32-S2; If youre changing the way Zephyr includes the IDF, Id be happy to adapt my PR for it but I think waiting on a stable release of it would be best
(https://github.com/zephyrproject-rtos/zephyr/pull/27246)

@mrrosen

I added support for ESP32-S2 in a PR a while back

Thank you for update.

If youre changing the way Zephyr includes the IDF, Id be happy to adapt my PR for it but I think waiting on a stable release of it would be best

Yes we are trying to align with stable ESP-IDF v4.2 release timelines. Release candidate is due sometimes next week, followed up by formal announcement. Regarding how Zephyr consumes IDF, some discussions are on-going at https://github.com/zephyrproject-rtos/esp-idf/issues/4, we will keep you posted on your PR for ESP32-S2 support based on our progress.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carlescufi picture carlescufi  路  5Comments

DeltaEvo picture DeltaEvo  路  4Comments

pdunaj picture pdunaj  路  3Comments

qianfan-Zhao picture qianfan-Zhao  路  3Comments

karstenkoenig picture karstenkoenig  路  4Comments