ESP32 - supported types of microsd cards

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

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 3661 times

ESP_rrtandler
Posts: 34
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: 31
Joined: Wed Sep 13, 2023 10:22 am

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 2722 times
All modules based on ESP-WROOM-32 ESP32-WROOM-32UE
  1. Chip is ESP32-D0WD-V3 (revision v3.1)
  2. Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
  3. .........
  4. I (31) boot: ESP-IDF v5.4 2nd stage bootloader
  5. I (31) boot: compile time Feb  4 2025 10:24:37
  6. I (31) boot: Multicore bootloader
  7. I (32) boot: chip revision: v3.1
  8. I (35) boot.esp32: SPI Speed      : 40MHz
  9. I (39) boot.esp32: SPI Mode       : DIO
  10. 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:
  1. CONFIG_EXAMPLE_FORMAT_IF_MOUNT_FAILED=y
  2. CONFIG_EXAMPLE_FORMAT_SD_CARD=y
  3. CONFIG_EXAMPLE_PIN_MOSI=23
  4. CONFIG_EXAMPLE_PIN_MISO=19
  5. CONFIG_EXAMPLE_PIN_CLK=18
  6. 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 2722 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
  1. D (725) spi_flash: trying chip: issi
  2. D (729) spi_flash: trying chip: gd
  3. D (732) spi_flash: trying chip: mxic
  4. D (736) spi_flash: trying chip: winbond
  5. D (740) spi_flash: trying chip: generic
  6. I (744) spi_flash: detected chip: generic
  7. I (748) spi_flash: flash io: dio
  8. .....
  9. I (815) main_task: Calling app_main()
  10. I (825) example: Initializing SD card
  11. I (825) example: Using SPI peripheral
  12. D (835) spi: SPI2 use gpio matrix.
  13. I (835) example: Mounting filesystem
  14. D (835) sdspi_host: sdspi_host_init_device: SPI2 cs=27 cd=-1 wp=-1 wp_polarity:0
  15. D (845) intr_alloc: Connected src 30 to int 5 (cpu 0)
  16. D (855) spi_hal: eff: 400, limit: 26666k(/2), 0 dummy, -1 delay
  17. D (855) spi_master: SPI2: New device added to CS5, effective clock: 400000 Hz
  18. I (865) gpio: GPIO[27]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
  19. D (875) spi_master: device5 locked the bus
  20. D (875) spi_master: device5 release bus
  21. D (885) sdspi_host: sdspi_host_start_command: cmd=52 error=0x107
  22. D (885) sdmmc_cmd: cmd=52, sdmmc_req_run returned 0x107
  23. D (895) spi_master: device5 locked the bus
  24. D (895) spi_master: device5 release bus
  25. D (925) spi_master: device5 locked the bus
  26. D (925) spi_master: device5 release bus
  27. D (945) spi_master: device5 locked the bus
  28. D (945) spi_master: device5 release bus
  29. D (945) sdmmc_sd: SDHC/SDXC card
  30. D (945) spi_master: device5 locked the bus
  31. D (945) spi_master: device5 release bus
  32. D (945) sdspi_host: sdspi_host_start_command: cmd=5 error=0x107
  33. D (955) sdmmc_cmd: cmd=5, sdmmc_req_run returned 0x107
  34. D (955) sdmmc_io: sdmmc_init_io: io_send_op_cond (1) returned 0x107; not IO card
  35. D (965) spi_master: device5 locked the bus
  36. D (975) spi_master: device5 release bus
  37. D (975) sdspi_host: data CRC set=1
  38. D (975) sdspi_transaction: cmd=59, R1 response: command not supported
  39. D (985) sdmmc_cmd: cmd=59, sdmmc_req_run returned 0x106
  40. E (995) sdmmc_sd: sdmmc_init_spi_crc: sdmmc_send_cmd_crc_on_off returned 0x106
  41. D (995) sdmmc_init: sdmmc_card_init: sdmmc_init_spi_crc returned 0x106
  42. E (1005) vfs_fat_sdmmc: sdmmc_card_init failed (0x106).
  43. I (1015) gpio: GPIO[27]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
  44. E (1025) example: Failed to initialize the card (ESP_ERR_NOT_SUPPORTED). Make sure SD card lines have pull-up resistors in place.
  45. 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 2722 times
Success connection of 64Gb card (log output): https://gist.github.com/sazanof/c7a9075 ... 7d137f2f43
  1. I (825) example: Initializing SD card
  2. I (825) example: Using SPI peripheral
  3. D (835) spi: SPI2 use gpio matrix.
  4. I (835) example: Mounting filesystem
  5. D (835) sdspi_host: sdspi_host_init_device: SPI2 cs=27 cd=-1 wp=-1 wp_polarity:0
  6. D (845) intr_alloc: Connected src 30 to int 5 (cpu 0)
  7. D (855) spi_hal: eff: 400, limit: 26666k(/2), 0 dummy, -1 delay
  8. D (855) spi_master: SPI2: New device added to CS5, effective clock: 400000 Hz
  9. I (865) gpio: GPIO[27]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
  10. D (875) spi_master: device5 locked the bus
  11. D (875) spi_master: device5 release bus
  12. I (885) sdspi_transaction: cmd=52, R1 response: command not supported
  13. D (895) sdmmc_cmd: cmd=52, sdmmc_req_run returned 0x106
  14. D (895) spi_master: device5 locked the bus
  15. ......
  16. D (945) sdmmc_sd: SDHC/SDXC card
  17. D (945) spi_master: device5 locked the bus
  18. D (945) spi_master: device5 release bus
  19. I (945) sdspi_transaction: cmd=5, R1 response: command not supported
  20. D (955) sdmmc_cmd: cmd=5, sdmmc_req_run returned 0x106
  21. D (965) sdmmc_io: sdmmc_init_io: io_send_op_cond (1) returned 0x106; not IO card
  22. D (965) spi_master: device5 locked the bus
  23. D (975) spi_master: device5 release bus
  24. D (975) sdspi_host: data CRC set=1
  25. D (975) spi_master: device5 locked the bus
  26. ...
  27. D (1025) sdmmc_common: host_ocr=0xff8000 card_ocr=0xc0ff8000
  28. D (1025) sdmmc_common: sdmmc_card_init: host_ocr=00ff8000, card_ocr=c0ff8000
  29. D (1035) sdmmc_init: sdmmc_card_init: card type is SD
  30. ...
  31. D (1085) sdspi_host: Setting card clock to 10000 kHz
  32. D (1095) spi_hal: eff: 10000, limit: 26666k(/2), 0 dummy, -1 delay
  33. D (1095) spi_master: SPI2: New device added to CS5, effective clock: 10000000 Hz
  34. ...
  35. D (1125) vfs_fat_sdmmc: using pdrv=0
  36. ...
  37. I (1185) example: Filesystem mounted
  38. Name: EC1S5
  39. Type: SDHC
  40. Speed: 10.00 MHz (limit: 10.00 MHz)
  41. Size: 61120MB
  42. CSD: ver=2, sector_size=512, capacity=125173760 read_bl_len=9
  43. SSR: bus_width=1
  44. I (1205) example: Opening file /sdcard/hello.txt
  45. ...
  46. I (1755) example: File written
  47. I (1765) example: Reading file /sdcard/nihao.txt
  48. ...
  49. I (1805) example: Read from file: 'Nihao EC1S5!'
  50. I (1805) gpio: GPIO[27]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
  51. I (1815) example: Card unmounted
  52. I (1815) gpio: GPIO[23]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
  53. I (1825) gpio: GPIO[19]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
  54. 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: 148
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: 31
Joined: Wed Sep 13, 2023 10:22 am

Re: ESP32 - supported types of microsd cards

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

nopnop2002 wrote:
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.
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: 34
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: 31
Joined: Wed Sep 13, 2023 10:22 am

Re: ESP32 - supported types of microsd cards

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

ESP_rrtandler wrote:
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.

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 1851 times
How much energy consumption of microsd?

ESP_rrtandler
Posts: 34
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: 31
Joined: Wed Sep 13, 2023 10:22 am

Re: ESP32 - supported types of microsd cards

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

ESP_rrtandler wrote:
Mon Feb 10, 2025 5:41 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 1603 times

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

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: Google [Bot] and 94 guests