How to read / write the "GPIO_STRAPPING" register

jcolebaker
Posts: 60
Joined: Thu Mar 18, 2021 12:23 am

How to read / write the "GPIO_STRAPPING" register

Postby jcolebaker » Mon Jun 27, 2022 1:16 am

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

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Mon Jun 27, 2022 2:51 am

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.

jcolebaker
Posts: 60
Joined: Thu Mar 18, 2021 12:23 am

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

Postby jcolebaker » Tue Jul 05, 2022 11:18 pm

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...).

chandrian31722
Posts: 4
Joined: Tue Jul 05, 2022 8:36 pm

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

Postby chandrian31722 » Mon Dec 05, 2022 11:38 pm

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

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Tue Dec 06, 2022 4:25 am

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.

Who is online

Users browsing this forum: No registered users and 103 guests