soc: esp32: virtual e-fuses support
Adds support for virtual e-fuses on esp32 socs Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
This commit is contained in:
parent
85f5bd9520
commit
77c350c149
9 changed files with 86 additions and 0 deletions
|
@ -62,6 +62,7 @@ endif
|
|||
|
||||
rsource "Kconfig.amp"
|
||||
rsource "Kconfig.console"
|
||||
rsource "Kconfig.efuse"
|
||||
rsource "Kconfig.spiram"
|
||||
rsource "Kconfig.esptool"
|
||||
rsource "Kconfig.flash"
|
||||
|
|
47
soc/espressif/common/Kconfig.efuse
Normal file
47
soc/espressif/common/Kconfig.efuse
Normal file
|
@ -0,0 +1,47 @@
|
|||
# Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if SOC_FAMILY_ESPRESSIF_ESP32
|
||||
|
||||
config ESP32_EFUSE_VIRTUAL
|
||||
bool "Simulate eFuse operations in RAM"
|
||||
help
|
||||
If "y" - The virtual mode is enabled and all eFuse operations (read and write) are redirected
|
||||
to RAM instead of eFuse registers, all permanent changes (via eFuse) are disabled.
|
||||
|
||||
If it is "y", then SECURE_FLASH_ENCRYPTION_MODE_RELEASE cannot be used.
|
||||
Because the EFUSE VIRT mode is for testing only.
|
||||
|
||||
During startup, the eFuses are copied into RAM. This mode is useful for fast tests.
|
||||
|
||||
config ESP32_EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
bool "Keep eFuses in flash"
|
||||
depends on ESP32_EFUSE_VIRTUAL
|
||||
help
|
||||
In addition to the "Simulate eFuse operations in RAM" option, this option just adds
|
||||
a feature to keep eFuses after reboots in flash memory. To use this mode the partition_table
|
||||
should have the `sys_partition` partition.
|
||||
|
||||
During startup, the eFuses are copied from flash or,
|
||||
in case if flash is empty, from real eFuse to RAM and then update flash.
|
||||
This mode is useful when need to keep changes after reboot
|
||||
(testing secure_boot and flash_encryption).
|
||||
|
||||
config ESP32_EFUSE_VIRTUAL_OFFSET
|
||||
hex
|
||||
depends on ESP32_EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
default $(dt_nodelabel_reg_addr_hex,sys_partition) if $(dt_nodelabel_exists,sys_partition)
|
||||
default 0x0
|
||||
|
||||
config ESP32_EFUSE_VIRTUAL_SIZE
|
||||
hex
|
||||
depends on ESP32_EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
default 0x2000 if $(dt_nodelabel_exists,sys_partition)
|
||||
default 0x0
|
||||
|
||||
config ESP32_EFUSE_MAX_BLK_LEN
|
||||
int
|
||||
default 192 if SOC_SERIES_ESP32
|
||||
default 256
|
||||
|
||||
endif # SOC_FAMILY_ESPRESSIF_ESP32
|
20
soc/espressif/common/include/efuse_virtual.h
Normal file
20
soc/espressif/common/include/efuse_virtual.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <esp_efuse.h>
|
||||
|
||||
static inline void esp_efuse_init_virtual(void)
|
||||
{
|
||||
#if CONFIG_ESP32_EFUSE_VIRTUAL
|
||||
#if CONFIG_ESP32_EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
esp_efuse_init_virtual_mode_in_flash(CONFIG_ESP32_EFUSE_VIRTUAL_OFFSET,
|
||||
CONFIG_ESP32_EFUSE_VIRTUAL_SIZE);
|
||||
#else
|
||||
esp_efuse_init_virtual_mode_in_ram();
|
||||
#endif
|
||||
#endif
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
#include <esp_private/cache_utils.h>
|
||||
#include <esp_private/system_internal.h>
|
||||
#include <esp_timer.h>
|
||||
#include <efuse_virtual.h>
|
||||
#include <psram.h>
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
|
@ -26,6 +27,8 @@ void IRAM_ATTR __esp_platform_app_start(void)
|
|||
|
||||
esp_flash_config();
|
||||
|
||||
esp_efuse_init_virtual();
|
||||
|
||||
#if CONFIG_ESP_SPIRAM
|
||||
esp_init_psram();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <esp_private/cache_utils.h>
|
||||
#include <esp_private/system_internal.h>
|
||||
#include <esp_timer.h>
|
||||
#include <efuse_virtual.h>
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
|
||||
#include <zephyr/kernel_structs.h>
|
||||
#include <kernel_internal.h>
|
||||
|
@ -24,6 +25,8 @@ void IRAM_ATTR __esp_platform_app_start(void)
|
|||
|
||||
esp_flash_config();
|
||||
|
||||
esp_efuse_init_virtual();
|
||||
|
||||
/* Start Zephyr */
|
||||
z_cstart();
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <esp_private/cache_utils.h>
|
||||
#include <esp_private/system_internal.h>
|
||||
#include <esp_timer.h>
|
||||
#include <efuse_virtual.h>
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
|
||||
#include <zephyr/kernel_structs.h>
|
||||
#include <kernel_internal.h>
|
||||
|
@ -25,6 +26,8 @@ void IRAM_ATTR __esp_platform_app_start(void)
|
|||
|
||||
esp_flash_config();
|
||||
|
||||
esp_efuse_init_virtual();
|
||||
|
||||
/* Start Zephyr */
|
||||
z_cstart();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <esp_private/cache_utils.h>
|
||||
#include <esp_private/system_internal.h>
|
||||
#include <esp_timer.h>
|
||||
#include <efuse_virtual.h>
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
|
||||
#include <zephyr/kernel_structs.h>
|
||||
#include <kernel_internal.h>
|
||||
|
@ -24,6 +25,8 @@ void IRAM_ATTR __esp_platform_app_start(void)
|
|||
|
||||
esp_flash_config();
|
||||
|
||||
esp_efuse_init_virtual();
|
||||
|
||||
/* Start Zephyr */
|
||||
z_cstart();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <esp_private/cache_utils.h>
|
||||
#include <esp_private/system_internal.h>
|
||||
#include <esp_timer.h>
|
||||
#include <efuse_virtual.h>
|
||||
#include <psram.h>
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
|
@ -41,6 +42,8 @@ void IRAM_ATTR __esp_platform_app_start(void)
|
|||
|
||||
esp_flash_config();
|
||||
|
||||
esp_efuse_init_virtual();
|
||||
|
||||
#if CONFIG_ESP_SPIRAM
|
||||
esp_init_psram();
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <esp_private/cache_utils.h>
|
||||
#include <esp_private/system_internal.h>
|
||||
#include <esp_timer.h>
|
||||
#include <efuse_virtual.h>
|
||||
#include <psram.h>
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
|
@ -54,6 +55,8 @@ void IRAM_ATTR __esp_platform_app_start(void)
|
|||
|
||||
esp_flash_config();
|
||||
|
||||
esp_efuse_init_virtual();
|
||||
|
||||
#if CONFIG_ESP_SPIRAM
|
||||
esp_init_psram();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue