From e6e898e9deabf113fc75762ad32bb89a98513da3 Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Thu, 19 Jun 2025 12:00:52 +0800 Subject: [PATCH] fix(esp_system): fix the usage conditions of os_spinlock --- components/esp_hw_support/ldo/esp_ldo_regulator.c | 2 +- components/esp_hw_support/port/esp32p4/io_mux.c | 2 +- .../esp_system/include/esp_private/critical_section.h | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/esp_hw_support/ldo/esp_ldo_regulator.c b/components/esp_hw_support/ldo/esp_ldo_regulator.c index a9539e71d1..0d598bf6d1 100644 --- a/components/esp_hw_support/ldo/esp_ldo_regulator.c +++ b/components/esp_hw_support/ldo/esp_ldo_regulator.c @@ -27,7 +27,7 @@ typedef struct ldo_regulator_channel_t { } flags; } ldo_regulator_channel_t; -static portMUX_TYPE s_spinlock = portMUX_INITIALIZER_UNLOCKED; +static __attribute__((unused)) portMUX_TYPE s_spinlock = portMUX_INITIALIZER_UNLOCKED; static const uint32_t s_ldo_channel_adjustable_mask = LDO_LL_ADJUSTABLE_CHAN_MASK; // each bit represents if the LDO channel is adjustable in hardware diff --git a/components/esp_hw_support/port/esp32p4/io_mux.c b/components/esp_hw_support/port/esp32p4/io_mux.c index a5786377a1..17e9daa442 100644 --- a/components/esp_hw_support/port/esp32p4/io_mux.c +++ b/components/esp_hw_support/port/esp32p4/io_mux.c @@ -18,7 +18,7 @@ #define RTCIO_RCC_ATOMIC() PERIPH_RCC_ATOMIC() -static portMUX_TYPE s_io_mux_spinlock = portMUX_INITIALIZER_UNLOCKED; +static __attribute__((unused)) portMUX_TYPE s_io_mux_spinlock = portMUX_INITIALIZER_UNLOCKED; static soc_module_clk_t s_io_mux_clk_src = 0; // by default, the clock source is not set explicitly by any consumer (e.g. SDM, Filter) #if CONFIG_ULP_COPROC_ENABLED diff --git a/components/esp_system/include/esp_private/critical_section.h b/components/esp_system/include/esp_private/critical_section.h index 94ff9bf937..500dfd6ec2 100644 --- a/components/esp_system/include/esp_private/critical_section.h +++ b/components/esp_system/include/esp_private/critical_section.h @@ -22,7 +22,12 @@ extern "C" { #endif -#if (CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32P4) && !NON_OS_BUILD +/** + * In theory, OS_SPINLOCK should only be defined in a multi-core environment, because critical-section-related + * functions there take a lock as a parameter. In practice, since the Xtensa FreeRTOS port layer is the same + * for the ESP32, S3, and S2, the latter also requires a parameter in its critical-section-related functions. + */ +#if (!CONFIG_FREERTOS_UNICORE || CONFIG_IDF_TARGET_ARCH_XTENSA) && !NON_OS_BUILD /** * This macro also helps users switching between spinlock declarations/definitions for multi-/single core environments * if the macros below aren't sufficient.