Ankit Chilamatur
Ankit Chilamatur

Reputation: 41

Kernel panic error in ARM board

I have ARM board at remote location. Some time I had a kernel panic error in it. At this same time there is no option to hardware restart. bus no one is available at this place to restart it.

I want to restart my board automatically after kernel panic error. so what to do in kernel.

Upvotes: 2

Views: 2386

Answers (5)

kaiwan
kaiwan

Reputation: 2144

AFAIK, a simple way to restart the board after kernel panic is to pass a kernel parameter (from the bootloader usually)

 panic=1

The board will then auto-reboot '1' second(s) after a panic.

Search the Documentation for more.

Some examples from the documentation:

...
panic=      [KNL] Kernel behaviour on panic: delay <timeout>
            timeout > 0: seconds before rebooting
            timeout = 0: wait forever
            timeout < 0: reboot immediately
            Format: <timeout>
...
oops=panic  Always panic on oopses. Default is to just kill the
            process, but there is a small probability of
            deadlocking the machine.
            This will also cause panics on machine check exceptions.
            Useful together with panic=30 to trigger a reboot.
...

Upvotes: 1

artless-noise-bye-due2AI
artless-noise-bye-due2AI

Reputation: 22469

The panic() is usually due to events that the kernel can not recover from. If you do not have a watchdog, you need to look at your hardware to see if a GPIO, etc is connected to the RESET line. If so, you can toggle this pin to reboot the CPU. Trying to alter panic() may just make things worse, depending on the root cause and the type of features you use.

You may hook arm_pm_restart with your custom restart functionality. You can test it with the shell command reboot, if present. panic() should call the same routine. With current ARM Linux versions

You may wish to turn off the MMU and block interrupts in this routine. It will make it more resilient when called from panic(). As you are going to reset, you can copy the routine to any physical address you like.

The watchdog maybe better; it may catch cases where even panic() may not be called. You may have a watchdog and not realize it. Many Cortex-A CPUs, have one built in. It is fairly rare for hardware not to have a watchdog.

However, if you don't have the watchdog, you can use the GPIO mechanism above; hardware should usually provide someway for software to restart the device (and peripherals). The panic() maybe due to some mis-behaving device tromping memory, latched up DRAM/Flash, etc. Toggling a RESET line maybe better than a watchdog in this case; if the RESET is also connected to other hardware, besides the CPU.

Related: How to debug kernel freeze, How to change watchdog timer

Upvotes: 2

Sanket Parmar
Sanket Parmar

Reputation: 1577

As suggested in previous comments watchdog timer is your friend here. If your hardware contains watchdog timer, Enable it in kernel option and configure it.

Other alternative is use Phidget. If you usb connection available at remote location. Phidget controller/software is used to control your board using USB. Check for board support.

Upvotes: 0

Vignesh Radhakrishnan
Vignesh Radhakrishnan

Reputation: 132

You can modify the panic() function kernel/panic.c to call the kernel_restart(*cmd) at the point you want it to restart (like probably after printing the required debug information).

I am assuming you are bringing up a board, so Please note that you need to supply the ops for the associated functions in machine_restart() - (called by kernel_restart) in accordance to the MACH . If you are just using the board as is , then i guess rebuilding the kernel with kernel_restart(*cmd) should do.

Upvotes: 2

Jeyaram
Jeyaram

Reputation: 9494

If your hardware contains watchdog timer, then compile the kernel with watchdog support and configure it. I suggest to follow this blog http://www.jann.cc/2013/02/02/linux_watchdog.html

Caution :: I never tried this. If the problem is solved, request you to update here.

Upvotes: 2

Related Questions