SD card ESP32-P4

JohnnyZ
Posts: 36
Joined: Thu Jan 11, 2024 10:24 am

SD card ESP32-P4

Postby JohnnyZ » Mon Sep 01, 2025 12:33 pm

I am having problem with examples/storage/sd_card/sdmmc
I am using Waveshare board, and schematic around SD card is pretty much identical like the official board.
Tried on the branches: v5.4, v5.4.2, v5.5 and latest master.

Logs without card insterted:

Code: Select all

I (35) boot: ESP-IDF v5.5-490-gdf59d05d1d-dirty 2nd stage bootloader
I (35) boot: compile time Sep  1 2025 14:05:22
I (35) boot: Multicore bootloader
I (37) boot: chip revision: v0.1
I (40) boot: efuse block revision: v0.1
I (43) boot.esp32p4: SPI Speed      : 80MHz
I (47) boot.esp32p4: SPI Mode       : DIO
I (51) boot.esp32p4: SPI Flash Size : 2MB
I (55) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (62) boot: ## Label            Usage          Type ST Offset   Length
I (68) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (74) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (81) boot:  2 factory          factory app      00 00 00010000 00100000
I (88) boot: End of partition table
I (91) esp_image: segment 0: paddr=00010020 vaddr=40030020 size=0c5ech ( 50668) map
I (106) esp_image: segment 1: paddr=0001c614 vaddr=30100000 size=00044h (    68) load
I (107) esp_image: segment 2: paddr=0001c660 vaddr=4ff00000 size=039b8h ( 14776) load
I (116) esp_image: segment 3: paddr=00020020 vaddr=40000020 size=2e4d8h (189656) map
I (148) esp_image: segment 4: paddr=0004e500 vaddr=4ff039b8 size=0be14h ( 48660) load
I (157) esp_image: segment 5: paddr=0005a31c vaddr=4ff0f800 size=02444h (  9284) load
I (163) boot: Loaded app from partition at offset 0x10000
I (164) boot: Disabling RNG early entropy source...
W (174) pmu_pvt: blk_version is less than 2, pvt auto dbias init not supported in efuse.
I (176) cpu_start: Multicore app
I (186) cpu_start: Pro cpu start user code
I (186) cpu_start: cpu freq: 360000000 Hz
I (186) app_init: Application information:
I (186) app_init: Project name:     sd_card
I (190) app_init: App version:      v5.5-490-gdf59d05d1d-dirty
I (195) app_init: Compile time:     Sep  1 2025 14:04:52
I (200) app_init: ELF file SHA256:  36ee08c88...
I (205) app_init: ESP-IDF:          v5.5-490-gdf59d05d1d-dirty
I (210) efuse_init: Min chip rev:     v0.1
I (214) efuse_init: Max chip rev:     v1.99 
I (218) efuse_init: Chip rev:         v0.1
I (222) heap_init: Initializing. RAM available for dynamic allocation:
I (228) heap_init: At 4FF13410 len 00027BB0 (158 KiB): RAM
I (233) heap_init: At 4FF3AFC0 len 00004BF0 (18 KiB): RAM
I (238) heap_init: At 4FF40000 len 00060000 (384 KiB): RAM
I (244) heap_init: At 50108080 len 00007F80 (31 KiB): RTCRAM
I (249) heap_init: At 30100044 len 00001FBC (7 KiB): TCM
I (255) spi_flash: detected chip: gd
I (257) spi_flash: flash io: dio
W (260) spi_flash: Detected size(16384k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (273) main_task: Started on CPU0
I (313) main_task: Calling app_main()
I (313) example: Initializing SD card
I (313) example: Using SDMMC peripheral
W (313) ldo: The voltage value 0 is out of the recommended range [500, 2700]
I (323) example: Mounting filesystem
E (343) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
E (343) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
E (343) example: Failed to initialize the card (ESP_ERR_TIMEOUT). Make sure SD card lines have pull-up resistors in place.
I (353) main_task: Returned from app_main()
4GB Amazon card:

Code: Select all

I (321) example: Mounting filesystem
E (321) sdmmc_io: sdmmc_io_reset: unexpected return: 0x108
E (321) vfs_fat_sdmmc: sdmmc_card_init failed (0x108).
E (331) example: Failed to initialize the card (ESP_ERR_INVALID_RESPONSE). Make sure SD card lines have pull-up resistors in place.
I (341) main_task: Returned from app_main()
2 GB Samsung, 15 years old card:

Code: Select all

I (321) example: Mounting filesystem
E (361) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x109
E (361) vfs_fat_sdmmc: sdmmc_card_init failed (0x109).
E (361) example: Failed to initialize the card (ESP_ERR_INVALID_CRC). Make sure SD card lines have pull-up resistors in place.
I (371) main_task: Returned from app_main()
Some random card:

Code: Select all

I (321) example: Mounting filesystem
E (721) sdmmc_cmd: sdmmc_read_sectors_dma: sdmmc_send_cmd returned 0x107, failed to get status (0x107)
E (721) diskio_sdmmc: sdmmc_read_blocks failed (0x107)
W (721) vfs_fat_sdmmc: failed to mount card (1)
E (731) vfs_fat_sdmmc: mount_to_vfs failed (0xffffffff).
E (731) example: Failed to mount filesystem. If you want the card to be formatted, set the EXAMPLE_FORMAT_IF_MOUNT_FAILED menuconfig option.
I (751) main_task: Returned from app_main()
Sandisk Ultra 64 GB card (noticable delay but no luck). Same results for Kingston 64 GB.

Code: Select all

I (321) example: Mounting filesystem
E (3341) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
E (3341) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
E (3341) example: Failed to initialize the card (ESP_ERR_TIMEOUT). Make sure SD card lines have pull-up resistors in place.
I (3351) main_task: Returned from app_main()
SanDisk Extreme Pro 128 GB

Code: Select all

I (321) example: Mounting filesystem
E (341) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
E (341) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
E (341) example: Failed to initialize the card (ESP_ERR_TIMEOUT). Make sure SD card lines have pull-up resistors in place.
I (351) main_task: Returned from app_main()
Same results when I disable internal pullups in the code.
LDO VO4 pin is at 3.3V (measured with multimeter)
Tried lowering freq to 100 kHz
All cards are usable on PC
SD card slot has 10k pull up resistors
Pinout in menuconfig corresponds with the schematic https://files.waveshare.com/wiki/ESP32- ... ematic.pdf

ahsrabrifat
Posts: 201
Joined: Sat Jan 18, 2025 2:31 pm

Re: SD card ESP32-P4

Postby ahsrabrifat » Mon Sep 01, 2025 1:36 pm

Is there any problem with your ESP32-P4 board itself? Is it working alright otherwise?

JohnnyZ
Posts: 36
Joined: Thu Jan 11, 2024 10:24 am

Re: SD card ESP32-P4 [solved]

Postby JohnnyZ » Mon Sep 01, 2025 5:50 pm

My board was working okay. Tested HW things: UART, GPIO, SPI LCD, I2C, ...
And how I can add SD card on that list! :mrgreen:
It is HW fault. Again...
LDO VO4 was indeed 3.3V, but there is transistor between that voltage and VCC SD. VCC SD was at 1.1V regardless is transistor's gate set to low or high.
After removing transistor and soldering wire, SD started working, old Samsung card:

Code: Select all

I (321) example: Mounting filesystem
I (461) example: Filesystem mounted
Name: 00000
Type: SDSC
Speed: 20.00 MHz (limit: 20.00 MHz)
Size: 1909MB
CSD: ver=1, sector_size=512, capacity=3909632 read_bl_len=10
SSR: bus_width=4
I (471) example: Opening file /sdcard/hello.txt
I (521) example: File written
I (541) example: Renaming file /sdcard/hello.txt to /sdcard/foo.txt
I (551) example: Reading file /sdcard/foo.txt
I (551) example: Read from file: 'Hello 00000!'
I (551) example: Opening file /sdcard/nihao.txt
I (591) example: File written
I (591) example: Reading file /sdcard/nihao.txt
I (591) example: Read from file: 'Nihao 00000!'
I (591) example: Card unmounted
I (591) main_task: Returned from app_main()

lbernstone
Posts: 1132
Joined: Mon Jul 22, 2019 3:20 pm

Re: SD card ESP32-P4

Postby lbernstone » Sat Nov 15, 2025 3:21 am

For anyone still looking for this info, the transistor mentioned above is on gpio46. It should be pulled low to power the sd card.

Who is online

Users browsing this forum: Baidu [Spider], ChatGPT-User and 3 guests