RFC: Should the MicroPython RP2 port implement a PICO_PANIC_FUNCTION? #18736
Unanswered
Gadgetoid
asked this question in
RP2040 / Pico
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
For longer than I'd care to admit I let Pico SDK functions raise a
panicand basically lock up MicroPython with no useful output. This happens when attempting to claim DMA channels when they're exhausted, and for all sorts of other reasons that are easy to hit when re-running C/C++ device driver code upon soft reset.Defining
PICO_PANIC_FUNCTIONto print out the error usingmp_plat_printand sit in a loop reliably (as far as I can tell) gets the panic message out over USB serial and has been a time saver for chasing down hardware resource related bugs/lockups.I put this in the board config:
And this... somewhere:
Should this be included in the RP2 port by default? I don't believe it has any drawbacks. It would probably be ideal if it supplemented the format string with "PANIC: " to make it clear why the board has stopped responding.
Is there any precedent for this sort of thing in other ports I could follow?
The standard
panicimplementation is here: https://github.com/raspberrypi/pico-sdk/blob/a1438dff1d38bd9c65dbd693f0e5db4b9ae91779/src/rp2_common/pico_platform_panic/panic.c#L64-L83Beta Was this translation helpful? Give feedback.
All reactions