2011年4月13日星期三

使用串口调试Kernel Panic

一开始,在Ubuntu环境下,尝试使用"linux-crashdump"工具集来处理。水很深,几经尝试没有成功。

1. 在VMware里边给虚拟机添加一个串口。
    Use named pipe: \\.\pipe\com_1
    This end is the server.
    The other end is an application

2. 给内核增加增加两个启动参数。
    console=ttyS0,115200 console=tty0
   使用"grub-mkconfig -o /boot/grub/grub.cfg"命令来更新GRUB2配置文件。重新启动后可以从"/proc/cmdline"看到启动参数。

3. 在PuTTY中建立一个Session,配置好"Serial line"和"Speed"项,连接即可。

4. 用快捷键"Alt+SysRq+C"或者命令"echo c > /proc/sysrqtrigger"来触发Kernel Dump,可以在PuTTY的对应的Session里边看到Dump信息。

另外,PuTTY的Session是可以记成日志的,在配置窗口左侧的"Logging"项中设置。


补充笔记:
1. 内核代码库中的相关文档。
    Documentation/oops-tracing.txt
    Documentation/serial-console.txt
    Documentation/networking/netconsole.txt

2. 如果没有指定console参数,内核就会按照VGA Card,Serial Port的顺序,直到找到第一个可作为System Console的设备。所以,一般来说,Dump信息只出现在屏幕上。

3. console参数可以写多个,输出将会在所有指定的设备上出现。

4. console参数指定的设备中,不能出现两个同类设备。如,同时指定两个串口设备作为System Console的输出就不可以。

5. console参数列表中的最后一个设备将会被用来打开"/dev/console"

6. 使用Serial Line来登录,在/etc/inittab中添加类似如下格式的信息:
    id:runlevels:action:process
如:"S1:23:respawn:/sbin/getty -L ttyS1 9600 vt100",则可以从ttyS1登录。参考"Configuring init to start getty: the /etc/inittab file"


可参考资料
1. Debugging Linux Kernel Lockup / Panic / Oops,里边有相关的内核配置选项

没有评论:

发表评论