ESP32S3 SD-card init problem

Any bugs you encounter with Flowcode should be discussed here.
stefan.erni
Valued Contributor
Posts: 1265
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 236 times
Been thanked: 252 times

Re: ESP32S3 SD-card init problem

Post by stefan.erni »

Hi Ben

I'm not exactly sure what I'm doing wrong.
It worked with the ESP32-wroom. With the ESP32-S3,
I can't get it to work. I've already tried three different boards.
I also noticed that the green LED is flashing.
That happened with the SparkFun board, too.
IMG_6542.jpeg
IMG_6542.jpeg (34.62 KiB) Viewed 1117 times
IMG_6561.jpeg
IMG_6561.jpeg (68.18 KiB) Viewed 1117 times

BenR
Matrix Staff
Posts: 2252
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 618 times
Been thanked: 818 times

Re: ESP32S3 SD-card init problem

Post by BenR »

Hello,

I wonder if the LED is interfering with the signal e.g. adding capacitance and stopping the signal from running at full speed? Maybe worth removing it?

Aha I didn't know you were using my board ok I'll see if I can replicate the issue there for you and let you know. It's slightly different to the Matrix version and so there could be something minor that's causing it.

stefan.erni
Valued Contributor
Posts: 1265
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 236 times
Been thanked: 252 times

Re: ESP32S3 SD-card init problem

Post by stefan.erni »

Hi Ben

This is a very practical board and works well as a data logger if there is enough space and power available.
The SD card is also located in an easily accessible place and wired in 4-bit mode.
There is just one issue with initializing the card.

stefan.erni
Valued Contributor
Posts: 1265
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 236 times
Been thanked: 252 times

Re: ESP32S3 SD-card init problem

Post by stefan.erni »

Hi Ben

I got the touchscreen working. It's very easy to use. It's simple to start and stop a recording using the large touch fields.
unfortunately...
I'm still having problems with the SD card—it won't initialize.
CapTouchTFT_ONE_touch_rec_macro_.fcfx
(41.17 KiB) Downloaded 20 times
2026-07-13_16-15-45.PNG
2026-07-13_16-15-45.PNG (213.98 KiB) Viewed 534 times

BenR
Matrix Staff
Posts: 2252
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 618 times
Been thanked: 818 times

Re: ESP32S3 SD-card init problem

Post by BenR »

Hello,

Right sorry it's taken so long, I've finally built up a few displays and done some testing.

I've taken an SD card from our EB3 upstream as I know that works in 4-bit SD mode. For reference it's a 2GB Cloudisk card.

Using these connections and settings for the SD card it simply worked straight away.
Screenshot 2026-07-14 202951.png
Screenshot 2026-07-14 202951.png (17.82 KiB) Viewed 489 times
There is a problem if I try and initialise the card multiple times, it works the first time but then returns 255 every time after that. If I uninitialise the card as part of the loop then I can init over and over again and always get a return value of 0.

One problem that was reported via eBay was the S3 module itself. On my test board I have the ESP32-S3-N16R8. Which version of the S3 module do you have there? I know there are some minor differences to do with the PSRAM.
Screenshot 2026-07-14 203404.png
Screenshot 2026-07-14 203404.png (102.13 KiB) Viewed 489 times
Interestingly I'm using a version with the larger PSRAM which technically shouldn't be possible as it's using the pins assigned to the SD card. I wonder if the PSRAM has to be activated somewhere in the menu config and you are making use of it?

So maybe something to go on there?!

1) What version of the ESP32 S3 WROOM module is on your board?
2) Have you been into the menuconfig and changed any settings to do with RAM or PSRAM?

My test program is fairly basic and so it may not be invoking the PSRAM and hence why I'm not seeing the problem.

The guy on eBay suggested I buy the N8R2 version of the module from now on so as to avoid the issue entirely so I will certainly try and do this. I currently have stock of these so I could make one of these up for you for testing.

stefan.erni
Valued Contributor
Posts: 1265
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 236 times
Been thanked: 252 times

Re: ESP32S3 SD-card init problem

Post by stefan.erni »

Hi Ben

on my board is:
IMG_6641.jpeg
IMG_6641.jpeg (89.3 KiB) Viewed 462 times
No I did not use or change RAM / PSRAM

And yes ! It's working now.
I changed my touchprogram and add the sd-card with a single init the card.
I creat a file Test.txt and save the string "Hallo" to the file
CapTouchTFT_ONE_touch_rec_macro_.fcfx
(45.65 KiB) Downloaded 17 times
2026-07-15_08-38-14.PNG
2026-07-15_08-38-14.PNG (11.13 KiB) Viewed 462 times
And... You're right if the card send once 0 for ok you can not init again. You need to uninit first.
I tested with the stop button to uninit b4 I init again.I will include this into every sd-init loop.

One more question.
Is the `dc_touched` macro not an interrupt but a "normal" macro where everything is allowed and works?

BenR
Matrix Staff
Posts: 2252
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 618 times
Been thanked: 818 times

Re: ESP32S3 SD-card init problem

Post by BenR »

DC_Touched is called from the DisplayManager1::CheckForTouch call.

It's not an interrupt, you can put what you want in there but I would maybe treat it somewhat like an interrupt in that you essentially block the UI while you're in there.

stefan.erni
Valued Contributor
Posts: 1265
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 236 times
Been thanked: 252 times

Re: ESP32S3 SD-card init problem

Post by stefan.erni »

Hi Ben

The card doesn't work yet on the other two boards. Both have the S3-mini1.
The SparkFun board already has the card built in. Are there any differences between the ESP32-S3_DevKitC and ESP32-S3_MINI regarding the SD card?
2026-07-16_09-31-20.PNG
2026-07-16_09-31-20.PNG (1.1 MiB) Viewed 412 times

BenR
Matrix Staff
Posts: 2252
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 618 times
Been thanked: 818 times

Re: ESP32S3 SD-card init problem

Post by BenR »

The N4R2 only mentions IO26 being not available. I can't see there's any differences with the SD software library.

IO38, 39, 40, 47 has PHY USB associations on that device, you maybe have to disable the PHY USB functionality?

You could try forcing each pin to be in standard IO mode using code like this for each pin.

Code: Select all

// Define the configuration for IO38
    gpio_config_t io_conf = {
        .pin_bit_mask = ((1ULL << GPIO_NUM_33) | (1ULL << GPIO_NUM_34) | (1ULL << GPIO_NUM_38) | (1ULL << GPIO_NUM_39) | (1ULL << GPIO_NUM_40) | (1ULL << GPIO_NUM_47)),
        .mode = GPIO_MODE_INPUT_OUTPUT,          // Or GPIO_MODE_OUTPUT / GPIO_MODE_INPUT
        .pull_up_en = GPIO_PULLUP_DISABLE,
        .pull_down_en = GPIO_PULLDOWN_DISABLE,
        .intr_type = GPIO_INTR_DISABLE
    };
    
    // Apply configuration; this overrides the default USB-OTG routing
    gpio_config(&io_conf);
If that doesn't work then talking with Gemini it recommends using this to burn out the efuse just be careful it doesn't disable you from reflashing the board.

Code: Select all

espefuse.py -p PORT burn_efuse DIS_USB_OTG_DOWNLOAD_MODE 1
Might be worth seeing what Sparkfun have to say, we simply use the ESP32 IDF SD Mode driver behind the scenes so they should hopefully have knowledge of this.

stefan.erni
Valued Contributor
Posts: 1265
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 236 times
Been thanked: 252 times

Re: ESP32S3 SD-card init problem

Post by stefan.erni »

Hi Ben

I just pasted the C code as-is, but I think that was a mistake on my part. No error, but no improvement either.
2026-07-16_17-33-10.PNG
2026-07-16_17-33-10.PNG (37.18 KiB) Viewed 382 times
I tried the component for the SC/SDHC with SPI, and it works nice to creat a file and save a string.
But for my board, I need SPI1 for the display, SPI2 for the ADC, and 4-bit SDMMC for the SD card.
The ESP32-S3 mini can do that.
2026-07-16_17-33-40.PNG
2026-07-16_17-33-40.PNG (10.78 KiB) Viewed 382 times
2026-07-16_17-27-57.PNG
2026-07-16_17-27-57.PNG (8.69 KiB) Viewed 382 times

Post Reply