From 9e0a32e011f9565dccfd66ec1f8ab85888f2daf9 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 26 Apr 2024 15:44:49 +0200 Subject: [PATCH] core/panic: make reboot on panic configurable --- core/lib/include/panic.h | 13 +++++++++++++ core/lib/panic.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/lib/include/panic.h b/core/lib/include/panic.h index 2fd453805f40..8b1b02537e48 100644 --- a/core/lib/include/panic.h +++ b/core/lib/include/panic.h @@ -28,6 +28,19 @@ extern "C" { #endif +/** + * @brief Automatically reboot the system on panic() + * + * By default this is on when @ref DEVELHELP is disabled. + */ +#ifndef CONFIG_CORE_REBOOT_ON_PANIC +#ifdef DEVELHELP +#define CONFIG_CORE_REBOOT_ON_PANIC (0) +#else +#define CONFIG_CORE_REBOOT_ON_PANIC (1) +#endif +#endif + /** * @brief Definition of available panic modes */ diff --git a/core/lib/panic.c b/core/lib/panic.c index 6e6fb5a8cf07..1b056a84eaf9 100644 --- a/core/lib/panic.c +++ b/core/lib/panic.c @@ -79,7 +79,7 @@ NORETURN void core_panic(core_panic_t crash_code, const char *message) /* disable watchdog and all possible sources of interrupts */ irq_disable(); panic_arch(); -#if !defined(DEVELHELP) && defined(MODULE_PERIPH_PM) +#if CONFIG_CORE_REBOOT_ON_PANIC && defined(MODULE_PERIPH_PM) /* DEVELHELP not set => reboot system */ pm_reboot(); #else