From 84665de122cffd641bd42322150fbb5dc89db91c Mon Sep 17 00:00:00 2001 From: Yonatan Schachter Date: Sat, 26 Feb 2022 19:25:03 +0200 Subject: [PATCH] soc: rpi_pico: Added panic handler Some pico-sdk drivers call a panic function, originally implemented as part of the Pico's C runtime. This commit adds a Zephyr compatible implementation of panic, so that those drivers could be compiled with Zephyr. Signed-off-by: Yonatan Schachter --- soc/arm/rpi_pico/rp2/soc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/soc/arm/rpi_pico/rp2/soc.c b/soc/arm/rpi_pico/rp2/soc.c index 3df9b983723..69681016b38 100644 --- a/soc/arm/rpi_pico/rp2/soc.c +++ b/soc/arm/rpi_pico/rp2/soc.c @@ -13,9 +13,12 @@ * for the Raspberry Pi RP2040 family processor. */ +#include + #include #include #include +#include #include #include @@ -61,4 +64,18 @@ static int rp2040_init(const struct device *arg) return 0; } +/* + * Some pico-sdk drivers call panic on fatal error. + * This alternative implementation of panic handles the panic + * through Zephyr. + */ +void __attribute__((noreturn)) panic(const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vprintf(fmt, args); + k_fatal_halt(K_ERR_CPU_EXCEPTION); +} + SYS_INIT(rp2040_init, PRE_KERNEL_1, 0);