Esp32S3 : SD Spi driver with 16Gb SD Card does not work

ThomasESP32
Posts: 229
Joined: Thu Jul 14, 2022 5:15 am

Esp32S3 : SD Spi driver with 16Gb SD Card does not work

Postby ThomasESP32 » Thu Oct 17, 2024 8:58 pm

Good evening,

I have used the SDSpi example with Esp32S3 in order to mount a FileSystem with VFS on a 2Gb micro SD Card (Spi)
using standard SPI mode.

Everything is ok.

Now, I have changed the SDCard with a 16Gb microSD Card and the same example/driver does not
manage to mount the FileSystem.
Do you think this example is compatible with SDHC 16Gb cards ? Do you think I have to change the
standard SPI mode with a quad spi mode ? If the answer is yes, how do do that ?

At the moment I don't understand why the driver does not manage to mount my 16Gb card....

Please help me

Do you have any ideas please ?
Best regards,

Thomas TRUILHE

nopnop2002
Posts: 112
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: Esp32S3 : SD Spi driver with 16Gb SD Card does not work

Postby nopnop2002 » Thu Oct 17, 2024 11:21 pm

I tried 16GB and 64GB SD card media, and they can be mounted without any problems.

There may be a problem with the SD card media.

SD card media with large current consumption may not be able to be mounted.

The current consumption of SD card media is a very important factor, but unfortunately it is not listed in the product datasheet.


Code: Select all

I (345) main_task: Started on CPU0
I (355) main_task: Calling app_main()
I (355) example: Initializing SD card
I (355) example: Using SPI peripheral
I (355) example: Mounting filesystem
I (365) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (415) sdspi_transaction: cmd=5, R1 response: command not supported
I (635) example: Filesystem mounted
Name: SL16G
Type: SDHC/SDXC
Speed: 20.00 MHz (limit: 20.00 MHz)
Size: 15193MB
CSD: ver=2, sector_size=512, capacity=31116288 read_bl_len=9
SSR: bus_width=1

Code: Select all

I (345) main_task: Started on CPU0
I (355) main_task: Calling app_main()
I (355) example: Initializing SD card
I (355) example: Using SPI peripheral
I (355) example: Mounting filesystem
I (365) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (415) sdspi_transaction: cmd=5, R1 response: command not supported
I (575) example: Filesystem mounted
Name: SB16G
Type: SDHC/SDXC
Speed: 20.00 MHz (limit: 20.00 MHz)
Size: 15193MB
CSD: ver=2, sector_size=512, capacity=31116288 read_bl_len=9
SSR: bus_width=1

Code: Select all

I (345) main_task: Started on CPU0
I (355) main_task: Calling app_main()
I (355) example: Initializing SD card
I (355) example: Using SPI peripheral
I (355) example: Mounting filesystem
I (365) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (415) sdspi_transaction: cmd=5, R1 response: command not supported
I (635) example: Filesystem mounted
Name: DR064
Type: SDHC/SDXC
Speed: 20.00 MHz (limit: 20.00 MHz)
Size: 59136MB
CSD: ver=2, sector_size=512, capacity=121110528 read_bl_len=9
SSR: bus_width=1

You may be able to mount it by setting format_if_mount_failed to true.

Code: Select all

#ifdef CONFIG_EXAMPLE_FORMAT_IF_MOUNT_FAILED
        .format_if_mount_failed = true,
#else
        .format_if_mount_failed = false,
#endif // EXAMPLE_FORMAT_IF_MOUNT_FAILED

ThomasESP32
Posts: 229
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32S3 : SD Spi driver with 16Gb SD Card does not work

Postby ThomasESP32 » Fri Oct 18, 2024 4:20 am

Perfect, so you managed to mount your SDHC card with the sdspi standard example
using the SPI mode ?

Without any change in the code ?
Could you please confirm ? I will try with another card or check if the option format_if_mount_fail is set to false or true.

Best regards,

nopnop2002
Posts: 112
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: Esp32S3 : SD Spi driver with 16Gb SD Card does not work

Postby nopnop2002 » Fri Oct 18, 2024 5:06 am

SD cards have different names depending on their capacity.

An SDHC card is an SD card with a capacity of 4GB to 32GB.

All 16GB media are SDHC.

https://www.coolblue.nl/en/advice/compa ... cards.html

ThomasESP32
Posts: 229
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32S3 : SD Spi driver with 16Gb SD Card does not work

Postby ThomasESP32 » Fri Oct 18, 2024 5:42 am

Thank you for your answer. Here is what I get with the SDHC SD Card :

I (311) main_task: Started on CPU0
I (321) main_task: Calling app_main()
I (321) example: Initializing SD card
I (321) example: Using SPI peripheral
I (331) example: Mounting filesystem
I (331) gpio: GPIO[48]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (341) sdspi_transaction: cmd=52, R1 response: command not supported
E (391) sdmmc_sd: sdmmc_init_spi_crc: sdmmc_send_cmd_crc_on_off returned 0x106
E (391) vfs_fat_sdmmc: sdmmc_card_init failed (0x106).
I (391) gpio: GPIO[48]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
E (401) example: Failed to initialize the card (ESP_ERR_NOT_SUPPORTED). Make sure SD card lines have pull-up resistors in place.
I (411) main_task: Returned from app_main()

And here is what I get with the 2Gb SD Card :

I (311) main_task: Started on CPU0
I (321) main_task: Calling app_main()
I (321) example: Initializing SD card
I (321) example: Using SPI peripheral
I (331) example: Mounting filesystem
I (331) gpio: GPIO[48]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (381) sdspi_transaction: cmd=5, R1 response: command not supported
I (571) example: Filesystem mounted
Name: SA02G
Type: SDSC
Speed: 20.00 MHz (limit: 20.00 MHz)
Size: 1898MB
CSD: ver=1, sector_size=512, capacity=3887104 read_bl_len=10
SSR: bus_width=1


And in attachment a photo of the two SD Cards...
Do you have any idea please ? I use the sdspi example without changing anything except the format_if_mount_fail to true.
(So use of Standard SPI mode, 4 pins).

Best regards,

Thomas
Attachments
20241018_073800.jpg
20241018_073800.jpg (1.49 MiB) Viewed 1350 times

ThomasESP32
Posts: 229
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32S3 : SD Spi driver with 16Gb SD Card does not work

Postby ThomasESP32 » Fri Oct 18, 2024 6:26 am

Now, I have tried to connect my micro SDcard in quad spi mode (Using the sdspi example)
but I don't understand how to connect it...

I think in quad Spi mode, my card should have the following signals :
-CLK
-DATA0
-DATA1
-DATA2
-DATA3
-CS
Could you confirm ?

I have defined these pins in the firmware, but on the schematic of my micro SD adapter board,
I have connected :
- CLK signal on the CLK pin.
- Data 0 on the DATA 0 pin.
- Data 1 on the DATA 1 pin.
- Data 2 on the DATA 2 pin.
- Data 3 on the DATA 3 pin.

But where to connect the chip select signal ???
In attachment the schematic of my microSD adapter board.

Do you have any idea where to connect the CS signal ?

-Data
Attachments
adapter.jpg
adapter.jpg (111.19 KiB) Viewed 1309 times

nopnop2002
Posts: 112
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: Esp32S3 : SD Spi driver with 16Gb SD Card does not work

Postby nopnop2002 » Fri Oct 18, 2024 10:34 am

>Do you have any idea please ?

Please use another SD card media from a reliable brand.
We can't find any other solution.

MicroController
Posts: 1734
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Esp32S3 : SD Spi driver with 16Gb SD Card does not work

Postby MicroController » Fri Oct 18, 2024 11:52 am

You can try limiting the SPI clock speed to some low value, like 1MHz, and see if things improve.

ThomasESP32
Posts: 229
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32S3 : SD Spi driver with 16Gb SD Card does not work

Postby ThomasESP32 » Mon Oct 21, 2024 6:44 am

Good morning,

I have tried with a 1MHz frequency and things are the same.
I get exactly the same message and the card is not mounted.

So I will follow your recommandation and try with a card from another brand.

Thank you for your help,

best regards,

Thomas TRUILHE

ThomasESP32
Posts: 229
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32S3 : SD Spi driver with 16Gb SD Card does not work

Postby ThomasESP32 » Mon Oct 21, 2024 7:13 am

Using the second example sdmmc, it seams that I can mount the 2Go and the 16Go card.
It is perfect thank you.

Who is online

Users browsing this forum: Baidu [Spider] and 245 guests