From b5bacffbd3a54a8b19ae1ebcb287cd5ce7c787fa Mon Sep 17 00:00:00 2001 From: Guillaume Souchere Date: Wed, 28 Dec 2022 10:25:42 +0100 Subject: [PATCH] esp_hw_support: allow writing in IRAM when CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT is not set for esp32C2 when CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT is not set, the PMP rule for esp32c2 shoud allow write access. Fix esp_cpu_configure_region_protection() in cpu.c accordingly. --- components/esp_hw_support/cpu.c | 7 +++++++ components/heap/test_apps/sdkconfig.defaults | 1 + 2 files changed, 8 insertions(+) diff --git a/components/esp_hw_support/cpu.c b/components/esp_hw_support/cpu.c index 9e2817c96b..79f2f4cec6 100644 --- a/components/esp_hw_support/cpu.c +++ b/components/esp_hw_support/cpu.c @@ -454,11 +454,13 @@ extern int _data_start; #define CONDITIONAL_NONE 0x0 #define CONDITIONAL_RX PMP_R | PMP_X #define CONDITIONAL_RW PMP_R | PMP_W +#define CONDITIONAL_RWX PMP_R | PMP_W | PMP_X #else // With L bit set #define CONDITIONAL_NONE NONE #define CONDITIONAL_RX RX #define CONDITIONAL_RW RW +#define CONDITIONAL_RWX RWX #endif void esp_cpu_configure_region_protection(void) @@ -525,7 +527,12 @@ void esp_cpu_configure_region_protection(void) } else { // 1. IRAM PMP_ENTRY_SET(0, SOC_DIRAM_IRAM_LOW, CONDITIONAL_NONE); + +#if CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT PMP_ENTRY_SET(1, IRAM_END, PMP_TOR | CONDITIONAL_RX); +#else + PMP_ENTRY_SET(1, IRAM_END, PMP_TOR | CONDITIONAL_RWX); +#endif // 2. DRAM PMP_ENTRY_SET(2, DRAM_START, CONDITIONAL_NONE); diff --git a/components/heap/test_apps/sdkconfig.defaults b/components/heap/test_apps/sdkconfig.defaults index bbd0363cd0..40fc15f7a7 100644 --- a/components/heap/test_apps/sdkconfig.defaults +++ b/components/heap/test_apps/sdkconfig.defaults @@ -1,6 +1,7 @@ CONFIG_COMPILER_DUMP_RTL_FILES=y CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=n # memory protection needs to be disabled for certain tests +CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT=n # for c2 and c6 this config must be disabled for certain tests CONFIG_COMPILER_STACK_CHECK_MODE_ALL=y CONFIG_COMPILER_STACK_CHECK=y