From af1ea9b1b9a70cd401e042a4ebfb0fa18d99a9be Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 11 Mar 2019 15:15:16 +1100 Subject: [PATCH] efuse: When Virtual eFuses are enabled, seed the virtual values as part of startup code --- components/efuse/src/esp_efuse_utility.c | 8 ++++++-- docs/en/api-reference/system/efuse.rst | 10 ++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/components/efuse/src/esp_efuse_utility.c b/components/efuse/src/esp_efuse_utility.c index fa360e46ba..a9401f163a 100644 --- a/components/efuse/src/esp_efuse_utility.c +++ b/components/efuse/src/esp_efuse_utility.c @@ -32,6 +32,10 @@ static const char *TAG = "efuse"; // Array for emulate efuse registers. #ifdef CONFIG_EFUSE_VIRTUAL static uint32_t virt_blocks[COUNT_EFUSE_BLOCKS][COUNT_EFUSE_REG_PER_BLOCK]; + +/* Call the update function to seed virtual efuses during initialization */ +__attribute__((constructor)) void esp_efuse_utility_update_virt_blocks(); + #endif /** @@ -181,7 +185,7 @@ void esp_efuse_utility_reset(void) void esp_efuse_utility_burn_efuses(void) { #ifdef CONFIG_EFUSE_VIRTUAL - ESP_LOGE(TAG, "Not really burning any efuses!"); + ESP_LOGW(TAG, "Virtual efuses enabled: Not really burning eFuses"); for (int num_block = 0; num_block < COUNT_EFUSE_BLOCKS; num_block++) { esp_efuse_coding_scheme_t scheme = esp_efuse_get_coding_scheme(num_block); if (scheme == EFUSE_CODING_SCHEME_3_4) { @@ -229,7 +233,7 @@ void esp_efuse_utility_erase_virt_blocks() void esp_efuse_utility_update_virt_blocks() { #ifdef CONFIG_EFUSE_VIRTUAL - ESP_LOGI(TAG, "Emulate efuse is enabled"); + ESP_LOGI(TAG, "Loading virtual efuse blocks from real efuses"); for (int num_block = 0; num_block < COUNT_EFUSE_BLOCKS; num_block++) { int subblock = 0; for (uint32_t addr_rd_block = range_read_addr_blocks[num_block].start; addr_rd_block <= range_read_addr_blocks[num_block].end; addr_rd_block += 4) { diff --git a/docs/en/api-reference/system/efuse.rst b/docs/en/api-reference/system/efuse.rst index e1fd2bebc0..44d4df812d 100644 --- a/docs/en/api-reference/system/efuse.rst +++ b/docs/en/api-reference/system/efuse.rst @@ -248,9 +248,15 @@ The number of bits not included in square brackets is free (bits in EFUSE_BLK0 a Debug eFuse & Unit tests ------------------------ -eFuse manager have option :envvar:`CONFIG_EFUSE_VIRTUAL` in Kconfig which will make an operation write is virtual. It can help to debug app and unit tests. +Virtual eFuses +^^^^^^^^^^^^^^ -esptool have an useful tool for reading/writing ESP32 eFuse bits - `espefuse.py `_. +The Kconfig option :envvar:`CONFIG_EFUSE_VIRTUAL` will virtualize eFuse values inside the eFuse Manager, so writes are emulated and no eFuse values are permanently changed. This can be useful for debugging app and unit tests. + +espefuse.py +^^^^^^^^^^^ + +esptool includes a useful tool for reading/writing ESP32 eFuse bits - `espefuse.py `_. ::