ESP32-WROOM with SD Breakout

Thread Starter

ry1808

Joined Aug 21, 2023
4
Hi everyone. Experienced electronics engineer here but just starting to dip my toe into the Arduino world. Working on a small project that requires logging data to as SD card. I am using a ESP32-WROOM-32UE board:

https://www.sparkfun.com/products/17381

I have wired this up (correctly I believe) to:

https://www.sparkfun.com/products/13743

Running through some very basic code I keep getting errors and the card will not initialize (the card is formatted to FAT32). Here is the sample code:

Code:
#include <SPI.h>
#include <SD.h>

const int chipSelectPin = 17; // Change to your CS pin

void setup() {
  Serial.begin(115200);
  pinMode(chipSelectPin, OUTPUT);

  if (!SD.begin(chipSelectPin)) {
    Serial.println("SD card initialization failed!");
    while (1);
  }

  Serial.println("SD card initialized successfully!");
}

void loop() {
  // This loop can be left empty for the test

  delay(1000); // Add a delay if desired
}
The output error I get is:

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode: DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:13260
load:0x40080400,len:3028
entry 0x400805e4
E (159) esp_core_dump_flash��ɕ�dump data check failed:
Calculated checksum='3936a6d4'
Image checksum='ffffffff'
SD card initialization failed!

As I've been going through this project I've learnt a lot about the Arduino ecosystem and overcome so (probably basic for everyone here) issues but this is the first one that has really stumped me.

Thanks in advance for any advice.
 

geekoftheweek

Joined Oct 6, 2013
1,429
Have you tried different SD cards? There are some that have caused people trouble in the past. It seems from what I found on a quick search that devices 2TB and over do not support SPI mode.

It's not usually that the cards don't support SPI, but the steps to actually enter SPI mode are slightly different than they are supposed to be. I would imagine the Arduino library would account for the differences somehow, but I could be wrong.

There have also been strange behaviors and issues with SD cards sharing the SPI with another device. It seems you pretty much have to dedicate the SPI to a single SD card only.
 

Thread Starter

ry1808

Joined Aug 21, 2023
4
Thanks for the reply.

I have a SanDisk 32GB FAT32 formatted card in there. I imagine it's a decent card so hopefully wouldn't be an issue. I will try a different card, see how that goes.

I will be dedicating the SPI bus to the SD card only.
 

geekoftheweek

Joined Oct 6, 2013
1,429
I have a SanDisk 32GB FAT32 formatted card in there. I imagine it's a decent card so hopefully wouldn't be an issue. I will try a different card, see how that goes.

I will be dedicating the SPI bus to the SD card only.
I would think being a somewhat modest size card of a major manufacturer that it should work.

I'll admit I never attempted this myself, but have done some research over the years a few times thinking I would try something. While not all diagrams show it many do show a pull up resistor connected to the DO of the SD breakout / MISO connection.
https://onlinedocs.microchip.com/pr...tml?GUID-48879CB2-9C60-4279-8B98-E17C499B12AF

Other than that I don't know. Unfortunately the error messages don't give much detail as to what the problem is other than it's not working.
 

geekoftheweek

Joined Oct 6, 2013
1,429
Actually I did notice the breakout board includes level shifting circuitry to be able to use it with a 5V micro. The ESP32 operates on 3.3V which has me wondering...

Can you show a schematic of your connections? Nevermind the pull up comment in the earlier post.
 

geekoftheweek

Joined Oct 6, 2013
1,429
The same error messages were present on my initial test with 3V3 connected to the VCC of the SD card board, 5V has never directly been connected to the ESP board.
If you connect 5V to VCC of the SD card board there is a good chance you will get 5V out of the DO pin of the breakout board. I'm not sure exactly how your board is designed so maybe I'm wrong on this, but that is usually the purpose of a level shifter.
 

geekoftheweek

Joined Oct 6, 2013
1,429
Actually in your initial post what part of the output is normal boot messages and what part is SD related? Everything looked like boot messages the first time around, but now I'm curious.
 
Top