]> granicus.if.org Git - esp-idf/commitdiff
FreeRTOS: Configure configASSERT fail behaviour, abort() by default
authorAngus Gratton <angus@espressif.com>
Wed, 24 Aug 2016 08:01:41 +0000 (16:01 +0800)
committerAngus Gratton <angus@espressif.com>
Wed, 24 Aug 2016 10:13:10 +0000 (18:13 +0800)
components/freertos/Kconfig
components/freertos/include/freertos/FreeRTOSConfig.h

index 89227a7ddfde1904bc35625f4ffcae6da05e691d..037e795bc9eeae489b322115fbec009d88c4010d 100644 (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
index c0a86efed3fd42bbdfc85a0a3ec07eed6c3cb3d3..46abb9a3b8589719fd43d7f745b358612cd1bf7a 100644 (file)
 #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__ */
 
 
 /*-----------------------------------------------------------