-
Notifications
You must be signed in to change notification settings - Fork 7.9k
feat: add Kconfig option to allow VDD_SPI_AS_GPIO write (IDFGH-16349) #17491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Hello HonestQiao, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
If merged, I'll backport this to active branches. |
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT[]; | ||
extern const esp_efuse_desc_t* ESP_EFUSE_USB_EXCHG_PINS[]; | ||
extern const esp_efuse_desc_t* ESP_EFUSE_VDD_SPI_AS_GPIO[]; | ||
#define ESP_EFUSE_VDD_SPI_AS_GPIO_DESC ESP_EFUSE_VDD_SPI_AS_GPIO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
See the comment at the top of this file
Hi @HonestQiao! |
Thank you for the feedback. Yes, my intention with the Kconfig warning was precisely to highlight this irreversible danger. Your suggestion is excellent – a dedicated function makes perfect sense for this special case, and having the generic API reject it with ESP_ERR_NOT_SUPPORTED is the right way to guide users to the safe path. |
Absolutely. Since this operation is extremely dangerous for the affected chips, I added the prominent warning in Kconfig as a safeguard. At first, I wanted to automatically detect whether there is built-in flash and prohibit the operation accordingly, but I abandoned that idea due to the high coupling it would introduce. Also, could you please let us know what other operations can similarly "brick" the chip? |
Per your advice, I'm thinking of structuring the code like this. Is this the right direction?
We can use a dedicated esp_efuse_burn_vdd_spi_as_gpio() function. |
Yes, you got me right. I think that developers typically burn eFuses via espefuse.py (esptool) rather The esp-idf provides a small explicit helper (esp_efuse_burn_vdd_spi_as_gpio()) gated by CONFIG_EFUSE_ALLOW_VDD_SPI_AS_GPIO_BURN (default n). Do not special-case the generic esp_efuse_write_field_* APIs. A short list of the “instant brick” eFuses if burned incorrectly: We can not check all of them in esp-idf and the chip condition. I think espefuse is the proper way to do it. |
Thank you for the detailed guidance and the list of critical eFuses. This is extremely valuable. I understand the approach now: the primary safeguard should be in espefuse.py with a forced --force option for dangerous writes like this, while ESP-IDF provides an explicit helper function gated by a Kconfig. I will study these points and work on implementing the corresponding handling in espefuse.py. |
Description
This PR adds a guarded Kconfig option ESP_EFUSE_VDD_SPI_AS_GPIO_ALLOWED to control access to the dangerous VDD_SPI_AS_GPIO eFuse operation.
Motivation:
Writing to the VDD_SPI_AS_GPIO eFuse is an irreversible operation that permanently reconfigures the VDD_SPI pin as a GPIO. This immediately disables power to embedded flash, rendering it permanently unusable. Without proper safeguards, users might accidentally execute this destructive operation.
Changes:
Related
This is a preventive safety measure and not directly related to any existing issue.
Testing