From 9800750f15c950d05ed874623adbc91054159a29 Mon Sep 17 00:00:00 2001 From: Felipe Neves Date: Tue, 7 Jan 2020 10:46:59 -0300 Subject: [PATCH] freertos/port: Put critical sections around uxPortCompareSetExtram() to prevent preemption during its execution. Closes: https://github.com/espressif/esp-idf/issues/4561 --- components/freertos/port.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/freertos/port.c b/components/freertos/port.c index bab93aad5a..3088fae45d 100644 --- a/components/freertos/port.c +++ b/components/freertos/port.c @@ -443,6 +443,9 @@ static portMUX_TYPE extram_mux = portMUX_INITIALIZER_UNLOCKED; void uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t compare, uint32_t *set) { uint32_t prev; + + uint32_t oldlevel = portENTER_CRITICAL_NESTED(); + #ifdef CONFIG_FREERTOS_PORTMUX_DEBUG vPortCPUAcquireMutexIntsDisabled(&extram_mux, portMUX_NO_TIMEOUT, __FUNCTION__, __LINE__); #else @@ -458,6 +461,8 @@ void uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t compare, uint32_t #else vPortCPUReleaseMutexIntsDisabled(&extram_mux); #endif + + portEXIT_CRITICAL_NESTED(oldlevel); } #endif //defined(CONFIG_SPIRAM)