Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Debugging on DaVinci using kgdb

From Texas Instruments Wiki
Jump to: navigation, search

Debugging DaVinci Linux Kernel using kgdb

This topic discusses the main ways of using kgdb (1) for debugging Linux kernel. For debugging Linux user space programs see debugging remotely on DaVinci using gdb article.

The purpose of this page is to give users the minimum amount they need to know to get their debug session up and running, given specific setups.

(1) Note: For availability of kgdb see section below, the links and versions in that article are outdated.

Availability of kgdb patches

Linux kernel kgdb patches are currently (~2.6.23 time) not part of the official Linux git Kernel and therefore are not included in DaVinci git kernel as well.

  • Montavista did the job for including them in their kernel
  • For recent git kernel you have to patch kernel with kgdb patches on your own.

Rebuilding Kernel with kgdb support

Launch kernel configuration menu using the following command

make ARCH=arm CROSS_COMPILE=arm_v5t_le- menuconfig

Enable the following options in kernel configuration menu

a) CONFIG_NETCONSOLE (Networking support -> Network console logging support)

b) CONFIG_DEBUG_KERNEL (Kernel hacking -> Kernel Debugging)

c) CONFIG_KGDB (Kernel hacking -> KGDB)

d) CONFIG_KGDB_ETH (Kernel hacking -> KGDB -> Method of KGDB communication -> Ethernet)

After enabling the options in menuconfig rebuild the kernel and any other modules in your system (e.g. CMEM, DSP Link, etc).

Target configuration

Target is configured by additional Linux kernel arguments passed e.g. via U-Boot. Add kgdboe option in bootargs environment variable on U-Boot prompt.

  • target-port (optional): GDB port (default 6443)
  • target-ip: target ip address (i.e DVEVM ip address)
  • dev (optional): network interface (default eth0)
  • host-port (optional): Host port use to send/recieve UDP packets (default 6442)
  • host-ip: Host IP address

Example for U-Boot configuration:

DVEVM# setenv bootargs ... kgdboe=@,@

Note that in this example host IP address is and DVEVM IP address is (same as you normally set in U-Boot parameters serverip and ipaddr).

Host configuration

Go to Linux kernel main directory (where you executed make uImage and where the main Linux kernel executable vmlinux is located) and there create a file .gdbinit:

touch .gdbinit

Edit this with your preferred editor and add

target remote udp:

(with IP address of the target the host should connect to, same as used above in target configuration).

Connecting from Host

1. Boot DVEVM with the kgdb kernel. In boot messages you should get anything like

TI DaVinci EMAC: MAC address is deadbeaf
TI DaVinci EMAC Linux version updated 4.0
TI DaVinci EMAC: Installed 1 instances.
netconsole: not configured, aborting
kgdboe: local port 6443
kgdboe: local IP
kgdboe: interface eth0
kgdboe: remote port 6442
kgdboe: remote IP
kgdboe: remote ethernet address ff:ff:ff:ff:ff:ff
kgdboe: device eth0 not up yet, forcing it
kgdboe: debugging over ethernet enabled

2. Start cross debugging on Host machine

  $ arm_v5t_le-gdb vmlinux
  GNU gdb 6.3 (MontaVista 6.3- 2005-07-23)
  Copyright 2004 Free Software Foundation, Inc.
  GDB is free software, covered by the GNU General Public License, and you are
  welcome to change it and/or distribute copies of it under certain conditions.
  Type "show copying" to see the conditions.
  There is absolutely no warranty for GDB.  Type "show warranty" for details.
  This GDB was configured as "--host=i686-pc-linux-gnu --target=armv5tl-montavista-linuxeabi".
  warning: The remote protocol may be unreliable over UDP
  warning: some events may be lost, rendering further debugging impossible
  0xc00533dc in breakpoint () at kernel/kgdb.c:1620
  1620                 atomic_set(&kgdb_setting_breakpoint,1);

Further reading

Included in the kgdb kernel patch is documentation. To get this, in Linux main directory on host (where you executed make uImage) e.g. call

make htmldocs

After some time, redirect your web browser to file index.html in Linux kernel documentation subdirectory


There you should find now an entry kgdb with further infos.

Graphical debugging

As seen above, using "raw" gdb is debugging on command line. If you like graphical kernel debugging, you can use e.g. ddd. See How to use the DDD on the top of the GNU Cross Debugger for how to do this (this uses m68k-elf-gdb, but it applies the same way for DaVinci using e.g. arm_v5t_le-gdb instead of m68k-elf-gdb). Instead of $ arm_v5t_le-gdb vmlinux like above do

$ ddd --debugger arm_v5t_le-gdb vmlinux

which then looks like

Ddd davinci.jpg