Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions components/efuse/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,25 @@ menu "eFuse Bit Manager"
default 128 if EFUSE_CODE_SCHEME_COMPAT_REPEAT
default 256 if !IDF_TARGET_ESP32

choice ESP_EFUSE_VDD_SPI_AS_GPIO_DANGEROUS_WRITE
bool "[DANGER] Allow Writing to ESP_EFUSE_VDD_SPI_AS_GPIO"
default ESP_EFUSE_VDD_SPI_AS_GPIO_DANGEROUS_WRITE_NOT_ALLOWED
depends on IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32C61 || IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32H21
help
Allows writing to the VDD_SPI_AS_GPIO efuse field.

WARNING: This is an irreversible operation! Once written, it cannot be undone.

CRITICAL: If you use Embedded Flash, it will immediately stop working and can never be recovered.
This flag changes the VDD_SPI pin to function as a GPIO, which will permanently disable power to the Embedded Flash.

Ensure that you fully understand the implications of setting this flag.

If unsure, choice 'Not allowed'.
config ESP_EFUSE_VDD_SPI_AS_GPIO_DANGEROUS_WRITE_NOT_ALLOWED
bool "Not allowed"
config ESP_EFUSE_VDD_SPI_AS_GPIO_DANGEROUS_WRITE_ALLOWED
bool "Allowed"
endchoice

endmenu
12 changes: 12 additions & 0 deletions components/efuse/src/esp_efuse_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ esp_err_t esp_efuse_write_field_bit(const esp_efuse_desc_t* field[])
uint8_t existing = 0;
const uint8_t one = 1;

#if defined(ESP_EFUSE_VDD_SPI_AS_GPIO_DANGEROUS_WRITE_NOT_ALLOWED)
if (field == ESP_EFUSE_VDD_SPI_AS_GPIO) {
ESP_LOGE(TAG, "Writing to VDD_SPI_AS_GPIO is not allowed.");
ESP_LOGW(TAG, "[DANGER] Enable CONFIG_ESP_EFUSE_VDD_SPI_AS_GPIO_ALLOWED in menuconfig.");
ESP_LOGW(TAG, "WARNING: This is an irreversible operation! Once written, it cannot be undone.");
ESP_LOGW(TAG, "CRITICAL: If you use Embedded Flash, it will immediately stop working and can never be recovered.");
ESP_LOGW(TAG, "This flag changes the VDD_SPI pin to function as a GPIO, which will permanently disable power to the Embedded Flash.");
ESP_LOGW(TAG, "Ensure that you fully understand the implications of setting this flag.");
return ESP_ERR_NOT_SUPPORTED;
}
#endif

if (field == NULL || field[0]->bit_count != 1) {
return ESP_ERR_INVALID_ARG;
}
Expand Down
Loading