FreeRTOS: Configure configASSERT fail behaviour, abort() by default

This commit is contained in:
Angus Gratton 2016-08-24 16:01:41 +08:00
parent 94104f0fe8
commit 93c92f7a5b
2 changed files with 41 additions and 3 deletions

View File

@ -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

View File

@ -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__ */
/*-----------------------------------------------------------