From 48b2925b9fd6c6e903bb19ec63d37103ffb38597 Mon Sep 17 00:00:00 2001 From: Mimoja Date: Mon, 19 Jun 2023 16:43:20 +0200 Subject: [PATCH] Reset flasher if it shared the pins with the SDCard If the flasher and the SDCard share pins the ESP will need to be reset to bring VSPI and HSPI back into sane states. Trying to reinit them without a reset will lead to heap corruptions. Better safe than sorry. Signed-off-by: Mimoja --- ESP32_AP-Flasher/src/serialap.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ESP32_AP-Flasher/src/serialap.cpp b/ESP32_AP-Flasher/src/serialap.cpp index db249e6a..80c6525e 100644 --- a/ESP32_AP-Flasher/src/serialap.cpp +++ b/ESP32_AP-Flasher/src/serialap.cpp @@ -748,6 +748,15 @@ void APTask(void* parameter) { #endif Serial.println("Please verify your wiring and try again!"); } +#ifdef HAS_SDCARD + if (SD_CARD_CLK == FLASHER_AP_CLK || + SD_CARD_MISO == FLASHER_AP_MISO || + SD_CARD_MOSI == FLASHER_AP_MOSI) { + Serial.println("Reseting in 30 seconds to restore SPI state!\n"); + flashCountDown(30); + ESP.restart(); + } +#endif } uint8_t attempts = 0;