How to make Raspberry Pi auto-reboot after kernel panic

Hi, I have a fairly standard Mender/Yocto build for the Raspberry Pi 3 and 4.

We’re had a few customers in the field encounter kernel panics, which required a manual power-cycle of the Pi to get it running again. So I’d like to implement auto-reboot when a kernel panic happens.

I can do this after boot using echo 20 >/proc/sys/kernel/panic, but I was if there was a more ‘proper’ way of doing it, perhaps as an argument passed in from U-Boot?

Does anyone know if this is possible?

Thanks!
James

Hi @james-onsolution,

According to The kernel’s command-line parameters — The Linux Kernel documentation you can pass `panic= " via command line. Please note that this will only catch situations where the kernel is still properly panicking. If you require more robustness, then you need to look into hardware watchdog functionality.

Greetz,
Josef

Directly in the kernel config

│ CONFIG_PANIC_TIMEOUT: │
│ │
│ Set the timeout value (in seconds) until a reboot occurs when │
│ the kernel panics. If n = 0, then we wait forever. A timeout │
│ value n > 0 will wait n seconds before rebooting, while a timeout │
│ value n < 0 will reboot immediately.

@clementp Thanks, I’ll give this CONFIG_PANIC_TIMEOUT a try soon

@TheYoctoJester In regards to the hardware watchdog, do you know if there is any information about how to get this working on the RPi? From some Googling, it looks like the Pi 3 and 4 have a hardware watchdog built in, but I can’t find much information about how to enable/configure it in Yocto and how to make sure it plays nicely with Mender

I’ve only just now revisiting this issue, and I’m not 100% sure how to implement CONFIG_PANIC_TIMEOUT. Is there any documentation you can point me towards? @clementp

Kind Regards,
James