Skip to content

Crash when using SD library and no card is present #1815

Closed
@bHogan2

Description

@bHogan2

WDT error under circumstances described below.

Hardware

Hardware: ESP-12
Core Version: 2.1.0 stable
OS: Win10

Description

I'm using an I2C OLED and an SPI SD card. Under 2.0.0 I could run both together - as long as I started SPI before I2C. (A workaround) If I didn't, I could still read the card, but if there was NO CARD, the ESP would hang with a WDT error.

With 2.1.0 it doesn't matter which I do first, I'll always get the WDT hang.
Not sure why - but wanted to call the difference to your attention in case it rings a bell..

Settings in IDE

Module: Generic ESP8266 Module
Flash Size: 512k
CPU Frequency: 80Mhz
Flash Mode: DIO
Flash Frequency: 80Mhz
Upload Using: SERIAL
Reset Method: ck

Sketch

pseudocode of a big sketch . . .

void setup() {
EEPROM.begin(4096); // FWIW
SPI.begin()

if (! SD.begin(SD_SELECT)) { // triggers the WDT error if no card
Serial.println("No Card");
return NO_CARD;
}
SPI.end(); //done with SPI so close it so pins can be reused
///////////////////////////////////
Wire.pins(SDA_PIN, SCL_PIN); // define pins used for I2C
Wire.begin(); // HAD TO DO THIS AFTER SPI else "no card WDT reset"
}

void loop() {
}

#define SDA_PIN         0               // I2C SDA pin (pulled up) + PGM button and LED
#define SCL_PIN         2               // I2C SCL pin (pulled up)
#define MISO_PIN     12               // (when used) MISO (DO on SD)   
#define MOSI_PIN      13              // MOSI (DI on SD)
#define SCLK_PIN      14               // SCLK (SCK on SD)
#define CS_PIN           15              // SS (CS on SD)- always LOW that's OK - not used
// WAKE                16               // wired to RESET through cap to wake from sleep

### Debug Messages

WDT timeout






<bountysource-plugin>

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/32238017-crash-when-using-sd-library-and-no-card-is-present?utm_campaign=plugin&utm_content=tracker%2F14245935&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F14245935&utm_medium=issues&utm_source=github).
</bountysource-plugin>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions