KGDB Kernel Debugger
This page describes how to use in-kernel KGDB to debug the Linux Kernel running on LX2162A Clearfog Board.
Requirements
On the Target (LX2162A Clearfog) a native UART from the SoC must be used. UART1 (ttyAMA0) is normally used for console access (mini-USB connector).
Additionally UART2 (ttyAMA1) is available on pin header J19.
The host may connect to the target by any suitable usb-to-uart adapters, usually showing up as /dev/ttyUSB0 or similar.
Further the kernel must be recompiled adding support for KGDB and additional symbol information:
CONFIG_KGDB=y
CONFIG_DEBUG_INFO=y
# CONFIG_DEBUG_INFO_REDUCED is not setFinally the target must disable its watchdog functionality to avoid unintended reset while debugging.
Configure Host
Dedicated UART
Debugging Linux using the LX2162A Clearfog UART2 exposed on J19 pin header at 3.3V logic level.
Note: This method currently is not functional during the author’s testing …
Share Console
Debugging Linux using the LX2162A Clearfog UART1 that is already in use for console.
Kernel developers provide a proxy tool for multiplexing between KGDB commands and the regular console from a single UART: https://git.kernel.org/pub/scm/utils/kernel/kgdb/agent-proxy.git/tree/README.TXT
It reads from the Host (PC) Serial POrt that is connected to the Target, and exposes KGDB and Console on two local network ports for access from gdb and telnet.
If on the Host side the console uart is /dev/ttyUSB0, then the agent-proxy is started as follows:
Note: Ensure no other process is opening the serial device, in particular no other terminal emulator.
Console is now available using telnet:
Note: When configuring the target, choose ttyAMA0 for KGDB.
Note: When configuring the target, choose ttyAMA0 for KGDB.
Note: When configuring the target, choose ttyAMA0for KGDB instead of dedicated ttyAMA1.
Configure Debugger on Target
Disable Watchdog
In Linux edit systemd config file to disable watchdog configuration:
In boot-loader during every boot, break to u-boot console during the timeout and stop the watchdog:
At Boot-Time
Kernel debugger can be configured using kernel cmdline passed from bootloader.
Edit extlinux.conf APPEND line and add kgdboc=ttyAMA1,115200 - e.g.:
At Run-Time
Kernel debugger can be enabled at run-time by setting the kgdboc parameter through sysfs:
Start Debugging
To start a debug session requires coordinated steps on both the Host (PC) and the Target (LX2162A Clearfog). Extra complication is added by system watchdog if it wasn’t disabled properly.
Target
A debug session on the Target is started by issuing magic sysrq - which will halt the kernel and start KGDB:
Host
The Host should connect to the Target immediately after sysrq was issued. It is recommended to first start gdb and wait while it loads vmlinux file - then issue sysrq and connect (target command).
Last updated