Debug the Linux kernel with a serial line

Source: Internet
Author: User

First, the environment

Ubuntu 14.04

A PC with serial port (number PC1, Debug machine)

Another PC connects the PC1 (number PC2, the machine that initiates the debug command) via USB to serial cable

Second, serial line configuration and testing

Installing cutecom

USB to serial port connected to the PC2, and connected to the PC1

PC1 and PC2 use sudo cutecom to open the serial software

Use/DEV/TTYS0 same baud rate 115200 on PC1 on/dev/ttyusb0 PC2

Test: PC1 send data, PC2 can receive and echo normally.

Third, compile and install the kernel

Compile in PC2, and then build the *header*.deb and *image*.deb in PC1 and install them.

sudo make Menuconfig

sudo make-kpkg--initrd--revision 1.0--append-to-version-2016 kernel_image kernel_headers

sudo dpkg-i *headers*.deb

sudo dpkg-i *image*.deb

Four, PC1 dynamic start debugging options

echo ttys0,115200 >/sys/module/kgdboc/parameters/kgdboc

V. Test configuration Results

PC1 Run the following command

sudo su

echo g >/proc/sysrq-trigger

PC2 into the Linux kernel source directory and run

GDB Vmlinux

>set Serial baud 115200

>target remote/dev/ttyusb0

After normal then can see PC2 into Linux corresponding code snippet

Vi. reference materials

Dual-machine kernel debug via kgdb-Blog channel-csdn.net

KGDB with Virtualbox:debug a Live kernel-open Source for you

Kernel Debugging and Tracing Linux Update

GDB-KGDB remote Debugging connection issue via USB and Serial Connection-stack Overflow

Chapter 5. Using Kgdb/gdb

Debug the Linux kernel with a serial line

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.