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 <yonatan.schachter@gmail.com>
This commit is contained in:
Yonatan Schachter 2022-02-26 19:25:03 +02:00 committed by Carles Cufí
parent 48000cd5a4
commit 84665de122

View File

@ -13,9 +13,12 @@
* for the Raspberry Pi RP2040 family processor.
*/
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/init.h>
#include <zephyr/logging/log.h>
#include <zephyr/fatal.h>
#include <hardware/regs/resets.h>
#include <hardware/clocks.h>
@ -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);