From ff5e91e332a4a01fb2cb542416213956f6a00e69 Mon Sep 17 00:00:00 2001 From: ainyan03 Date: Sat, 15 Aug 2026 09:40:22 +0000 Subject: [PATCH] Fix pinMode pulls not driven on ESP-IDF v6 (SOC_GPIO_SUPPORT_RTC_INDEPENDENT removed) ESP-IDF v6 removed the SOC_GPIO_SUPPORT_RTC_INDEPENDENT soc capability macro. pinMode treated the missing macro as 0, which routes RTC-capable pins through the RTC-domain pull path meant for the plain ESP32. On ESP32-S2/S3 (and other chips with independent digital pads) that path does not drive the pad pulls: input_pullup left the IO_MUX FUN_PU bit clear and the line did not rise. Map the capability to an internal LGFX_GPIO_RTC_INDEPENDENT macro that uses the SoC value when available and otherwise derives it from the build target: only the plain ESP32 needs the RTC path. Verified on ESP32-S3 (floating RTC-capable pin, ESP-IDF v6.0.1): input_pullup previously read back low with FUN_PU clear; with this fix the pull-up is driven and the pin reads high. No regression on v5.5.4 (macro still provided by the SoC caps) and no behavior change for the plain ESP32. --- src/lgfx/v1/platforms/esp32/common.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lgfx/v1/platforms/esp32/common.cpp b/src/lgfx/v1/platforms/esp32/common.cpp index 063e6a2..8a944f6 100644 --- a/src/lgfx/v1/platforms/esp32/common.cpp +++ b/src/lgfx/v1/platforms/esp32/common.cpp @@ -84,8 +84,16 @@ Original Source: #include #endif -#ifndef SOC_GPIO_SUPPORT_RTC_INDEPENDENT -#define SOC_GPIO_SUPPORT_RTC_INDEPENDENT 0 +// Whether the digital pads (pulls in IO_MUX) work independently of the RTC IO +// domain; only the plain ESP32 needs the RTC-domain path for RTC-capable pins. +// ESP-IDF v6 removed the SOC_GPIO_SUPPORT_RTC_INDEPENDENT macro, so derive +// the value from the build target when it is absent. +#if defined (SOC_GPIO_SUPPORT_RTC_INDEPENDENT) + #define LGFX_GPIO_RTC_INDEPENDENT SOC_GPIO_SUPPORT_RTC_INDEPENDENT +#elif defined (CONFIG_IDF_TARGET) && !defined (CONFIG_IDF_TARGET_ESP32) + #define LGFX_GPIO_RTC_INDEPENDENT 1 +#else + #define LGFX_GPIO_RTC_INDEPENDENT 0 #endif #if __has_include() @@ -416,7 +424,7 @@ namespace lgfx auto io_mux_val = *io_mux_reg; // & ~(FUN_PU_M | FUN_PD_M | SLP_PU_M | SLP_PD_M | MCU_SEL_M); #if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED - if (!SOC_GPIO_SUPPORT_RTC_INDEPENDENT && rtc_gpio_is_valid_gpio(gpio_num)) { + if (!LGFX_GPIO_RTC_INDEPENDENT && rtc_gpio_is_valid_gpio(gpio_num)) { rtc_gpio_deinit(gpio_num); if (mode == pin_mode_t::input_pulldown) { rtc_gpio_pulldown_en((gpio_num_t)pin); }