Linux Debug infrastructure (Kernel debugging using KGDB)

Enabling KGDB with Petalinux

  • Pre-requisites
    • Petalinux environment (set the required environment set for petalinux)
    • Petalinux (source from Petalinux daily)
    • Petalinux project (create). petalinux-create -t project -s <hardware_specific.bsp>
    • $ petalinux-create -t kgdb -s /proj/petalinux/2018.3/petalinux-v2018.3_daily_latest/bsp/release/xilinx-zcu102-v2018.3-final.bsp

  • Modifying Linux-kernel This step is to enable Kernel-configs for KGDB (module can be enabled by selecting that module and pressing ‘y’)
    • To configure kernel use Petalinux-config. This will open kernel menu-config.
    • $ petalinux-config -c kernel

check project-spec/meta-user/recipes-kernel/linux/linux-xlnx/user_xx.cfg for following configs-

  • Building Project the boot images. To build the project use petalinux-build
      • $ petalinux-build

Working with ARM-DCC

  • On development hardware-
    • Boot the hardware
    • select the console for debugging. echo ttyPS0 > /sys/module/kgdboc/parameters/kgdboc. Following logs should show up-

      • [   60.352486] KGDB: Registered I/O driver kgdboc
      • [   60.372279] KGDB: Waiting for connection from remote gdb...
  • On host PC-
    • change to the images directory of the project. cd images/linux/. locate vmlinux binary
    • launch gdb with vmlinux
    • aarch64-linux-gnu-gdb -b 115200 ./vmlinux
    • Once gdb prompt is up. select the host-remote tty interface. 
    • target remote /dev/ttyUSB0
    • Once connection is established, carry on with debugging. Set breakpoints, run kernel etc..