mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 11:17:20 +02:00
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
This commit is contained in:
@@ -141,18 +141,25 @@ menu "FreeRTOS"
|
|||||||
|
|
||||||
choice FREERTOS_ASSERT
|
choice FREERTOS_ASSERT
|
||||||
prompt "FreeRTOS assertions"
|
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
|
help
|
||||||
Failed FreeRTOS configASSERT() assertions can be configured to
|
Failed FreeRTOS configASSERT() assertions can be configured to
|
||||||
behave in different ways.
|
behave in different ways.
|
||||||
|
|
||||||
|
By default these behave the same as the global project assert settings.
|
||||||
|
|
||||||
config FREERTOS_ASSERT_FAIL_ABORT
|
config FREERTOS_ASSERT_FAIL_ABORT
|
||||||
bool "abort() on failed assertions"
|
bool "abort() on failed assertions"
|
||||||
|
depends on !COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE
|
||||||
help
|
help
|
||||||
If a FreeRTOS configASSERT() fails, FreeRTOS will abort() and
|
If a FreeRTOS configASSERT() fails, FreeRTOS will abort() and
|
||||||
halt execution. The panic handler can be configured to handle
|
halt execution. The panic handler can be configured to handle
|
||||||
the outcome of an abort() in different ways.
|
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
|
config FREERTOS_ASSERT_FAIL_PRINT_CONTINUE
|
||||||
bool "Print and continue failed assertions"
|
bool "Print and continue failed assertions"
|
||||||
help
|
help
|
||||||
|
@@ -88,7 +88,7 @@
|
|||||||
|
|
||||||
/* configASSERT behaviour */
|
/* configASSERT behaviour */
|
||||||
#ifndef __ASSEMBLER__
|
#ifndef __ASSEMBLER__
|
||||||
#include <stdlib.h> /* for abort() */
|
#include <assert.h>
|
||||||
#include "esp32c3/rom/ets_sys.h"
|
#include "esp32c3/rom/ets_sys.h"
|
||||||
|
|
||||||
#if defined(CONFIG_FREERTOS_ASSERT_DISABLE)
|
#if defined(CONFIG_FREERTOS_ASSERT_DISABLE)
|
||||||
@@ -98,12 +98,8 @@
|
|||||||
esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \
|
esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \
|
||||||
__FUNCTION__); \
|
__FUNCTION__); \
|
||||||
}
|
}
|
||||||
#else /* CONFIG_FREERTOS_ASSERT_FAIL_ABORT */
|
#elif defined(CONFIG_FREERTOS_ASSERT_FAIL_ABORT)
|
||||||
#define configASSERT(a) if (unlikely(!(a))) { \
|
#define configASSERT(a) assert(a)
|
||||||
esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \
|
|
||||||
__FUNCTION__); \
|
|
||||||
abort(); \
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
|
#if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
|
||||||
|
@@ -119,7 +119,7 @@ int xt_clock_freq(void) __attribute__((deprecated));
|
|||||||
|
|
||||||
/* configASSERT behaviour */
|
/* configASSERT behaviour */
|
||||||
#ifndef __ASSEMBLER__
|
#ifndef __ASSEMBLER__
|
||||||
#include <stdlib.h> /* for abort() */
|
#include <assert.h>
|
||||||
#include "esp_rom_sys.h"
|
#include "esp_rom_sys.h"
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
#include "esp32/rom/ets_sys.h" // will be removed in idf v5.0
|
#include "esp32/rom/ets_sys.h" // will be removed in idf v5.0
|
||||||
@@ -138,12 +138,8 @@ int xt_clock_freq(void) __attribute__((deprecated));
|
|||||||
esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \
|
esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \
|
||||||
__FUNCTION__); \
|
__FUNCTION__); \
|
||||||
}
|
}
|
||||||
#else /* CONFIG_FREERTOS_ASSERT_FAIL_ABORT */
|
#elif defined(CONFIG_FREERTOS_ASSERT_FAIL_ABORT)
|
||||||
#define configASSERT(a) if (unlikely(!(a))) { \
|
#define configASSERT(a) assert(a)
|
||||||
esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \
|
|
||||||
__FUNCTION__); \
|
|
||||||
abort(); \
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
|
#if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
|
||||||
|
Reference in New Issue
Block a user