From a30ee4748acef1a613f9c6d7e5aaf9bae0552e01 Mon Sep 17 00:00:00 2001 From: Manuel <71137295+mverch67@users.noreply.github.com> Date: Thu, 16 Apr 2026 22:06:01 +0200 Subject: [PATCH] fix LDO warnings --- .../crowpanel-advanced-p4/pins_arduino.h | 10 ++++++--- .../esp32p4/crowpanel-advanced-p4/variant.cpp | 22 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/variants/esp32p4/crowpanel-advanced-p4/pins_arduino.h b/variants/esp32p4/crowpanel-advanced-p4/pins_arduino.h index 6972d4362..0c259f6e1 100644 --- a/variants/esp32p4/crowpanel-advanced-p4/pins_arduino.h +++ b/variants/esp32p4/crowpanel-advanced-p4/pins_arduino.h @@ -80,14 +80,18 @@ static const uint8_t T13 = 15; #if defined(CROWPANEL_ADV_P4_50) #define BOARD_SDMMC_SLOT 1 +// Workaround for Arduino-ESP32 P4 SPI LDO auto-config on SDMMC slot0 pins (47/48). +// Use a valid GPIO (aligned to variant LoRa CS) and pre-tag it in initVariant() +// so setLDOPower() short-circuits. +#define BOARD_SDMMC_POWER_PIN 30 #else +#define BOARD_SDMMC_POWER_PIN 10 #define BOARD_SDMMC_SLOT 0 #endif #define BOARD_SDMMC_POWER_CHANNEL 4 -#define BOARD_SDMMC_POWER_PIN -1 -#define BOARD_SDMMC_POWER_ON_LEVEL LOW +#define BOARD_SDMMC_POWER_ON_LEVEL HIGH -// WIFI - ESP32C6 (CrowPanel Advanced P4) +// BT/WIFI - ESP32C6 #define BOARD_HAS_SDIO_ESP_HOSTED #ifdef CROWPANEL_ADV_P4_50 // CrowPanel Advanced P4 50": 4-bit SDIO on Slot 1 with GPIO 53/54/52/51/50/49 diff --git a/variants/esp32p4/crowpanel-advanced-p4/variant.cpp b/variants/esp32p4/crowpanel-advanced-p4/variant.cpp index cd089d329..b62e48ee0 100644 --- a/variants/esp32p4/crowpanel-advanced-p4/variant.cpp +++ b/variants/esp32p4/crowpanel-advanced-p4/variant.cpp @@ -2,14 +2,22 @@ #include "Arduino.h" #include -void earlyInitVariant() +extern "C" void initVariant(void) { #if defined(CONFIG_IDF_TARGET_ESP32P4) && defined(BOARD_SDMMC_POWER_PIN) - // Work around Arduino-ESP32 P4 SPI null-deref in setLDOPower() when this pin - // already has a bus type but no extra type string assigned. - if (perimanPinIsValid(BOARD_SDMMC_POWER_PIN) && perimanGetPinBusType(BOARD_SDMMC_POWER_PIN) != ESP32_BUS_TYPE_MAX && - perimanGetPinBusExtraType(BOARD_SDMMC_POWER_PIN) == nullptr) { - perimanSetPinBusExtraType(BOARD_SDMMC_POWER_PIN, ""); + // Ensure setLDOPower() exits early for this board family. + // On ESP32-P4, Arduino SPI may attempt SDMMC on-chip LDO setup when SPI uses + // pins that match SDMMC slot0 IOMUX pins (for example, GPIO 47/48 on p4-50). + // Pre-tagging BOARD_SDMMC_POWER_PIN as "SDMMC POWER" short-circuits that path. + if (perimanPinIsValid(BOARD_SDMMC_POWER_PIN)) { + pinMode(BOARD_SDMMC_POWER_PIN, OUTPUT); + digitalWrite(BOARD_SDMMC_POWER_PIN, BOARD_SDMMC_POWER_ON_LEVEL); + + if (perimanGetPinBusType(BOARD_SDMMC_POWER_PIN) != ESP32_BUS_TYPE_MAX && + perimanGetPinBusExtraType(BOARD_SDMMC_POWER_PIN) == nullptr) { + perimanSetPinBusExtraType(BOARD_SDMMC_POWER_PIN, ""); + } + perimanSetPinBusExtraType(BOARD_SDMMC_POWER_PIN, "SDMMC POWER"); } #endif -} \ No newline at end of file +}