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);