espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.6k stars 7.27k forks source link

ESP32-S3 SDMMC example fails, sdmmc_init_ocr: send_op_cond (1) returned 0x107 (IDFGH-11902) #12986

Closed SneezingCactus closed 9 months ago

SneezingCactus commented 9 months ago

Answers checklist.

IDF version.

v5.3-dev-1353-gb3f7e2c8a4

Espressif SoC revision.

ESP32-S3 (QFN56) (revision v0.1)

Operating System used.

Linux

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32-S3-DevKitC-1 v1.0

Power Supply used.

USB

What is the expected behavior?

The SD card should've been initialized and mounted in SDMMC mode normally, as it did in SPI mode.

What is the actual behavior?

The SD card appears to give responses to some commands during initialization, as the logs notify that the card present is an SDHC/SDXC card. However, initialization later fails with a 0x107, suggesting that the SD card did not respond to a command (or several).

Steps to reproduce.

  1. Hook up the SD card to the board. GPIO choice shouldn't matter given it's an ESP32-S3, but these are the GPIOs I used during testing:
SD card GPIO
CLK 14
CMD 13
D0 12
D1 11
D2 10
D3 9
  1. Make a copy of the SDMMC example.
  2. Configure the example's GPIOs in menuconfig.
  3. Flash the project into the board.

Debug Logs.

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0xa (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3810,len:0x178c
load:0x403c9700,len:0x4
load:0x403c9704,len:0xccc
load:0x403cc700,len:0x2e64
entry 0x403c9924
I (27) boot: ESP-IDF v5.3-dev-1353-gb3f7e2c8a4 2nd stage bootloader
I (27) boot: compile time Jan 15 2024 23:53:38
I (27) boot: Multicore bootloader
I (32) boot: chip revision: v0.1
I (35) boot.esp32s3: Boot SPI Speed : 80MHz
I (40) boot.esp32s3: SPI Mode       : DIO
I (45) boot.esp32s3: SPI Flash Size : 2MB
I (50) boot: Enabling RNG early entropy source...
I (55) boot: Partition Table:
I (59) boot: ## Label            Usage          Type ST Offset   Length
I (66) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (73) 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 (92) esp_image: segment 0: paddr=00010020 vaddr=3c030020 size=0f310h ( 62224) map
I (112) esp_image: segment 1: paddr=0001f338 vaddr=3fc92c00 size=00ce0h (  3296) load
I (113) esp_image: segment 2: paddr=00020020 vaddr=42000020 size=2aa30h (174640) map
I (149) esp_image: segment 3: paddr=0004aa58 vaddr=3fc938e0 size=01f68h (  8040) load
I (151) esp_image: segment 4: paddr=0004c9c8 vaddr=40374000 size=0ebcch ( 60364) load
I (174) boot: Loaded app from partition at offset 0x10000
I (175) boot: Disabling RNG early entropy source...
I (186) cpu_start: Multicore app
D (186) cpu_start: Pro cpu up
D (186) cpu_start: Starting app cpu, entry point is 0x40375270
D (0) cpu_start: App cpu up
D (196) clk: RTC_SLOW_CLK calibration value: 3665882
D (207) cpu_start: calling init function: 0x42001fa4 on core: 0
I (208) cpu_start: Pro cpu start user code
I (208) cpu_start: cpu freq: 160000000 Hz
D (212) cpu_start: calling init function: 0x42001ff0 on core: 0
I (218) cpu_start: Application information:
I (222) cpu_start: Project name:     sd_card
I (227) cpu_start: App version:      1
I (232) cpu_start: Compile time:     Jan 15 2024 23:53:31
I (238) cpu_start: ELF file SHA256:  991cf65bfd728b3b...
I (244) cpu_start: ESP-IDF:          v5.3-dev-1353-gb3f7e2c8a4
I (250) cpu_start: Min chip rev:     v0.0
I (255) cpu_start: Max chip rev:     v0.99 
I (260) cpu_start: Chip rev:         v0.1
D (265) cpu_start: calling init function: 0x42002158 on core: 0
D (271) memory_layout: Checking 6 reserved memory ranges:
D (276) memory_layout: Reserved memory range 0x3fc84000 - 0x3fc92c00
D (283) memory_layout: Reserved memory range 0x3fc92c00 - 0x3fc961c8
D (289) memory_layout: Reserved memory range 0x3fceee34 - 0x3fcf0000
D (295) memory_layout: Reserved memory range 0x40374000 - 0x40382c00
D (302) memory_layout: Reserved memory range 0x600fe000 - 0x600fe010
D (308) memory_layout: Reserved memory range 0x600fffe8 - 0x60100000
D (315) memory_layout: Building list of available memory regions:
D (321) memory_layout: Available memory region 0x3fc961c8 - 0x3fca0000
D (327) memory_layout: Available memory region 0x3fca0000 - 0x3fcb0000
D (334) memory_layout: Available memory region 0x3fcb0000 - 0x3fcc0000
D (341) memory_layout: Available memory region 0x3fcc0000 - 0x3fcd0000
D (347) memory_layout: Available memory region 0x3fcd0000 - 0x3fce0000
D (354) memory_layout: Available memory region 0x3fce0000 - 0x3fce9710
D (360) memory_layout: Available memory region 0x3fce9710 - 0x3fceee34
D (367) memory_layout: Available memory region 0x3fcf0000 - 0x3fcf8000
D (374) memory_layout: Available memory region 0x600fe010 - 0x600fffe8
I (380) heap_init: Initializing. RAM available for dynamic allocation:
D (388) heap_init: New heap initialised at 0x3fc961c8
I (393) heap_init: At 3FC961C8 len 00053548 (333 KiB): RAM
I (399) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
D (405) heap_init: New heap initialised at 0x3fcf0000
I (410) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
D (416) heap_init: New heap initialised at 0x600fe010
I (421) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
D (427) cpu_start: calling init function: 0x42002164 on core: 0
D (433) cpu_start: calling init function: 0x420069a0 on core: 0
D (439) cpu_start: calling init function: 0x420286dc on core: 0
D (445) cpu_start: calling init function: 0x42002170 on core: 0
D (452) intr_alloc: Connected src 39 to int 2 (cpu 0)
D (456) cpu_start: calling init function: 0x4200217c on core: 0
D (463) cpu_start: calling init function: 0x42007ffc on core: 0
D (468) cpu_start: calling init function: 0x42008cf0 on core: 0
D (474) cpu_start: calling init function: 0x4200981c on core: 0
D (481) cpu_start: calling init function: 0x42006a14 on core: 0
D (487) cpu_start: calling init function: 0x42002188 on core: 0
D (492) cpu_start: calling init function: 0x42002194 on core: 0
D (499) spi_flash: trying chip: issi
D (502) spi_flash: trying chip: gd
I (506) spi_flash: detected chip: gd
I (510) spi_flash: flash io: dio
W (514) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
D (527) cpu_start: calling init function: 0x420286e4 on core: 0
D (533) cpu_start: calling init function: 0x42016794
D (538) cpu_start: calling init function: 0x42016754
D (543) cpu_start: calling init function: 0x40379788
D (548) cpu_start: calling init function: 0x42003540
D (553) cpu_start: calling init function: 0x42002728
D (558) cpu_start: calling init function: 0x42001ca4
D (563) cpu_start: calling init function: 0x42006f44 on core: 0
D (569) intr_alloc: Connected src 59 to int 3 (cpu 0)
D (574) cpu_start: calling init function: 0x42004a8c on core: 0
I (580) sleep: Configure to isolate all GPIO pins in sleep state
I (587) sleep: Enable automatic switching of GPIO sleep configuration
D (594) cpu_start: calling init function: 0x420021c0 on core: 0
D (600) cpu_start: calling init function: 0x42008920 on core: 0
D (606) cpu_start: calling init function: 0x420021cc on core: 0
D (612) intr_alloc: Connected src 79 to int 9 (cpu 0)
D (617) app_start: Starting scheduler on CPU0
D (622) intr_alloc: Connected src 57 to int 12 (cpu 0)
D (622) intr_alloc: Connected src 80 to int 2 (cpu 1)
D (632) app_start: Starting scheduler on CPU1
D (632) intr_alloc: Connected src 58 to int 3 (cpu 1)
I (622) main_task: Started on CPU0
D (642) heap_init: New heap initialised at 0x3fce9710
D (642) intr_alloc: Connected src 52 to int 13 (cpu 0)
I (652) main_task: Calling app_main()
I (652) example: Initializing SD card
I (662) example: Using SDMMC peripheral
I (662) example: Mounting filesystem
D (672) sdmmc_periph: peripheral version 5342270a, hardware config 03c44c83
D (672) intr_alloc: Connected src 30 to int 17 (cpu 0)
D (682) sdmmc_periph: using GPIO14 as clk pin
I (682) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
D (692) sdmmc_periph: using GPIO13 as cmd pin
I (702) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
D (712) sdmmc_periph: using GPIO12 as d0 pin
I (712) gpio: GPIO[12]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
D (722) sdmmc_periph: using GPIO11 as d1 pin
I (722) gpio: GPIO[11]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
D (732) sdmmc_periph: using GPIO10 as d2 pin
I (742) gpio: GPIO[10]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (752) gpio: GPIO[9]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
D (762) sdmmc_periph: slot=1 host_div=10 card_div=20 freq=400kHz (max 400kHz)
D (762) sdmmc_periph: slot=1 width=1
D (772) sdmmc_req: process_command_response: error 0x107  (status=00000100)
D (792) sdmmc_sd: SDHC/SDXC card
D (792) sdmmc_req: process_command_response: error 0x107  (status=00000100)
D (792) sdmmc_io: sdmmc_init_io: io_send_op_cond (1) returned 0x107; not IO card
D (1792) sdmmc_common: send_op_cond timeout, trying MMC
D (1792) sdmmc_req: process_command_response: error 0x107  (status=00000100)
D (1792) sdmmc_req: process_command_response: error 0x107  (status=00000100)
D (1792) sdmmc_req: process_command_response: error 0x107  (status=00000100)
D (1802) sdmmc_cmd: sdmmc_send_cmd_send_op_cond: sdmmc_send_app_cmd err=0x107
E (1812) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
D (1822) sdmmc_init: sdmmc_card_init: sdmmc_init_ocr returned 0x107
E (1822) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
E (1832) example: Failed to initialize the card (ESP_ERR_TIMEOUT). Make sure SD card lines have pull-up resistors in place.
I (1842) main_task: Returned from app_main()

More Information.

SneezingCactus commented 9 months ago

Seems like the real issue all this time was the power supply. I hooked up an external 3.3V power supply to the SD card and it started working perfectly. 4-bit won't work (for some reason, sdmmc_init_ocr still timeouts if DAT1 and DAT2 aren't grounded, even when trying to initialize the card as 4-bit), but 1-bit is more than enough for my project.

I will be closing the issue now.

pacucha42 commented 8 months ago

Nice to hear you have solved the issue. Thanks for the update