ESP32 - supported types of microsd cards

sazanof
Posts: 39
Joined: Wed Sep 13, 2023 10:22 am
Contact:

ESP32 - supported types of microsd cards

Postby sazanof » Sun Dec 08, 2024 7:58 am

Hello. In my project, I use storing the web interface on a memory card. I couldn't get ESP 32 to recognize the card for a very long time. I've tried a lot of options.

regular microsd 1gb - error (type not supported)
16GB microsdhc memory card - CRC verification error
4gb MICROSDHC U-1 memory card - everything is fine
64gb Samsung evo microsd U-1 - everything is fine

(pullup-s enabled)

See file below

I don't need to use memory cards > 4gb

Q: What types of cards are supported in ESP32? I have not found clear information in order to definitely know what to buy. I would not like to play the lottery. Tell me, please :) .
Attachments
photo_2024-12-08_10-55-52.jpg
photo_2024-12-08_10-55-52.jpg (101.67 KiB) Viewed 6951 times

ESP_rrtandler
Posts: 52
Joined: Wed May 31, 2023 6:54 pm

Re: ESP32 - supported types of microsd cards

Postby ESP_rrtandler » Mon Dec 09, 2024 11:20 am

Hi sazanof,

There is no list of supported types of micro SD cards available.

To help you with the reliability of the SD card use could you share the particular type of ESP32 device (module) you are using and code fragment showing, how is the SD/MMC driver initialised, respective where does the error codes you have mentioned come from ?

Could you also clarify whether you have software enabled pull-ups on the respective GPIOs in ESP32, or physically attached (soldered) pull-up resistors ?

sazanof
Posts: 39
Joined: Wed Sep 13, 2023 10:22 am
Contact:

Re: ESP32 - supported types of microsd cards

Postby sazanof » Tue Feb 04, 2025 9:27 am

ESP_rrtandler! I'm sorry, I missed your answer!
SO, I tested many variants. Module I use are:
photo_2025-02-04_11-49-17.jpg
photo_2025-02-04_11-49-17.jpg (273.26 KiB) Viewed 6012 times
All modules based on ESP-WROOM-32 ESP32-WROOM-32UE

Code: Untitled.c Select all

Chip is ESP32-D0WD-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
.........
I (31) boot: ESP-IDF v5.4 2nd stage bootloader
I (31) boot: compile time Feb 4 2025 10:24:37
I (31) boot: Multicore bootloader
I (32) boot: chip revision: v3.1
I (35) boot.esp32: SPI Speed : 40MHz
I (39) boot.esp32: SPI Mode : DIO
I (42) boot.esp32: SPI Flash Size : 4MB
Adapter I using has 10K pullup resistors, also on my custom board pullup resistors exists too.
PIN MAP:

Code: Untitled.c Select all


CONFIG_EXAMPLE_FORMAT_IF_MOUNT_FAILED=y
CONFIG_EXAMPLE_FORMAT_SD_CARD=y
CONFIG_EXAMPLE_PIN_MOSI=23
CONFIG_EXAMPLE_PIN_MISO=19
CONFIG_EXAMPLE_PIN_CLK=18
CONFIG_EXAMPLE_PIN_CS=27
Cards I using:
photo_2025-02-04_12-00-54.jpg
photo_2025-02-04_12-00-54.jpg (116.74 KiB) Viewed 6012 times
Of course, I would like to save money and use 4-32GB memory cards.

Code example, I using - https://github.com/espressif/esp-idf/bl ... /README.md

Debug logs (LOG LEVEL DEBUG)

Full log since boot - https://gist.github.com/sazanof/8d0a382 ... a746232306

Code: Untitled.c Select all


D (725) spi_flash: trying chip: issi
D (729) spi_flash: trying chip: gd
D (732) spi_flash: trying chip: mxic
D (736) spi_flash: trying chip: winbond
D (740) spi_flash: trying chip: generic
I (744) spi_flash: detected chip: generic
I (748) spi_flash: flash io: dio
.....
I (815) main_task: Calling app_main()
I (825) example: Initializing SD card
I (825) example: Using SPI peripheral
D (835) spi: SPI2 use gpio matrix.
I (835) example: Mounting filesystem
D (835) sdspi_host: sdspi_host_init_device: SPI2 cs=27 cd=-1 wp=-1 wp_polarity:0
D (845) intr_alloc: Connected src 30 to int 5 (cpu 0)
D (855) spi_hal: eff: 400, limit: 26666k(/2), 0 dummy, -1 delay
D (855) spi_master: SPI2: New device added to CS5, effective clock: 400000 Hz
I (865) gpio: GPIO[27]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
D (875) spi_master: device5 locked the bus
D (875) spi_master: device5 release bus
D (885) sdspi_host: sdspi_host_start_command: cmd=52 error=0x107
D (885) sdmmc_cmd: cmd=52, sdmmc_req_run returned 0x107
D (895) spi_master: device5 locked the bus
D (895) spi_master: device5 release bus
D (925) spi_master: device5 locked the bus
D (925) spi_master: device5 release bus
D (945) spi_master: device5 locked the bus
D (945) spi_master: device5 release bus
D (945) sdmmc_sd: SDHC/SDXC card
D (945) spi_master: device5 locked the bus
D (945) spi_master: device5 release bus
D (945) sdspi_host: sdspi_host_start_command: cmd=5 error=0x107
D (955) sdmmc_cmd: cmd=5, sdmmc_req_run returned 0x107
D (955) sdmmc_io: sdmmc_init_io: io_send_op_cond (1) returned 0x107; not IO card
D (965) spi_master: device5 locked the bus
D (975) spi_master: device5 release bus
D (975) sdspi_host: data CRC set=1
D (975) sdspi_transaction: cmd=59, R1 response: command not supported
D (985) sdmmc_cmd: cmd=59, sdmmc_req_run returned 0x106
E (995) sdmmc_sd: sdmmc_init_spi_crc: sdmmc_send_cmd_crc_on_off returned 0x106
D (995) sdmmc_init: sdmmc_card_init: sdmmc_init_spi_crc returned 0x106
E (1005) vfs_fat_sdmmc: sdmmc_card_init failed (0x106).
I (1015) gpio: GPIO[27]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
E (1025) example: Failed to initialize the card (ESP_ERR_NOT_SUPPORTED). Make sure SD card lines have pull-up resistors in place.
I (1035) main_task: Returned from app_main()
Schematics I using on custom board:
photo_2025-02-04_12-17-06.jpg
photo_2025-02-04_12-17-06.jpg (171.14 KiB) Viewed 6012 times
Success connection of 64Gb card (log output): https://gist.github.com/sazanof/c7a9075 ... 7d137f2f43

Code: Untitled.c Select all


I (825) example: Initializing SD card
I (825) example: Using SPI peripheral
D (835) spi: SPI2 use gpio matrix.
I (835) example: Mounting filesystem
D (835) sdspi_host: sdspi_host_init_device: SPI2 cs=27 cd=-1 wp=-1 wp_polarity:0
D (845) intr_alloc: Connected src 30 to int 5 (cpu 0)
D (855) spi_hal: eff: 400, limit: 26666k(/2), 0 dummy, -1 delay
D (855) spi_master: SPI2: New device added to CS5, effective clock: 400000 Hz
I (865) gpio: GPIO[27]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
D (875) spi_master: device5 locked the bus
D (875) spi_master: device5 release bus
I (885) sdspi_transaction: cmd=52, R1 response: command not supported
D (895) sdmmc_cmd: cmd=52, sdmmc_req_run returned 0x106
D (895) spi_master: device5 locked the bus
......
D (945) sdmmc_sd: SDHC/SDXC card
D (945) spi_master: device5 locked the bus
D (945) spi_master: device5 release bus
I (945) sdspi_transaction: cmd=5, R1 response: command not supported
D (955) sdmmc_cmd: cmd=5, sdmmc_req_run returned 0x106
D (965) sdmmc_io: sdmmc_init_io: io_send_op_cond (1) returned 0x106; not IO card
D (965) spi_master: device5 locked the bus
D (975) spi_master: device5 release bus
D (975) sdspi_host: data CRC set=1
D (975) spi_master: device5 locked the bus
...
D (1025) sdmmc_common: host_ocr=0xff8000 card_ocr=0xc0ff8000
D (1025) sdmmc_common: sdmmc_card_init: host_ocr=00ff8000, card_ocr=c0ff8000
D (1035) sdmmc_init: sdmmc_card_init: card type is SD
...
D (1085) sdspi_host: Setting card clock to 10000 kHz
D (1095) spi_hal: eff: 10000, limit: 26666k(/2), 0 dummy, -1 delay
D (1095) spi_master: SPI2: New device added to CS5, effective clock: 10000000 Hz
...
D (1125) vfs_fat_sdmmc: using pdrv=0
...
I (1185) example: Filesystem mounted
Name: EC1S5
Type: SDHC
Speed: 10.00 MHz (limit: 10.00 MHz)
Size: 61120MB
CSD: ver=2, sector_size=512, capacity=125173760 read_bl_len=9
SSR: bus_width=1
I (1205) example: Opening file /sdcard/hello.txt
...
I (1755) example: File written
I (1765) example: Reading file /sdcard/nihao.txt
...
I (1805) example: Read from file: 'Nihao EC1S5!'
I (1805) gpio: GPIO[27]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1815) example: Card unmounted
I (1815) gpio: GPIO[23]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1825) gpio: GPIO[19]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1835) gpio: GPIO[18]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
But other SD cards - ERROR. Can you help me to solve problem?

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

Re: ESP32 - supported types of microsd cards

Postby nopnop2002 » Wed Feb 05, 2025 10:43 am

This may be related to the power consumption of the micro SD card.

Even Linux machines that use an SD card as a boot device, such as RaspberryPi, cannot be booted from an SD card that consumes a lot of power.

sazanof
Posts: 39
Joined: Wed Sep 13, 2023 10:22 am
Contact:

Re: ESP32 - supported types of microsd cards

Postby sazanof » Wed Feb 05, 2025 12:30 pm

This may be related to the power consumption of the micro SD card.

Even Linux machines that use an SD card as a boot device, such as RaspberryPi, cannot be booted from an SD card that consumes a lot of power.
I've never had any problems with RPI + Sd. I don't think Microsd cards are made so that they can't be used in 90% of cases. In addition, judging by the lack of sane information and solutions to problems with memory cards, we can conclude that either 90% of the cards are not supported by SPI, or 90% of ESP32 users do not use memory cards in their projects.

ESP_rrtandler
Posts: 52
Joined: Wed May 31, 2023 6:54 pm

Re: ESP32 - supported types of microsd cards

Postby ESP_rrtandler » Mon Feb 10, 2025 3:01 pm

Hi sazanof,

I wouldn't completely exclude the influence of the power supply. See the issue reported here
https://github.com/espressif/esp-idf/issues/12986
I do not see where does your board get the power. I assume the power supply in your case is provided by the ESP programmer. You may try to power the board using external 3.3V power supply and retry the failing cards as this approach helped the linked issue.

sazanof
Posts: 39
Joined: Wed Sep 13, 2023 10:22 am
Contact:

Re: ESP32 - supported types of microsd cards

Postby sazanof » Mon Feb 10, 2025 3:18 pm

Hi sazanof,

I wouldn't completely exclude the influence of the power supply. See the issue reported here
https://github.com/espressif/esp-idf/issues/12986
I do not see where does your board get the power. I assume the power supply in your case is provided by the ESP programmer. You may try to power the board using external 3.3V power supply and retry the failing cards as this approach helped the linked issue.

Hi! I am usin also LD33V (3,3V 1A) voltage regulator.
photo_2025-02-10_18-17-19.jpg
photo_2025-02-10_18-17-19.jpg (160.1 KiB) Viewed 5142 times
How much energy consumption of microsd?

ESP_rrtandler
Posts: 52
Joined: Wed May 31, 2023 6:54 pm

Re: ESP32 - supported types of microsd cards

Postby ESP_rrtandler » Mon Feb 10, 2025 5:41 pm

In the logs of the working / failing card, the main difference I see, is the error code returned by the library when it tries to get the characteristics of the card. While the working card responses with 0x106 which means not supported, the failing card case shows 0x107 which means timeout. Situation very similar to this was discussed here:
https://github.com/espressif/esp-idf/issues/8582
and here:
https://github.com/espressif/esp-idf/issues/8683

You may check the signal idle voltage levels at your SD card and if you have oscilloscope, then also the voltage range of the signal to exclude the cases described in the links above.

sazanof
Posts: 39
Joined: Wed Sep 13, 2023 10:22 am
Contact:

Re: ESP32 - supported types of microsd cards

Postby sazanof » Mon Feb 10, 2025 6:57 pm

You may check the signal idle voltage levels at your SD card and if you have oscilloscope, then also the voltage range of the signal to exclude the cases described in the links above.
I'm not good at working with an oscilloscope. Here's what happened to do. If I did something wrong, please tell me how to connect what and where to measure the signal.
1 channel - MISO
2 channel - MOSI

Tests with working card. the screenshots show the moment when the sd card is turned on and the moment when it is read.
microsd-ocs.png
microsd-ocs.png (336.96 KiB) Viewed 4894 times

sazanof
Posts: 39
Joined: Wed Sep 13, 2023 10:22 am
Contact:

Re: ESP32 - supported types of microsd cards

Postby sazanof » Sun Feb 16, 2025 10:31 am

Friends, do you have any idea what's wrong with sd cards or their software support? Check out the pictures above that I sent. So far, the problem has remained the same.

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot] and 13 guests