From 61b70c50a4ca11061fabcd68ad943a22492dd446 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 18 Feb 2021 15:13:50 +1100 Subject: [PATCH] freertos: Use the standard assert() function for configASSERT Unless the option for "assert and keep running" is enabled. This means that silent asserts now work for FreeRTOS, and disabling asserts now also disables them in FreeRTOS without needing a separate config change. Related to https://github.com/espressif/esp-idf/issues/6306 --- components/freertos/Kconfig | 9 ++++++++- .../port/riscv/include/freertos/FreeRTOSConfig.h | 8 ++------ .../port/xtensa/include/freertos/FreeRTOSConfig.h | 8 ++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index ad975c6510..25de7e73c7 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -141,18 +141,25 @@ menu "FreeRTOS" choice FREERTOS_ASSERT prompt "FreeRTOS assertions" - default FREERTOS_ASSERT_FAIL_ABORT + default FREERTOS_ASSERT_FAIL_ABORT if !COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE + default FREERTOS_ASSERT_DISABLE if COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE help Failed FreeRTOS configASSERT() assertions can be configured to behave in different ways. + By default these behave the same as the global project assert settings. + config FREERTOS_ASSERT_FAIL_ABORT bool "abort() on failed assertions" + depends on !COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE help If a FreeRTOS configASSERT() fails, FreeRTOS will abort() and halt execution. The panic handler can be configured to handle the outcome of an abort() in different ways. + If assertions are disabled for the entire project, they are also + disabled in FreeRTOS and this option is unavailable. + config FREERTOS_ASSERT_FAIL_PRINT_CONTINUE bool "Print and continue failed assertions" help diff --git a/components/freertos/port/riscv/include/freertos/FreeRTOSConfig.h b/components/freertos/port/riscv/include/freertos/FreeRTOSConfig.h index 62ca5ce488..63d5aa44cc 100644 --- a/components/freertos/port/riscv/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/port/riscv/include/freertos/FreeRTOSConfig.h @@ -88,7 +88,7 @@ /* configASSERT behaviour */ #ifndef __ASSEMBLER__ -#include /* for abort() */ +#include #include "esp32c3/rom/ets_sys.h" // If CONFIG_FREERTOS_ASSERT_DISABLE is set then configASSERT is defined empty later in FreeRTOS.h and the macro @@ -100,11 +100,7 @@ __FUNCTION__); \ } #elif defined(CONFIG_FREERTOS_ASSERT_FAIL_ABORT) -#define configASSERT(a) if (unlikely(!(a))) { \ - esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \ - __FUNCTION__); \ - abort(); \ - } +#define configASSERT(a) assert(a) #endif #if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION diff --git a/components/freertos/port/xtensa/include/freertos/FreeRTOSConfig.h b/components/freertos/port/xtensa/include/freertos/FreeRTOSConfig.h index 7aae48374f..93c7f81c98 100644 --- a/components/freertos/port/xtensa/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/port/xtensa/include/freertos/FreeRTOSConfig.h @@ -119,7 +119,7 @@ int xt_clock_freq(void) __attribute__((deprecated)); /* configASSERT behaviour */ #ifndef __ASSEMBLER__ -#include /* for abort() */ +#include #include "esp_rom_sys.h" #if CONFIG_IDF_TARGET_ESP32 #include "esp32/rom/ets_sys.h" // will be removed in idf v5.0 @@ -140,11 +140,7 @@ int xt_clock_freq(void) __attribute__((deprecated)); __FUNCTION__); \ } #elif defined(CONFIG_FREERTOS_ASSERT_FAIL_ABORT) -#define configASSERT(a) if (unlikely(!(a))) { \ - esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \ - __FUNCTION__); \ - abort(); \ - } +#define configASSERT(a) assert(a) #endif #if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION