Skip to content

Commit a99753d

Browse files
o-marshmallowmahavirj
authored andcommitted
fix(esp_hw_support): clear the memory protection interrupt status on boot
Fixes #15359
1 parent d7222cc commit a99753d

File tree

1 file changed

+9
-2
lines changed
  • components/esp_hw_support/port/esp32s2

1 file changed

+9
-2
lines changed

components/esp_hw_support/port/esp32s2/memprot.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -787,6 +787,13 @@ esp_err_t esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uin
787787
bool use_peri1 = required_mem_prot & MEMPROT_PERI1_RTCSLOW;
788788
bool use_peri2 = required_mem_prot & MEMPROT_PERI2_RTCSLOW_0 || required_mem_prot & MEMPROT_PERI2_RTCSLOW_1;
789789

790+
// make sure there is no pending interrupt, this may be the case if the target just rebooted
791+
// after a memory protection fault.
792+
memprot_ll_iram0_clear_intr();
793+
memprot_ll_dram0_clear_intr();
794+
memprot_ll_peri1_clear_intr();
795+
memprot_ll_peri2_clear_intr();
796+
790797
//disable protection
791798
if (use_iram0 && (ret = esp_memprot_intr_ena(MEMPROT_IRAM0_SRAM, false)) != ESP_OK) {
792799
return ret;
@@ -865,7 +872,7 @@ esp_err_t esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uin
865872
}
866873
}
867874

868-
//reenable protection (bus based)
875+
//re-enable protection (bus based)
869876
if (use_iram0 && (ret = esp_memprot_intr_ena(MEMPROT_IRAM0_SRAM, true)) != ESP_OK) {
870877
return ret;
871878
}

0 commit comments

Comments
 (0)