The University of Queensland Homepage
School of ITEE ITEE Main Website

 Debugging the Kernel

Debugging the Kernel

The hardware debugging facilities present in recent MicroBlaze/EDK releases makes life a lot easier when trying to debug the kernel.  The MicroBlaze Debug Module (MDM) is a core that is instantiated along with the rest of your MicroBlaze system.  It provides hardware debug functionailty, controlled by the XMD program that executes on your host machine (Linux or Windows).

The following provides a simple introduction to hardware-based kernel debugging on the MicroBlaze uClinux platform.  Note that the instructions here do not apply for debugging user applications on the platform.  That is still being worked on.

Requirements

BEGIN opb_mdm
PARAMETER INSTANCE = debug_module
PARAMETER HW_VER = 2.00.a
PARAMETER C_MB_DBG_PORTS = 1
PARAMETER C_USE_UART = 1
PARAMETER C_UART_WIDTH = 8
PARAMETER C_BASEADDR = 0xFFFFC000
PARAMETER C_HIGHADDR = 0xFFFFC0FF
PARAMETER C_WRITE_FSL_PORTS = 1
BUS_INTERFACE MFSL0 = download_link
BUS_INTERFACE SOPB = d_opb_v20
PORT OPB_Clk = sys_clk
END
 

Also required is this FSL bus declaration:

BEGIN fsl_v20
PARAMETER INSTANCE = download_link
PARAMETER HW_VER = 1.00.b
PARAMETER C_EXT_RESET_HIGH = 0
PORT SYS_Rst = sys_rst
PORT FSL_Clk = sys_clk
END

and finally this line in the main MicroBlaze section of the MHS file:

BUS_INTERFACE SFSL0 = download_link
 

The following instructions assume that you uClinux distribution is in the directory ~/uClinux-dist, and that your mbvanilla directory is ~/MicroBlaze/mbvanilla.  Adjust accordingly to suit your local configuration.

 

  1. Build and download your hardware. and kernel image that you wish to debug.
     
  2. Start XMD, from within the mbvanilla directory, and connect to the MDM:

    $ xmd
    ...
    XMD% xload mhs system.mhs
    XMD% mbconnect mdm
     
  3. Leave xmd connected running.  In a new terminal window, change to the uClinux distribution directory, and start mb-gdb:

    $ cd ~/uClinux-dist
    $ mb-gdb
     
  4. Make sure the gdb console window is open.  From the gdb Source Windows select View->Console, or press Ctrl+H
     
  5. In the gdb console window, enter the following commands:

    (gdb) target remote localhost:1234
    (gdb) load images/image.elf      (this will take about a minute or less)
    (gdb) sym images/image.elf

    If you are running xmd on a different machine to mb-gdb, in the first command above you enter the name of that machine, instead of localhost. 
     
  6. You are now ready to start debugging the kernel.  You can set some breakpoints (e.g. start_kernel), or simply enter

    (gdb) cont

    to boot the kernel.  You can press the "Stop" button on the gdb window at any time to halt the CPU.  You can then browse the source code, examine variables, place breakpoints etc.

Home Up


Last updated 08-May-2006   
© 2003-2006 John Williams unless otherwise stated