Serial console debugging

Setting up the serial console

1. First find which devices are attached to the system

dmesg | grep "tty"

2. For the device found above (say ttyS0), create the /etc/event.d/ttyS0 file with the following contents

# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from
# the point the system is started until it is
# shut down again.

start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5

stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

respawn
exec /sbin/getty -L 115200 ttyS0 vt102


3. Edit /etc/securetty and add ttyS0

4. During reboot edit the kernel in grub menu (press 'e'). At the end of the kernel line add console=ttyS0,115200n8 tty1

5. Boot into your kernel

6. Once you log in, if you want all the dmesg output to go on the serial console do the following:
sudo tail -f /var/log/kern.log > /dev/ttyS0

Setting up the client

1. Open minicom and set the port as the one you are talking on, it could be ttySn or ttyUSBn depending on if you are using a serial port or a USB to serial converter. (e.g. ttyS0, ttyUSB0)

2. Set the setting as 115200 baud, 8 bits, 1 stop bit, no parity, no flow control

Update: There is another program called gtkterm if you don't fancy the command line applications. Also I would recommend using konsole to run minicom within as it supports unlimited buffer, which can be very useful if you are trying to look at the /var/log/kern.log of the target machine, for example.

Update (Apr 20, 2010): Only if you want to have a serial console (like a bash on the serial port) should you do the getty for ttyS0. If you just want all the kernel message sent to the terminals just do the following:

 # echo 8 > /proc/sys/kernel/printk

Read this article for more details on kernel oops.

No comments: