Skip to content

Commit 84665de

Browse files
yonschcarlescufi
authored andcommitted
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 <[email protected]>
1 parent 48000cd commit 84665de

File tree

1 file changed

+17
-0
lines changed
  • soc/arm/rpi_pico/rp2

1 file changed

+17
-0
lines changed

soc/arm/rpi_pico/rp2/soc.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
* for the Raspberry Pi RP2040 family processor.
1414
*/
1515

16+
#include <stdio.h>
17+
1618
#include <zephyr/kernel.h>
1719
#include <zephyr/init.h>
1820
#include <zephyr/logging/log.h>
21+
#include <zephyr/fatal.h>
1922

2023
#include <hardware/regs/resets.h>
2124
#include <hardware/clocks.h>
@@ -61,4 +64,18 @@ static int rp2040_init(const struct device *arg)
6164
return 0;
6265
}
6366

67+
/*
68+
* Some pico-sdk drivers call panic on fatal error.
69+
* This alternative implementation of panic handles the panic
70+
* through Zephyr.
71+
*/
72+
void __attribute__((noreturn)) panic(const char *fmt, ...)
73+
{
74+
va_list args;
75+
76+
va_start(args, fmt);
77+
vprintf(fmt, args);
78+
k_fatal_halt(K_ERR_CPU_EXCEPTION);
79+
}
80+
6481
SYS_INIT(rp2040_init, PRE_KERNEL_1, 0);

0 commit comments

Comments
 (0)