From e29da11f6b07a40dabc37eaed406989f690f5016 Mon Sep 17 00:00:00 2001 From: Felipe Neves Date: Wed, 5 Aug 2020 18:28:37 -0300 Subject: [PATCH] freertos/portmux: increase portmux timeouts to avoid crashing when using debug feature Closes: https://github.com/espressif/esp-idf/issues/3629# --- components/esp_common/Kconfig | 2 +- components/freertos/include/freertos/portmacro.h | 5 +++++ components/freertos/portmux_impl.inc.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/esp_common/Kconfig b/components/esp_common/Kconfig index d4cdf96a85..6c5bda8a86 100644 --- a/components/esp_common/Kconfig +++ b/components/esp_common/Kconfig @@ -140,7 +140,7 @@ menu "Common ESP-related" config ESP_INT_WDT_TIMEOUT_MS int "Interrupt watchdog timeout (ms)" depends on ESP_INT_WDT - default 300 if !ESP32_SPIRAM_SUPPORT + default 600 if !ESP32_SPIRAM_SUPPORT default 800 if ESP32_SPIRAM_SUPPORT range 10 10000 help diff --git a/components/freertos/include/freertos/portmacro.h b/components/freertos/include/freertos/portmacro.h index 4ed2d56883..b2a400892e 100644 --- a/components/freertos/include/freertos/portmacro.h +++ b/components/freertos/include/freertos/portmacro.h @@ -83,6 +83,11 @@ extern "C" { #include "esp_private/crosscore_int.h" #include "esp_timer.h" /* required for FreeRTOS run time stats */ +#if CONFIG_IDF_TARGET_ESP32 +#include "esp32/clk.h" +#elif CONFIG_IDF_TARGET_ESP32S2BETA +#include "esp32s2beta/clk.h" +#endif #include diff --git a/components/freertos/portmux_impl.inc.h b/components/freertos/portmux_impl.inc.h index 07a7ce9fe1..4eb3e85af5 100644 --- a/components/freertos/portmux_impl.inc.h +++ b/components/freertos/portmux_impl.inc.h @@ -51,7 +51,7 @@ PORTMUX_AQUIRE_MUX_FN_NAME(portMUX_TYPE *mux, int timeout_cycles) { bool set_timeout = timeout_cycles > portMUX_NO_TIMEOUT; #ifdef CONFIG_FREERTOS_PORTMUX_DEBUG if (!set_timeout) { - timeout_cycles = 10000; // Always set a timeout in debug mode + timeout_cycles = 1000000 * (esp_clk_cpu_freq() / 1000000); // Always set a timeout in debug mode set_timeout = true; } #endif