From 3359f266891636d2b10a40d4bd976584df40461a Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 26 Apr 2024 14:07:24 +0200 Subject: [PATCH 1/3] core/assert: move common code to inline function --- core/lib/assert.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/core/lib/assert.c b/core/lib/assert.c index 002aed0bda..fb4ff644bf 100644 --- a/core/lib/assert.c +++ b/core/lib/assert.c @@ -24,11 +24,12 @@ #include "backtrace.h" #endif -__NORETURN void _assert_failure(const char *file, unsigned line) +__NORETURN static inline void _assert_common(void) { - printf("%s:%u => ", file, line); #if IS_USED(MODULE_BACKTRACE) +#ifdef DEBUG_ASSERT_VERBOSE printf("failed assertion. Backtrace:\n"); +#endif backtrace_print(); #endif #ifdef DEBUG_ASSERT_BREAKPOINT @@ -37,16 +38,16 @@ __NORETURN void _assert_failure(const char *file, unsigned line) core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION."); } +__NORETURN void _assert_failure(const char *file, unsigned line) +{ + printf("%s:%u => ", file, line); + _assert_common(); +} + __NORETURN void _assert_panic(void) { printf("%" PRIxTXTPTR "\n", cpu_get_caller_pc()); -#if IS_USED(MODULE_BACKTRACE) - backtrace_print(); -#endif -#ifdef DEBUG_ASSERT_BREAKPOINT - DEBUG_BREAKPOINT(1); -#endif - core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION."); + _assert_common(); } /** @} */ From 731ada03e584a8216f9f4ebacfd04d96e966df03 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 26 Apr 2024 14:16:17 +0200 Subject: [PATCH 2/3] core/assert: halt running thread instead of panic --- core/lib/assert.c | 7 +++++++ core/lib/include/assert.h | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/core/lib/assert.c b/core/lib/assert.c index fb4ff644bf..73558e8cf9 100644 --- a/core/lib/assert.c +++ b/core/lib/assert.c @@ -19,6 +19,7 @@ #include "architecture.h" #include "cpu.h" #include "debug.h" +#include "irq.h" #include "panic.h" #if IS_USED(MODULE_BACKTRACE) #include "backtrace.h" @@ -35,6 +36,12 @@ __NORETURN static inline void _assert_common(void) #ifdef DEBUG_ASSERT_BREAKPOINT DEBUG_BREAKPOINT(1); #endif + if (DEBUG_ASSERT_NO_PANIC && !irq_is_in() && irq_is_enabled()) { + puts("FAILED ASSERTION."); + while (1) { + thread_sleep(); + } + } core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION."); } diff --git a/core/lib/include/assert.h b/core/lib/include/assert.h index 55bfd29386..665813c92c 100644 --- a/core/lib/include/assert.h +++ b/core/lib/include/assert.h @@ -157,6 +157,15 @@ __NORETURN void _assert_panic(void); #endif #endif +/** + * @brief Don't panic on a failed assertion, just halt the running thread. + * + * If the assertion failed in an interrupt, the system will still panic. + */ +#ifndef DEBUG_ASSERT_NO_PANIC +#define DEBUG_ASSERT_NO_PANIC (1) +#endif + #ifdef __cplusplus } #endif From a28e98b36d8b690799ae3c0f98bcae412a19f1dc Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 29 Apr 2024 11:01:18 +0200 Subject: [PATCH 3/3] examples/dtls-wolfssl: add maple-mini to Makefile.ci --- examples/dtls-wolfssl/Makefile.ci | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/dtls-wolfssl/Makefile.ci b/examples/dtls-wolfssl/Makefile.ci index 4783cb20a8..7c669944d1 100644 --- a/examples/dtls-wolfssl/Makefile.ci +++ b/examples/dtls-wolfssl/Makefile.ci @@ -35,6 +35,7 @@ BOARD_INSUFFICIENT_MEMORY := \ nucleo-l031k6 \ nucleo-l053r8 \ nucleo-l412kb \ + maple-mini \ olimexino-stm32 \ opencm904 \ samd10-xmini \