From 669e2fb29d611245aaee8d1d2c01a40d47af01a4 Mon Sep 17 00:00:00 2001 From: DatanoiseTV <6614616+DatanoiseTV@users.noreply.github.com> Date: Fri, 8 May 2026 21:38:41 +0200 Subject: [PATCH] sleep: arm deep-sleep hold so per-pin gpio_hold_en actually holds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit doDeepSleep called gpio_hold_en for BUTTON_PIN and LORA_CS, but the ESP-IDF API contract is that gpio_hold_en alone only covers light sleep — deep sleep additionally requires gpio_deep_sleep_hold_en once before esp_deep_sleep_start to arm the holds across the deep- sleep boundary. Without it the pins float in DSLP, which on some boards leaks current through LORA_CS and on others triggers spurious wake from a noisy button line. --- src/sleep.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sleep.cpp b/src/sleep.cpp index 792781f6d0d..c4b858f221c 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -370,6 +370,14 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false, bool skipSaveN pinMode(I2C_SCL, ANALOG); #endif +#ifdef ARCH_ESP32 + // gpio_hold_en alone only retains pin state during light sleep on ESP32; + // for the holds to apply during deep sleep the global enable must be + // armed once before esp_deep_sleep_start. Without this, BUTTON_PIN and + // LORA_CS float in DSLP and can leak current or trigger spurious activity. + gpio_deep_sleep_hold_en(); +#endif + console->flush(); cpuDeepSleep(msecToWake); }