From 477d11e9c1ed0944b53b66a75cc01ad1087fdd40 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Mon, 2 May 2022 10:37:19 -0300 Subject: [PATCH] bootloader: Create option for enabling memory region protection Signed-off-by: Gustavo Henrique Nihei --- components/bootloader/Kconfig.projbuild | 8 ++++++++ components/bootloader_support/src/bootloader_mem.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/components/bootloader/Kconfig.projbuild b/components/bootloader/Kconfig.projbuild index e7be47a824..fdbadc2827 100644 --- a/components/bootloader/Kconfig.projbuild +++ b/components/bootloader/Kconfig.projbuild @@ -193,6 +193,14 @@ menu "Bootloader config" The GPIO must be held low continuously for this period of time after reset before a factory reset or test partition boot (as applicable) is performed. + config BOOTLOADER_REGION_PROTECTION_ENABLE + bool "Enable protection for unmapped memory regions" + default y + help + Protects the unmapped memory regions of the entire address space from unintended accesses. + This will ensure that an exception will be triggered whenever the CPU performs a memory + operation on unmapped regions of the address space. + config BOOTLOADER_WDT_ENABLE bool "Use RTC watchdog in start code" default y diff --git a/components/bootloader_support/src/bootloader_mem.c b/components/bootloader_support/src/bootloader_mem.c index 2466a6913f..69651b6936 100644 --- a/components/bootloader_support/src/bootloader_mem.c +++ b/components/bootloader_support/src/bootloader_mem.c @@ -17,6 +17,8 @@ void bootloader_init_mem(void) { cpu_hal_init_hwloop(); +#ifdef CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE // protect memory region esp_cpu_configure_region_protection(); +#endif }