SD_MMC returned 0x107

Hi all,
i’m trying to use the sd_mmc to read sdcard (1bit mode && 4 bit mode) with esp32, i have my own board,
pint are connected as standard (like the esprover kit 4.1, but without diode), i have pullup (10k) on

  • SD_dat0 (io2),
  • sd_dat1 (io4),
  • sd_dat2 (io12),
  • sd_dat3 (io13),
  • sd_cmd (io15),
  • sd_clk (ioio14),
  • sd_cd (io34)

the code initalize pins:

pinMode(SD_CLK, PULLUP);   // 14
pinMode(SD_CMD, PULLUP);   // 15
pinMode(SD_CD, PULLUP);     // 32
pinMode(SD_DAT0, PULLUP);  // 2
pinMode(SD_DAT1, PULLUP);  // 4
pinMode(SD_DAT2, PULLUP);  // 12
pinMode(SD_DAT3, PULLUP);  // 13
pinMode(SD_POWER, OUTPUT); // 35

bool card_present = SD_MMC.begin("/sdcard", true);
if (!card_present)
    Serial.println("Card Mount Failed");

the error is:

E (859) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
[E][SD_MMC.cpp:97] begin(): Failed to initialize the card (263). Make sure SD card lines have pull-up resistors in place.

i read a lot on internet about this problem,
i not have wire, connector soldered directly to my board
set registry on esp32 to 3.3v ( --port com7 set_flash_voltage 3.3V)
the pins use for sd-card are used only for sd-card, nothing more attached
put togheter io2+io2 (not functioning)
tried with 2 equals sd-card (16gb sdhc) formatted fat32 with partition of 512mb (noluck)
tried with another type (8gb) formatted fat32 with partition 512mb (no luck)
set SD_MMC.begin parameters for 1bit or 4bit
changed in SD_MCC.cpp
line 62 to -> host.max_freq_khz = SDMMC_FREQ_PROBING
upload is done with esp-prog, not need to set io2 to ground also when sdcard is inserted
to power the board not use usb

i have loosed many days to find solution
i not know what else try or what can be, no ideas at the moment

someone can try to point me in the right direction?

Well the problem description matches somehow Cant get a MicroSD card to work. (IDFGH-5170) · Issue #965 · espressif/esp-idf · GitHub.

Does it work within Arduino IDE? What is the complete minimal PlatformIO project to reproduce the problem (code + platformio.ini)?

Thank you for the reply
i tried with arduino ide 1.8.9, but same result

platform = espressif32
board = esp32dev
framework = arduino
build_type = debug
board_build.f_cpu = 240000000L
board_build.f_flash = 80000000L
board_build.flash_mode = qio
monitor_speed = 115200
monitor_port = COM7
monitor_filters = time, esp32_exception_decoder, default
upload_speed = 1152000
upload_protocol = esptool 
upload_port = COM7
debug_tool = esp-prog
debug_init_break = tbreak setup
lib_deps =
  build_flags = 


    pinMode(SD_CLK, PULLUP);   // 14
    pinMode(SD_CD, PULLUP);    // 32
    pinMode(SD_CMD, PULLUP);   // 15
    pinMode(SD_DAT0, PULLUP);  // 2
    pinMode(SD_DAT1, PULLUP);  // 4
    pinMode(SD_DAT2, PULLUP);  // 12
    pinMode(SD_DAT3, PULLUP);  // 13


    bool card_present = SD_MMC.begin("/sdcard", true);

    if (!card_present)
        Serial.println("Card Mount Failed");


If you have harware pullups in place, why pullup the pin yourself? This will change the impendence based on the internal microcontroller pullup.

Also, issue Wrover Kit SD · Issue #1131 · espressif/arduino-esp32 · GitHub talks about settung up the SPI pins prior to the SD_MMC call. Maybe the helps?

As a further debugging step, one could set up an ESP-IDF project to see if there was an issue with the SDMMC driver functions (which are also used by arduino) which may have been fixed.

i’ve removed the PULLUP lines, but nothing change,
i tried to set (as the talks) the spi pins, but not help
i tried also with esp-idf this is the log

␛[0;32mI (72) boot: Chip Revision: 0␛[0m
␛[0;32mI (32) boot: ESP-IDF GIT-NOTFOUND 2nd stage bootloader␛[0m
␛[0;32mI (32) boot: compile time 09:22:59␛[0m
␛[0;32mI (32) boot: Enabling RNG early entropy source...␛[0m
␛[0;32mI (37) boot: SPI Speed      : 40MHz␛[0m
␛[0;32mI (42) boot: SPI Mode       : DIO␛[0m
␛[0;32mI (46) boot: SPI Flash Size : 4MB␛[0m
␛[0;32mI (50) boot: Partition Table:␛[0m
␛[0;32mI (53) boot: ## Label            Usage          Type ST Offset   Length␛[0m
␛[0;32mI (60) boot:  0 nvs              WiFi data        01 02 00009000 00006000␛[0m
␛[0;32mI (68) boot:  1 phy_init         RF data          01 01 0000f000 00001000␛[0m
␛[0;32mI (75) boot:  2 factory          factory app      00 00 00010000 00100000␛[0m
␛[0;32mI (83) boot: End of partition table␛[0m
␛[0;32mI (87) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x09928 ( 39208) map␛[0m
␛[0;32mI (110) esp_image: segment 1: paddr=0x00019950 vaddr=0x3ffb0000 size=0x02154 (  8532) load␛[0m
␛[0;32mI (114) esp_image: segment 2: paddr=0x0001baac vaddr=0x40080000 size=0x00400 (  1024) load␛[0m
␛[0;32mI (117) esp_image: segment 3: paddr=0x0001beb4 vaddr=0x40080400 size=0x0415c ( 16732) load␛[0m
␛[0;32mI (133) esp_image: segment 4: paddr=0x00020018 vaddr=0x400d0018 size=0x1c598 (116120) map␛[0m
␛[0;32mI (176) esp_image: segment 5: paddr=0x0003c5b8 vaddr=0x4008455c size=0x06148 ( 24904) load␛[0m
␛[0;32mI (194) boot: Loaded app from partition at offset 0x10000␛[0m
␛[0;32mI (194) boot: Disabling RNG early entropy source...␛[0m
␛[0;32mI (194) cpu_start: Pro cpu up.␛[0m
␛[0;32mI (198) cpu_start: Application information:␛[0m
␛[0;32mI (203) cpu_start: Project name:     test_mmc_idf␛[0m
␛[0;32mI (208) cpu_start: App version:      1␛[0m
␛[0;32mI (212) cpu_start: Compile time:     May  9 2020 09:20:43␛[0m
␛[0;32mI (218) cpu_start: ELF file SHA256:  826dd0894479c1d6...␛[0m
␛[0;32mI (224) cpu_start: ESP-IDF:          GIT-NOTFOUND␛[0m
␛[0;32mI (230) cpu_start: Starting app cpu, entry point is 0x40081384␛[0m
␛[0;32mI (0) cpu_start: App cpu up.␛[0m
␛[0;32mI (240) heap_init: Initializing. RAM available for dynamic allocation:␛[0m
␛[0;32mI (247) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM␛[0m
␛[0;32mI (253) heap_init: At 3FFB3250 len 0002CDB0 (179 KiB): DRAM␛[0m
␛[0;32mI (259) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM␛[0m
␛[0;32mI (266) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM␛[0m
␛[0;32mI (272) heap_init: At 4008A6A4 len 0001595C (86 KiB): IRAM␛[0m
␛[0;32mI (278) cpu_start: Pro cpu start user code␛[0m
␛[0;32mI (297) spi_flash: detected chip: gd␛[0m
␛[0;32mI (297) spi_flash: flash io: dio␛[0m
␛[0;32mI (297) cpu_start: Starting scheduler on PRO CPU.␛[0m
␛[0;32mI (0) cpu_start: Starting scheduler on APP CPU.␛[0m
␛[0;32mI (305) example: Initializing SD card␛[0m
␛[0;32mI (305) example: Using SDMMC peripheral␛[0m
␛[0;32mI (315) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 ␛[0m
␛[0;31mE (345) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107␛[0m
␛[0;31mE (345) example: Failed to initialize the card (ESP_ERR_TIMEOUT). Make sure SD card lines have pull-up resistors in place.␛[0m

i not know what else i can do

If it doesn’t work with the vanilla ESP-IDF drivers, I think it’s best to ask in Issues · espressif/esp-idf · GitHub describing your hardware, software and things you’ve attempted (1-bit/4-bit mode, pullups en/disable, lowering frequency, different microSD card, …).

i decided to look better the situation, and looked with logic analyzer…
as you can see dat0 is ever high, never change…
i must understand why, there aren’t shortcircuit on the board, i think problem is software, but the only things program do, is initialize pins and call sd_mmc.begin…

Maybe do a ‘sanity check’ and do some simple code that toggles each pin in turn several times… that’ll identify whether there’s a solder bridge, some other code that’s conflicting or confounding the issue, or even a fault with the chip. Once that’s eliminated, the hardware is innocent, and you can start pointing fingers at the software! :wink: :rofl:

i’ve done exactly this, the pins toggle correctly (with pin set as OUTPUT) if i not start the sdmmc.

1 Like

just to update situation:
tried with another board (devkit 1) and external sd-card from arduino sketch, to test sd-mmc,
is functional but only with 1-bit mode, the 4-bit not functioning
my board with the same sketch non functioning with 1-bit and 4-bit
i think there are some electric problem, but i not understand, no short circuit, signal arrive to esp and sd-card, i have ordered some esd suppressor, maybe help

1 Like

Finally i found & solved the problem.
I tried to connect another (different socket) and immediately was functional,
so i tried to change the sd-cad socket on the board, et voila’ all functioning,
i try 1bit mode and ok, on 4bit ‘E (211) sdmmc_sd: got corrupted data after increasing clock frequency’
but ok, at the moment not interesting me, 1bit is enough to continue write the firmware, after i look what can be.

1 Like