From 6b4e1619d8c533aec6edd3e047db1395a9d9ce0c Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Tue, 23 Aug 2022 17:58:14 +0800 Subject: [PATCH] TWDT: the Kconfig option ESP_TASK_WDT_EN is now used to enable Task Watchdog --- components/esp_system/CMakeLists.txt | 2 +- components/esp_system/Kconfig | 6 +++--- components/esp_system/crosscore_int.c | 8 ++++---- components/esp_system/include/esp_private/crosscore_int.h | 4 ++-- components/esp_system/include/esp_private/esp_task_wdt.h | 8 ++++---- components/esp_system/sdkconfig.rename | 1 + components/esp_system/test/test_reset_reason.c | 4 ++-- components/esp_system/test/test_task_wdt.c | 4 ++-- components/espcoredump/src/core_dump_common.c | 6 +++--- components/mbedtls/test/test_rsa.c | 8 ++++---- docs/en/api-reference/system/wdts.rst | 2 +- docs/en/migration-guides/release-5.x/system.rst | 2 +- examples/system/task_watchdog/README.md | 2 +- 13 files changed, 29 insertions(+), 28 deletions(-) diff --git a/components/esp_system/CMakeLists.txt b/components/esp_system/CMakeLists.txt index d00732c59e..25307d36ca 100644 --- a/components/esp_system/CMakeLists.txt +++ b/components/esp_system/CMakeLists.txt @@ -25,7 +25,7 @@ else() "xt_wdt.c" "debug_stubs.c") - if(CONFIG_ESP_TASK_WDT) + if(CONFIG_ESP_TASK_WDT_EN) list(APPEND srcs "task_wdt/task_wdt.c") if(CONFIG_ESP_TASK_WDT_USE_ESP_TIMER) diff --git a/components/esp_system/Kconfig b/components/esp_system/Kconfig index b117fb1e98..fd477c2848 100644 --- a/components/esp_system/Kconfig +++ b/components/esp_system/Kconfig @@ -390,7 +390,7 @@ menu "ESP System Settings" help Also detect if interrupts on CPU 1 are disabled for too long. - config ESP_TASK_WDT + config ESP_TASK_WDT_EN bool "Enable Task Watchdog Timer" default y select FREERTOS_ENABLE_TASK_SNAPSHOT @@ -404,14 +404,14 @@ menu "ESP System Settings" # Software implementation of Task Watchdog, handy for targets with only a single # Timer Group, such as the ESP32-C2 bool - depends on ESP_TASK_WDT + depends on ESP_TASK_WDT_EN default y if IDF_TARGET_ESP32C2 default n if !IDF_TARGET_ESP32C2 select ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD config ESP_TASK_WDT_INIT bool "Initialize Task Watchdog Timer on startup" - depends on ESP_TASK_WDT + depends on ESP_TASK_WDT_EN default y help Enabling this option will cause the Task Watchdog Timer to be initialized diff --git a/components/esp_system/crosscore_int.c b/components/esp_system/crosscore_int.c index a6b576a22f..2ffb6a6848 100644 --- a/components/esp_system/crosscore_int.c +++ b/components/esp_system/crosscore_int.c @@ -96,14 +96,14 @@ static void IRAM_ATTR esp_crosscore_isr(void *arg) { esp_backtrace_print(100); } -#if CONFIG_ESP_TASK_WDT +#if CONFIG_ESP_TASK_WDT_EN if (my_reason_val & REASON_TWDT_ABORT) { extern void task_wdt_timeout_abort_xtensa(bool); /* Called from a crosscore interrupt, thus, we are not the core that received * the TWDT interrupt, call the function with `false` as a parameter. */ task_wdt_timeout_abort_xtensa(false); } -#endif // CONFIG_ESP_TASK_WDT +#endif // CONFIG_ESP_TASK_WDT_EN #endif // CONFIG_IDF_TARGET_ARCH_XTENSA } @@ -173,9 +173,9 @@ void IRAM_ATTR esp_crosscore_int_send_print_backtrace(int core_id) esp_crosscore_int_send(core_id, REASON_PRINT_BACKTRACE); } -#if CONFIG_ESP_TASK_WDT +#if CONFIG_ESP_TASK_WDT_EN void IRAM_ATTR esp_crosscore_int_send_twdt_abort(int core_id) { esp_crosscore_int_send(core_id, REASON_TWDT_ABORT); } -#endif // CONFIG_ESP_TASK_WDT +#endif // CONFIG_ESP_TASK_WDT_EN #endif diff --git a/components/esp_system/include/esp_private/crosscore_int.h b/components/esp_system/include/esp_private/crosscore_int.h index e392fd1551..1bc9a79a1f 100644 --- a/components/esp_system/include/esp_private/crosscore_int.h +++ b/components/esp_system/include/esp_private/crosscore_int.h @@ -61,7 +61,7 @@ void esp_crosscore_int_send_gdb_call(int core_id); */ void esp_crosscore_int_send_print_backtrace(int core_id); -#if CONFIG_ESP_TASK_WDT +#if CONFIG_ESP_TASK_WDT_EN /** * Send an interrupt to a CPU indicating it call `task_wdt_timeout_abort_xtensa`. * This will make the CPU abort, using the interrupted task frame. @@ -74,7 +74,7 @@ void esp_crosscore_int_send_print_backtrace(int core_id); */ void esp_crosscore_int_send_twdt_abort(int core_id); -#endif // CONFIG_ESP_TASK_WDT +#endif // CONFIG_ESP_TASK_WDT_EN #endif // !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2 && !CONFIG_IDF_TARGET_ESP32C2 #ifdef __cplusplus diff --git a/components/esp_system/include/esp_private/esp_task_wdt.h b/components/esp_system/include/esp_private/esp_task_wdt.h index a9d376f272..ab9548e544 100644 --- a/components/esp_system/include/esp_private/esp_task_wdt.h +++ b/components/esp_system/include/esp_private/esp_task_wdt.h @@ -9,7 +9,7 @@ #include "sdkconfig.h" #include "esp_err.h" -#if CONFIG_ESP_TASK_WDT +#if CONFIG_ESP_TASK_WDT_EN #ifdef __cplusplus extern "C" { @@ -29,7 +29,7 @@ typedef void (*twdt_isr_callback)(void*); /** * @brief Stop the Task Watchdog Timer (TWDT) * - * This function will temporarily stop the timer until it is restarted/resumed by a call to esp_task_wdt_restart(). + * This function will temporarily stop the timer until it is restarted by a call to esp_task_wdt_restart(). * @note esp_task_wdt_stop() must not be called by multiple tasks simultaneously. * @return @@ -41,7 +41,7 @@ esp_err_t esp_task_wdt_stop(void); /** * @brief Restart the Task Watchdog Timer (TWDT) * - * This function will restart/resume the timer after it has been stopped by esp_task_wdt_stop(). + * This function will restart the timer after it has been stopped by esp_task_wdt_stop(). * @note esp_task_wdt_restart() must not be called by multiple tasks simultaneously. * @return @@ -54,4 +54,4 @@ esp_err_t esp_task_wdt_restart(void); } #endif -#endif // CONFIG_ESP_TASK_WDT +#endif // CONFIG_ESP_TASK_WDT_EN diff --git a/components/esp_system/sdkconfig.rename b/components/esp_system/sdkconfig.rename index 5a9dc895b7..826f9cb0a3 100644 --- a/components/esp_system/sdkconfig.rename +++ b/components/esp_system/sdkconfig.rename @@ -26,6 +26,7 @@ CONFIG_TASK_WDT_PANIC CONFIG_ESP_TASK_WDT_PANI CONFIG_TASK_WDT_TIMEOUT_S CONFIG_ESP_TASK_WDT_TIMEOUT_S CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0 CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1 +CONFIG_ESP_TASK_WDT CONFIG_ESP_TASK_WDT_INIT CONFIG_ESP32_DEBUG_STUBS_ENABLE CONFIG_ESP_DEBUG_STUBS_ENABLE CONFIG_BROWNOUT_DET CONFIG_ESP_BROWNOUT_DET diff --git a/components/esp_system/test/test_reset_reason.c b/components/esp_system/test/test_reset_reason.c index 5c474af42e..60b1c343a4 100644 --- a/components/esp_system/test/test_reset_reason.c +++ b/components/esp_system/test/test_reset_reason.c @@ -222,7 +222,7 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_INT_WDT after interrupt watchdog do_int_wdt_hw, check_reset_reason_int_wdt); -#if CONFIG_ESP_TASK_WDT +#if CONFIG_ESP_TASK_WDT_EN static void do_task_wdt(void) { setup_values(); @@ -252,7 +252,7 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_TASK_WDT after task watchdog", "[reset_reason][reset="RESET"]", do_task_wdt, check_reset_reason_task_wdt); -#endif // CONFIG_ESP_TASK_WDT +#endif // CONFIG_ESP_TASK_WDT_EN static void do_rtc_wdt(void) { diff --git a/components/esp_system/test/test_task_wdt.c b/components/esp_system/test/test_task_wdt.c index 6684066707..858dcd9ecf 100644 --- a/components/esp_system/test/test_task_wdt.c +++ b/components/esp_system/test/test_task_wdt.c @@ -6,7 +6,7 @@ #include "sdkconfig.h" -#if CONFIG_ESP_TASK_WDT +#if CONFIG_ESP_TASK_WDT_EN #include #include "unity.h" @@ -153,4 +153,4 @@ TEST_CASE("Task WDT user feed", "[task_wdt]") TEST_ASSERT_EQUAL(ESP_OK, esp_task_wdt_deinit()); } -#endif // CONFIG_ESP_TASK_WDT +#endif // CONFIG_ESP_TASK_WDT_EN diff --git a/components/espcoredump/src/core_dump_common.c b/components/espcoredump/src/core_dump_common.c index 3935f78c7f..24607d1b65 100644 --- a/components/espcoredump/src/core_dump_common.c +++ b/components/espcoredump/src/core_dump_common.c @@ -294,7 +294,7 @@ inline bool esp_core_dump_tcb_addr_is_sane(uint32_t addr) inline bool esp_core_dump_in_isr_context(void) { -#if CONFIG_ESP_TASK_WDT +#if CONFIG_ESP_TASK_WDT_EN /* This function will be used to check whether a panic occurred in an ISR. * In that case, the execution frame must be switch to the interrupt stack. * However, in case where the task watchdog ISR calls the panic handler, @@ -304,9 +304,9 @@ inline bool esp_core_dump_in_isr_context(void) * TODO: IDF-5694. */ extern bool g_twdt_isr; return xPortInterruptedFromISRContext() && !g_twdt_isr; -#else // CONFIG_ESP_TASK_WDT +#else // CONFIG_ESP_TASK_WDT_EN return xPortInterruptedFromISRContext(); -#endif // CONFIG_ESP_TASK_WDT +#endif // CONFIG_ESP_TASK_WDT_EN } inline core_dump_task_handle_t esp_core_dump_get_current_task_handle() diff --git a/components/mbedtls/test/test_rsa.c b/components/mbedtls/test/test_rsa.c index dd0800161d..d6337dba5c 100644 --- a/components/mbedtls/test/test_rsa.c +++ b/components/mbedtls/test/test_rsa.c @@ -570,7 +570,7 @@ TEST_CASE("mbedtls RSA Generate Key", "[mbedtls][timeout=60]") const unsigned int key_size = 2048; const int exponent = 65537; -#if CONFIG_MBEDTLS_MPI_USE_INTERRUPT && CONFIG_ESP_TASK_WDT && !CONFIG_ESP_TASK_WDT_INIT +#if CONFIG_MBEDTLS_MPI_USE_INTERRUPT && CONFIG_ESP_TASK_WDT_EN && !CONFIG_ESP_TASK_WDT_INIT /* Check that generating keys doesnt starve the watchdog if interrupt-based driver is used */ esp_task_wdt_config_t twdt_config = { .timeout_ms = 1000, @@ -578,7 +578,7 @@ TEST_CASE("mbedtls RSA Generate Key", "[mbedtls][timeout=60]") .trigger_panic = true, }; TEST_ASSERT_EQUAL(ESP_OK, esp_task_wdt_init(&twdt_config)); -#endif // CONFIG_MBEDTLS_MPI_USE_INTERRUPT && CONFIG_ESP_TASK_WDT && !CONFIG_ESP_TASK_WDT_INIT +#endif // CONFIG_MBEDTLS_MPI_USE_INTERRUPT && CONFIG_ESP_TASK_WDT_EN && !CONFIG_ESP_TASK_WDT_INIT mbedtls_rsa_init(&ctx); mbedtls_ctr_drbg_init(&ctr_drbg); @@ -592,9 +592,9 @@ TEST_CASE("mbedtls RSA Generate Key", "[mbedtls][timeout=60]") mbedtls_ctr_drbg_free(&ctr_drbg); mbedtls_entropy_free(&entropy); -#if CONFIG_MBEDTLS_MPI_USE_INTERRUPT && CONFIG_ESP_TASK_WDT && !CONFIG_ESP_TASK_WDT_INIT +#if CONFIG_MBEDTLS_MPI_USE_INTERRUPT && CONFIG_ESP_TASK_WDT_EN && !CONFIG_ESP_TASK_WDT_INIT TEST_ASSERT_EQUAL(ESP_OK, esp_task_wdt_deinit()); -#endif // CONFIG_MBEDTLS_MPI_USE_INTERRUPT && CONFIG_ESP_TASK_WDT && !CONFIG_ESP_TASK_WDT_INIT +#endif // CONFIG_MBEDTLS_MPI_USE_INTERRUPT && CONFIG_ESP_TASK_WDT_EN && !CONFIG_ESP_TASK_WDT_INIT } diff --git a/docs/en/api-reference/system/wdts.rst b/docs/en/api-reference/system/wdts.rst index 280e2a705e..40c42cf8a2 100644 --- a/docs/en/api-reference/system/wdts.rst +++ b/docs/en/api-reference/system/wdts.rst @@ -107,7 +107,7 @@ The following config options control TWDT configuration. They are all enabled by .. list:: - - :ref:`CONFIG_ESP_TASK_WDT` - enables TWDT feature. If this option is disabled, TWDT cannot be used, even if initialized at runtime. + - :ref:`CONFIG_ESP_TASK_WDT_EN` - enables TWDT feature. If this option is disabled, TWDT cannot be used, even if initialized at runtime. - :ref:`CONFIG_ESP_TASK_WDT_INIT` - the TWDT is initialized automatically during startup. If this option is disabled, it is still possible to initialize the Task WDT at runtime by calling :cpp:func:`esp_task_wdt_init`. - :ref:`CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0` - {IDF_TARGET_IDLE_TASK} is subscribed to the TWDT during startup. If this option is disabled, it is still possible to subscribe the idle task by calling :cpp:func:`esp_task_wdt_init` again. :not CONFIG_FREERTOS_UNICORE: - :ref:`CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1` - CPU1 Idle task is subscribed to the TWDT during startup. diff --git a/docs/en/migration-guides/release-5.x/system.rst b/docs/en/migration-guides/release-5.x/system.rst index a20b83f8f2..88d49cb9f4 100644 --- a/docs/en/migration-guides/release-5.x/system.rst +++ b/docs/en/migration-guides/release-5.x/system.rst @@ -115,7 +115,7 @@ Task Watchdog Timers - Configuration is now passed as a configuration structure. - The function will now handle subscribing of the idle tasks if configured to do so. -- The former :ref:`CONFIG_ESP_TASK_WDT` configuration option has been renamed to :ref:`CONFIG_ESP_TASK_WDT_INIT` and a new :ref:`CONFIG_ESP_TASK_WDT` option has been introduced. +- The former ``CONFIG_ESP_TASK_WDT`` configuration option has been renamed to :ref:`CONFIG_ESP_TASK_WDT_INIT` and a new :ref:`CONFIG_ESP_TASK_WDT_EN` option has been introduced. FreeRTOS -------- diff --git a/examples/system/task_watchdog/README.md b/examples/system/task_watchdog/README.md index 7c4a9d631e..e04259d6fc 100644 --- a/examples/system/task_watchdog/README.md +++ b/examples/system/task_watchdog/README.md @@ -21,7 +21,7 @@ Before project configuration and build, be sure to set the correct chip target u ### Configure the project -Program should run correctly without needing any special configuration. However, users can disable `CONFIG_ESP_TASK_WDT` which will prevent the TWDT from being automatically initialized on startup. If disabled, the example will manually initialize the TWDT. +Program should run correctly without needing any special configuration. However, users can disable `CONFIG_ESP_TASK_WDT_INIT` which will prevent the TWDT from being automatically initialized on startup. If disabled, the example will manually initialize the TWDT. ### Build and Flash