From 35ace4196f9968eaf2ec4d80d178e337b881b96d Mon Sep 17 00:00:00 2001 From: Eren Terzioglu Date: Thu, 12 Dec 2024 09:57:00 +0100 Subject: [PATCH] esp32[c3|c6|h2]: Add efuse simulation support --- arch/risc-v/src/common/espressif/Kconfig | 7 +++++++ arch/risc-v/src/common/espressif/esp_efuse.c | 5 +++++ boards/risc-v/esp32c3/common/scripts/esp32c3_sections.ld | 2 ++ boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld | 2 ++ boards/risc-v/esp32h2/common/scripts/esp32h2_sections.ld | 2 ++ 5 files changed, 18 insertions(+) diff --git a/arch/risc-v/src/common/espressif/Kconfig b/arch/risc-v/src/common/espressif/Kconfig index 264cb088cd..4ced0c7982 100644 --- a/arch/risc-v/src/common/espressif/Kconfig +++ b/arch/risc-v/src/common/espressif/Kconfig @@ -395,6 +395,13 @@ config ESPRESSIF_EFUSE ---help--- Enable efuse support. +config ESPRESSIF_EFUSE_VIRTUAL + bool "Virtual EFUSE support" + depends on ESPRESSIF_EFUSE + default n + ---help--- + Enable virtual efuse support to simulate eFuse operations in RAM, changes will be reverted each reboot + config ESPRESSIF_HR_TIMER bool default RTC_DRIVER diff --git a/arch/risc-v/src/common/espressif/esp_efuse.c b/arch/risc-v/src/common/espressif/esp_efuse.c index be846f8dab..ce6b5cbfb5 100644 --- a/arch/risc-v/src/common/espressif/esp_efuse.c +++ b/arch/risc-v/src/common/espressif/esp_efuse.c @@ -46,6 +46,7 @@ #include "hal/efuse_hal.h" #include "esp_efuse_table.h" #include "esp_efuse_chip.h" +#include "esp_efuse_utility.h" /**************************************************************************** * Private Types @@ -256,5 +257,9 @@ int esp_efuse_initialize(const char *devpath) ret = -EEXIST; } +#ifdef CONFIG_ESPRESSIF_EFUSE_VIRTUAL + esp_efuse_utility_update_virt_blocks(); +#endif + return ret; } diff --git a/boards/risc-v/esp32c3/common/scripts/esp32c3_sections.ld b/boards/risc-v/esp32c3/common/scripts/esp32c3_sections.ld index 2def89f2f6..0832895a3b 100644 --- a/boards/risc-v/esp32c3/common/scripts/esp32c3_sections.ld +++ b/boards/risc-v/esp32c3/common/scripts/esp32c3_sections.ld @@ -127,6 +127,7 @@ SECTIONS *libarch.a:*esp_rom_spiflash.*(.text .text.* .literal .literal.*) *libarch.a:*esp_efuse_fields.*(.text .text.* .literal .literal.*) *libarch.a:*esp_efuse_api_key.*(.text .text.* .literal .literal.*) + *libarch.a:*esp_efuse_utility.*(.text .text.* .literal .literal.*) *libarch.a:*efuse_hal.*(.text .text.* .literal .literal.*) *libarch.a:*log.*(.text .text.* .literal .literal.*) *libarch.a:*log_noos.*(.text .text.* .literal .literal.*) @@ -246,6 +247,7 @@ SECTIONS *libarch.a:*esp_rom_spiflash.*(.rodata .rodata.*) *libarch.a:*esp_efuse_fields.*(.rodata .rodata.*) *libarch.a:*esp_efuse_api_key.*(.rodata .rodata.*) + *libarch.a:*esp_efuse_utility.*(.rodata .rodata.*) *libarch.a:*efuse_hal.*(.rodata .rodata.*) *libarch.a:*log.*(.rodata .rodata.*) *libarch.a:*log_noos.*(.rodata .rodata.*) diff --git a/boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld b/boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld index 304d975dc1..9114aa39c5 100644 --- a/boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld +++ b/boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld @@ -134,6 +134,7 @@ SECTIONS *libarch.a:*esp_rom_spiflash.*(.text .text.* .literal .literal.*) *libarch.a:*esp_efuse_fields.*(.text .text.* .literal .literal.*) *libarch.a:*esp_efuse_api_key.*(.text .text.* .literal .literal.*) + *libarch.a:*esp_efuse_utility.*(.text .text.* .literal .literal.*) *libarch.a:*efuse_hal.*(.text .text.* .literal .literal.*) *libarch.a:*log.*(.text .text.* .literal .literal.*) *libarch.a:*log_noos.*(.text .text.* .literal .literal.*) @@ -277,6 +278,7 @@ SECTIONS *libarch.a:*esp_rom_spiflash.*(.rodata .rodata.*) *libarch.a:*esp_efuse_fields.*(.rodata .rodata.*) *libarch.a:*esp_efuse_api_key.*(.rodata .rodata.*) + *libarch.a:*esp_efuse_utility.*(.rodata .rodata.*) *libarch.a:*efuse_hal.*(.rodata .rodata.*) *libarch.a:*log.*(.rodata .rodata.*) *libarch.a:*log_noos.*(.rodata .rodata.*) diff --git a/boards/risc-v/esp32h2/common/scripts/esp32h2_sections.ld b/boards/risc-v/esp32h2/common/scripts/esp32h2_sections.ld index 90a337aeec..e6af8045f7 100644 --- a/boards/risc-v/esp32h2/common/scripts/esp32h2_sections.ld +++ b/boards/risc-v/esp32h2/common/scripts/esp32h2_sections.ld @@ -136,6 +136,7 @@ SECTIONS *libarch.a:*esp_rom_spiflash.*(.text .text.* .literal .literal.*) *libarch.a:*esp_efuse_fields.*(.text .text.* .literal .literal.*) *libarch.a:*esp_efuse_api_key.*(.text .text.* .literal .literal.*) + *libarch.a:*esp_efuse_utility.*(.text .text.* .literal .literal.*) *libarch.a:*efuse_hal.*(.text .text.* .literal .literal.*) *libarch.a:*log.*(.text .text.* .literal .literal.*) *libarch.a:*log_noos.*(.text .text.* .literal .literal.*) @@ -274,6 +275,7 @@ SECTIONS *libarch.a:*esp_rom_spiflash.*(.rodata .rodata.*) *libarch.a:*esp_efuse_fields.*(.rodata .rodata.*) *libarch.a:*esp_efuse_api_key.*(.rodata .rodata.*) + *libarch.a:*esp_efuse_utility.*(.rodata .rodata.*) *libarch.a:*efuse_hal.*(.rodata .rodata.*) *libarch.a:*log.*(.rodata .rodata.*) *libarch.a:*log_noos.*(.rodata .rodata.*)