Conflict between GPIOs used by bootloader vs. SDMMC

jens.alfke
Posts: 17
Joined: Wed May 02, 2018 4:26 pm

Conflict between GPIOs used by bootloader vs. SDMMC

Postby jens.alfke » Mon Aug 30, 2021 7:30 pm

I've got a SparkFun ESP32 Thing (1st gen) on a breadboard wired up to a microSD card using 4-bit SDMMC. The wiring is as directed by comments in the IDF example: GPIOs 15, 14, 2, 4, 12, 13 connect to CMD, CLK, D0, D1, D2, D3 respectively. And I've added external 10K pullups to all but CLK, as per the multiple warnings in the file.

The damn thing is not flashable in this state -- uploading the first block of flash always fails with one of multiple fatal errors. In desperation I pulled the wires out and tried again, and was able to flash it. Then I had to fit the wires back in again, power up again, and watch my program run. This is not sustainable as a development cycle.

It looks like the problem is that GPIOs 2, 12 and 15 are monitored by the bootloader and change its behavior. These are exactly the same pins used by SDMMC! Pulling them up as required for SDMMC disables the bootloader (pin 2), and for good measure also tells it to use the wrong flash voltage (pin 12).

Is there any workaround for this? Like, can I tell IDF's SDMMC library to use different pins? (And if so, that kind of begs the question of why Espressif chose default pins that conflict so badly with the bootloader.)

Thanks,
--Jens

PS: To get it into bootloader mode at all I have to press both buttons then release Reset, at the exact right instant while the flasher is trying to connect, while pressing my belly button with the other hand. I used this exact board in 2018 and did not have this problem; maybe something's changed with IDF's flasher in the meantime?

username
Posts: 536
Joined: Thu May 03, 2018 1:18 pm

Re: Conflict between GPIOs used by bootloader vs. SDMMC

Postby username » Mon Aug 30, 2021 10:54 pm

you can use alternate pins. Check out the schematic for SF Thing Plus. This are the pins I used and it works just fine.
https://www.sparkfun.com/products/18018

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Conflict between GPIOs used by bootloader vs. SDMMC

Postby ESP_igrr » Tue Aug 31, 2021 9:09 am

Hi Jens, the issues and possible solutions for GPIO2 and GPIO12 are described here: https://github.com/espressif/esp-idf/tr ... esp32-only.

For GPIO2, the WROVER-KIT board includes a transistor on GPIO2 which pulls this pin down during programming (same is for GPIO0). This might be a solution if you are designing your own board.

Regarding GPIO12, you can burn an eFuse to disable the selection of flash voltage by this pin.

Who is online

Users browsing this forum: No registered users and 193 guests