Got this from Here. Posting only the portion I was interested in.
Accessing the printk buffer after a silent hang on boot.
This can also be useful when we are debugging the power management (that’s what I was doing when I wrote this).
Sometimes, if the kernel hangs early in the boot process, you get no messages on the console before the hang. Sometimes it's just "Uncompressing Linux.......". That's it.
However, there may still be messages in the printk buffer, which can give you an idea of where the problem is. The kernel starts putting messages into the printk buffer as soon as it starts. They stay buffered there until the console code has a chance to initialize the console device (often the serial port for embedded devices). Even though these messages are not printed before the hang, it is still possible in some circumstances to dump the printk buffer and see the messages.
When the kernel crashes as soon as it starts booting without any prints then its possible to dump the printk buffer from the boot loader. To do it you have to know how your boot loader maps memory compared to the kernel.
U-boot example on an OMAP OSK based board
When the kernel crashes, reset the board and drop to the boot loader prompt. Its important that you don't power cycle the board.
In the source tree of the compiled kernel which just crashed do
grep __log_buf System.map |
or
grep __log_buf /proc/kallsyms |
This showed
$ grep __log_buf System.map |
In our case, this address maps to 0x101eca94. So I reset the target board and use the following:
OMAP5912 OSK # md 0x101eca94 |
Similarly, the following steps shows the printk buffer (usually what got printed just before reset)
grep printk_buf System.map |
this shows the linked address of the printk_buf, e.g.:
c01ec5f4 b printk_buf.5 |
The address "c01ec5f4 " is in kernel virtual. Find the physical address mapping of it. So, after resetting the target board, but without letting it try to boot again, at the boot loader prompt
OMAP5912 OSK # md 101ec5f4 |
And you see the printk buffer that never got flushed to the UART. Knowing what's there can be very useful in debugging.
No comments:
Post a Comment