Page 1 of 1

How to read / write the "GPIO_STRAPPING" register

Posted: Mon Jun 27, 2022 1:16 am
by jcolebaker
Hi, we are trying to diagnose and work around problems relating to boot strapping pins and VDD_SDIO. I would like to be write the "GPIO_STRAPPING" register from my application, after boot (to control VDD_SDIO).

From the ESP32 data sheet, under "2.4 Strapping Pins":
Software can read the values of these five bits from register ”GPIO_STRAPPING”
Firmware can configure register bits to change the settings of “Voltage of Internal LDO (VDD_SDIO)” and “Timing
of SDIO Slave”, after booting
I have added the following code to read the register then set the "MTDI" pin bit:

Code: Select all

#include "soc/dport_reg.h"
#include "soc/gpio_reg.h"
...

    uint32_t gpio_strapping = DPORT_REG_READ(GPIO_STRAP_REG);
    ESP_LOGI("DEBUG", COLOUR_YELLOW "Strapping WAS: 0x%04X", gpio_strapping);

    uint32_t correct_gpio_strapping = 0x0013;
    DPORT_REG_WRITE(GPIO_STRAP_REG, correct_gpio_strapping);

    gpio_strapping = DPORT_REG_READ(GPIO_STRAP_REG);
    ESP_LOGI("DEBUG", COLOUR_YELLOW "Strapping NOW: 0x%04X", gpio_strapping);
However, when executed, the log shows that the bit is not set:

Code: Select all

I (1242) DEBUG: Strapping WAS: 0x0033
I (1242) DEBUG: Strapping NOW: 0x0033
Is it possible to set “Voltage of Internal LDO (VDD_SDIO)” after boot, as mentioned in the data sheet?

The reason for this madness is that, due to a hardware design problem, the board may sometimes boot up with the "MTDI" pin not quite pulled low enough, resulting in the wrong VDD_SDIO being selected.

EDIT: I fixed the earlier crash bug - I was using the wrong const. It's "GPIO_STRAP_REG", not "GPIO_STRAPPING".

-----
ESP-IDF 4.4
chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
Flash:
Manufacturer: c8
Device: 4017
Detected flash size: 8MB

Re: How to read / write the "GPIO_STRAPPING" register

Posted: Mon Jun 27, 2022 2:51 am
by ESP_Sprite
You can't write to the strapping register; it's read-only iirc. There's a register in the RTC domain that controls VCC_SDIO, but for your issue, I'd suggest using espefuse.py to burn the fuse that fixes VCC_SDIO to a given value; after that is done, the ESP32 will ignore MTDI.

Re: How to read / write the "GPIO_STRAPPING" register

Posted: Tue Jul 05, 2022 11:18 pm
by jcolebaker
Thanks, we now "burn" the required e-fuses as suggested, so that we don't rely on the strapping pins to set VDD_SDIO.

For anyone who finds this thread for similar reasons, here is the command we use:

Code: Select all

python espefuse.py --chip esp32 -p COMX set_flash_voltage 3.3V
(This is for boards with 3.3V flash, and you would need to replace "COMX" with your com port and maybe use the full path to espefuse.py depending on how your system is set up).

This has solved an issue where stray voltages from a USB programmer were causing the boot strapping pins to be set to the wrong level, causing VDD_SDIO to be set to 1.8V. This meant the flash would read but not write on some boards (surprising that it worked at all...).

Re: How to read / write the "GPIO_STRAPPING" register

Posted: Mon Dec 05, 2022 11:38 pm
by chandrian31722
Do you know how to change the regulator value in the GPIO_strapping pin register using the RTC (without running the efuse python script) I have restrictions here that doesnt allow me to use the efuse (though I have tested it and it works)

Thanks

Re: How to read / write the "GPIO_STRAPPING" register

Posted: Tue Dec 06, 2022 4:25 am
by ESP_Sprite
See the TRM, chapter 31.3.4 'Flash voltage regulator'. Note that we cannot guarantee proper startup of the ESP32 if the wrong flash voltage is configured, as in: there still is a chance that your ESP32 will boot-loop before it gets to your flash voltage setting code.