diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index 89227a7ddf..037e795bc9 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -121,5 +121,30 @@ config FREERTOS_DEBUG_OCDAWARE The FreeRTOS panic and unhandled exception handers can detect a JTAG OCD debugger and instead of panicking, have the debugger stop on the offending instruction. +choice FREERTOS_ASSERT + prompt "FreeRTOS assertions" + default FREERTOS_ASSERT_FAIL_ABORT + help + Failed FreeRTOS configASSERT() assertions can be configured to + behave in different ways. + +config FREERTOS_ASSERT_FAIL_ABORT + bool "abort() on failed assertions" + 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. + +config FREERTOS_ASSERT_FAIL_PRINT_CONTINUE + bool "Print and continue failed assertions" + help + If a FreeRTOS assertion fails, print it out and continue. + +config FREERTOS_ASSERT_DISABLE + bool "Disable FreeRTOS assertions" + help + FreeRTOS configASSERT() will not be compiled into the binary. + +endchoice endmenu diff --git a/components/freertos/include/freertos/FreeRTOSConfig.h b/components/freertos/include/freertos/FreeRTOSConfig.h index c0a86efed3..46abb9a3b8 100644 --- a/components/freertos/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/include/freertos/FreeRTOSConfig.h @@ -106,12 +106,25 @@ #include "xtensa_config.h" -#if 1 +/* configASSERT behaviour */ #ifndef __ASSEMBLER__ #include "rom/ets_sys.h" -#define configASSERT(a) if (!(a)) ets_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, __FUNCTION__) -#endif + +#if defined(CONFIG_FREERTOS_ASSERT_DISABLE) +#define configASSERT(a) /* assertions disabled */ +#elif defined(CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE) +#define configASSERT(a) if (!(a)) { \ + ets_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \ + __FUNCTION__); \ + } +#else /* CONFIG_FREERTOS_ASSERT_FAIL_ABORT */ +#define configASSERT(a) if (!(a)) { \ + ets_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \ + __FUNCTION__); \ + abort(); \ + } #endif +#endif /* def __ASSEMBLER__ */ /*-----------------------------------------------------------