xtensa/espressif: Update common-source integration for Xtensa devices

This commit updates the common-source integration for Xtensa-based
Espressif devices (ESP32, ESP32-S2, and ESP32-S3). This is part of a larger
common-source update split by architecture for better maintainability.

Major components updated:
- IRQ allocator refactoring with intr_alloc integration
- Common-source drivers (GPIO, RMT, I2C, SPI, UART, etc.)
- Espressif components upgrade to release/master.b-test
- Peripheral drivers (ADC, PWM, LEDC, MCPWM, PCNT, Temperature Sensor, etc.)
- Wireless adapters (Wi-Fi and BLE)
- esp_timer migration to the common-source path for Xtensa devices
- Common-source power management implementation (auto-sleep and wakeup paths)
- Board defconfigs for all Xtensa Espressif boards
- SMP support improvements for ESP32-S3
- Critical section handling improvements

Key architectural changes:
- IRQ Allocator: The new interrupt allocator enables multiple mapping
  options from interrupt sources to CPU interrupts, providing flexibility
  required by modern peripherals. Although this introduces breaking changes
  to the interrupt handling API, the required ARCH_MINIMAL_VECTORTABLE
  Kconfig option is explicitly checked during startup to ensure proper
  configuration. This validation prevents runtime issues from configuration
  mismatches.
- Xtensa-specific interrupt handling via esp_xtensa_intr.c providing
  NuttX-native implementations of xt_ints_on/off and interrupt handlers,
  avoiding conflicts with NuttX's core Xtensa macros.
- Timer/RTC unification: ESP32/ESP32-S2/ESP32-S3 move from chip-specific
  RTC/RT-timer code to common-source Espressif integration, including
  esp_timer_adapter/esp_rtc paths and the required bringup/defconfig updates.
- Power management consolidation: Xtensa PM follows the common-source
  implementation, including common-source auto-sleep behavior, UART/Wi-Fi
  wakeup coordination, and tickless-safe sleep flow compatibility.

Note: This is a large commit to maintain bisectability. Breaking the
changes into smaller commits would result in non-building intermediate
states across the common-source infrastructure update.

Tested configurations:
- All defconfigs were tested, including `ostest`.

Signed-off-by: Tiago Medicci Serrano <tiago.medicci@espressif.com>
This commit is contained in:
Tiago Medicci Serrano
2026-02-27 15:06:57 -03:00
committed by Xiang Xiao
parent c64b95ccbf
commit c17e16eaed
621 changed files with 11436 additions and 53138 deletions
@@ -15,6 +15,9 @@ CONFIG_ARCH_BOARD_ESP32_ETHERNETKIT=y
CONFIG_ARCH_CHIP="esp32"
CONFIG_ARCH_CHIP_ESP32=y
CONFIG_ARCH_CHIP_ESP32WROVER=y
CONFIG_ARCH_IRQ_TO_NDX=y
CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
CONFIG_ARCH_NUSER_INTERRUPTS=2
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_XTENSA=y
CONFIG_BOARD_LOOPSPERMSEC=16717
@@ -16,12 +16,15 @@ CONFIG_ARCH_CHIP="esp32"
CONFIG_ARCH_CHIP_ESP32=y
CONFIG_ARCH_CHIP_ESP32WROVER=y
CONFIG_ARCH_IRQBUTTONS=y
CONFIG_ARCH_IRQ_TO_NDX=y
CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
CONFIG_ARCH_NUSER_INTERRUPTS=2
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_XTENSA=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
CONFIG_ESP32_GPIO_IRQ=y
CONFIG_ESP32_UART0=y
CONFIG_ESPRESSIF_GPIO_IRQ=y
CONFIG_EXAMPLES_BUTTONS=y
CONFIG_FS_PROCFS=y
CONFIG_HAVE_CXX=y
@@ -14,6 +14,9 @@ CONFIG_ARCH_BOARD_ESP32_ETHERNETKIT=y
CONFIG_ARCH_CHIP="esp32"
CONFIG_ARCH_CHIP_ESP32=y
CONFIG_ARCH_CHIP_ESP32WROVER=y
CONFIG_ARCH_IRQ_TO_NDX=y
CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
CONFIG_ARCH_NUSER_INTERRUPTS=2
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_XTENSA=y
CONFIG_BOARD_LOOPSPERMSEC=16717
@@ -14,6 +14,9 @@ CONFIG_ARCH_BOARD_ESP32_ETHERNETKIT=y
CONFIG_ARCH_CHIP="esp32"
CONFIG_ARCH_CHIP_ESP32=y
CONFIG_ARCH_CHIP_ESP32WROVER=y
CONFIG_ARCH_IRQ_TO_NDX=y
CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
CONFIG_ARCH_NUSER_INTERRUPTS=2
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_XTENSA=y
CONFIG_BOARD_LOOPSPERMSEC=16717
@@ -7,7 +7,6 @@
#
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
CONFIG_ALARM_ARCH=y
CONFIG_ARCH="xtensa"
CONFIG_ARCH_BOARD="esp32-ethernet-kit"
CONFIG_ARCH_BOARD_COMMON=y
@@ -15,6 +14,9 @@ CONFIG_ARCH_BOARD_ESP32_ETHERNETKIT=y
CONFIG_ARCH_CHIP="esp32"
CONFIG_ARCH_CHIP_ESP32=y
CONFIG_ARCH_CHIP_ESP32WROVER=y
CONFIG_ARCH_IRQ_TO_NDX=y
CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
CONFIG_ARCH_NUSER_INTERRUPTS=2
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_XTENSA=y
CONFIG_BOARD_LOOPSPERMSEC=16717
@@ -53,5 +55,4 @@ CONFIG_START_YEAR=2011
CONFIG_SYSLOG_BUFFER=y
CONFIG_SYSTEM_NSH=y
CONFIG_TIMER=y
CONFIG_TIMER_ARCH=y
CONFIG_UART0_SERIAL_CONSOLE=y
@@ -14,11 +14,13 @@ CONFIG_ARCH_BOARD_ESP32_ETHERNETKIT=y
CONFIG_ARCH_CHIP="esp32"
CONFIG_ARCH_CHIP_ESP32=y
CONFIG_ARCH_CHIP_ESP32WROVER=y
CONFIG_ARCH_IRQ_TO_NDX=y
CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
CONFIG_ARCH_NUSER_INTERRUPTS=2
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_XTENSA=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
CONFIG_ESP32_RT_TIMER=y
CONFIG_ESP32_UART0=y
CONFIG_EXAMPLES_ALARM=y
CONFIG_FS_PROCFS=y
@@ -15,6 +15,9 @@ CONFIG_ARCH_BOARD_ESP32_ETHERNETKIT=y
CONFIG_ARCH_CHIP="esp32"
CONFIG_ARCH_CHIP_ESP32=y
CONFIG_ARCH_CHIP_ESP32WROVER=y
CONFIG_ARCH_IRQ_TO_NDX=y
CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
CONFIG_ARCH_NUSER_INTERRUPTS=2
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_XTENSA=y
CONFIG_BOARD_LOOPSPERMSEC=16717
@@ -38,6 +38,8 @@
#include <nuttx/himem/himem.h>
#include "esp32_partition.h"
#include "espressif/esp_gpio.h"
#include "esp32_start.h"
#ifdef CONFIG_USERLED
# include <nuttx/leds/userled.h>
@@ -55,10 +57,6 @@
# include "esp32_board_wdt.h"
#endif
#ifdef CONFIG_ESP32_RT_TIMER
# include "esp32_rt_timer.h"
#endif
#ifdef CONFIG_ESP32_SPIFLASH
# include "esp32_board_spiflash.h"
#endif
@@ -76,7 +74,11 @@
#endif
#ifdef CONFIG_RTC_DRIVER
# include "esp32_rtc_lowerhalf.h"
# include "espressif/esp_rtc.h"
#endif
#ifdef CONFIG_ESPRESSIF_HR_TIMER
# include "espressif/esp_hr_timer.h"
#endif
#ifdef CONFIG_MMCSD_SPI
@@ -162,14 +164,6 @@ int esp32_bringup(void)
}
#endif
#ifdef CONFIG_ESP32_RT_TIMER
ret = esp32_rt_timer_init();
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize RT timer: %d\n", ret);
}
#endif
#ifdef CONFIG_ESPRESSIF_BLE
ret = esp32_ble_initialize();
if (ret)
@@ -187,13 +181,21 @@ int esp32_bringup(void)
}
#endif
#ifdef CONFIG_ESPRESSIF_HR_TIMER
ret = esp_hr_timer_init();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: esp_hr_timer_init() failed: %d\n", ret);
}
#endif
/* First, register the timer drivers and let timer 1 for oneshot
* if it is enabled.
*/
#ifdef CONFIG_TIMER
#if defined(CONFIG_ESP32_TIMER0) && !defined(CONFIG_ESP32_RT_TIMER)
#if defined(CONFIG_ESP32_TIMER0) && !defined(CONFIG_ESPRESSIF_HR_TIMER)
ret = esp32_timer_initialize("/dev/timer0", TIMER0);
if (ret < 0)
{
@@ -282,7 +284,7 @@ int esp32_bringup(void)
#ifdef CONFIG_RTC_DRIVER
/* Instantiate the ESP32 RTC driver */
ret = esp32_rtc_driverinit();
ret = esp_rtc_driverinit();
if (ret < 0)
{
syslog(LOG_ERR,
@@ -37,7 +37,7 @@
#include <nuttx/irq.h>
#include <arch/irq.h>
#include "esp32_gpio.h"
#include "espressif/esp_gpio.h"
#include "esp32-ethernet-kit.h"
@@ -58,7 +58,7 @@
uint32_t board_button_initialize(void)
{
esp32_configgpio(BUTTON_BOOT, INPUT_FUNCTION_3 | PULLUP);
esp_configgpio(BUTTON_BOOT, INPUT_FUNCTION_3 | PULLUP | CHANGE);
return 1;
}
@@ -79,13 +79,13 @@ uint32_t board_buttons(void)
int i = 0;
int n = 0;
bool b0 = esp32_gpioread(BUTTON_BOOT);
bool b0 = esp_gpioread(BUTTON_BOOT);
for (i = 0; i < 10; i++)
{
up_mdelay(1); /* TODO */
bool b1 = esp32_gpioread(BUTTON_BOOT);
bool b1 = esp_gpioread(BUTTON_BOOT);
if (b0 == b1)
{
@@ -131,38 +131,6 @@ uint32_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, void *arg)
{
int ret;
DEBUGASSERT(id == 0);
int irq = ESP32_PIN2IRQ(BUTTON_BOOT);
if (NULL != irqhandler)
{
/* Make sure the interrupt is disabled */
esp32_gpioirqdisable(irq);
ret = irq_attach(irq, irqhandler, arg);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: irq_attach() failed: %d\n", ret);
return ret;
}
gpioinfo("Attach %p\n", irqhandler);
gpioinfo("Enabling the interrupt\n");
/* Configure the interrupt for rising and falling edges */
esp32_gpioirqenable(irq, CHANGE);
}
else
{
gpioinfo("Disable the interrupt\n");
esp32_gpioirqdisable(irq);
}
return OK;
return esp_gpio_irq(BUTTON_BOOT, irqhandler, arg);
}
#endif