Debugging our design
What to do if our design is not doing what we expected it to do. Then we need a debugger.
Xilinx Microprocessor Debugger and GNU Software Debugging Tools Using Xilinx Microprocessor Debugger (XMD) and GNU Debugger (GDB), we can debug our embedded application either on the host development system using an instruction set simulator or virtual platform, or on a board that has the FPGA loaded with our hardware bitstream. For more information on the GNU software debugging tools, refer to the Debug Overview. For more information on XMD, see the "Xilinx Microprocessor Debugger (XMD)" chapter in the Embedded System Tools Reference Manual.
Xilinx Microprocessor Debugger (XMD)
The Xilinx Microprocessor Debugger (XMD) is a tool that facilitates debugging programs and verifying systems using the PowerPC 405GP or MicroBlaze microprocessors. We can use it to debug programs running on a hardware board, Cycle-Accurate Instruction Set Simulator (ISS), or MicroBlaze Cycle-Accurate Virtual Platform (VP) system.
XMD provides a Tool Command Language (Tcl) interface. This interface can be used for command line control and debugging of the target as well as for running complex verification test scripts to test a complete system. XMD supports GNU Debugger (GDB) Remote TCP protocol to control debugging of a target. Some graphical debuggers use this interface for debugging, including PowerPC and MicroBlaze GDB (powerpc-eabi-gdb and mb-gdb) and the Platform Studio Software Development Kit (SDK), EDK's Eclipse-based Software IDE. In either case, the debugger connects to XMD running on the same computer or on a remote computer on the Network.
XMD reads Xilinx Microprocessor Project (XMP), Microprocessor Hardware Specification (MHS), and (Microprocessor Software Specification) (MSS) system files to better understand the hardware system on which the program is debugged. The information is used to perform memory range tests, determine MicroBlaze to Microprocessor Debug Module (MDM) connectivity for faster download speeds, and perform other system actions.
MicroBlaze Processor Target
XMD can connect through JTAG to one or more MicroBlaze processors using the opb_mdm Microprocessor Debug Module (MDM) peripheral. XMD can communicate with a ROM monitor such as XMDStub through JTAG or Serial interface. You can also debug programs using built-in Cycle-accurate MicroBlaze ISS.
MicroBlaze MDM hardware target

(Courtesy of Xilinx)
Debug session
This example demonstrates a simple debug session with a MicroBlaze MDM target. Basic XMD-based commands are used after connecting to the MDM target using the connect mb mdm.
==> xmd
XMD% connect mb mdm
connect mb mdm
Info:AutoDetecting cable. Please wait.
Info:Reusing 78010001 key.
Info:Reusing FC010001 key.
Info:Connecting to cable (Parallel Port - parport0).
Info: libusb-driver.so version: 2007-05-27 00:37:02.
Info: parport0: Info:baseAddress=0x0Info:, ecpAddress=0x400Info:
Info: LPT base address = 0000h.
Info: ECP base address = 0400h.
Can't open /dev/parport0: Permission denied
Info:LPT port is already in use. rc = FFFFFFFFh
Info:Cable connection failed.
Info:Reusing 79010001 key.
Info:Reusing FD010001 key.
Info:Connecting to cable (Parallel Port - parport1).
Info: libusb-driver.so version: 2007-05-27 00:37:02.
Info:Cable connection failed.
Info:Reusing 7A010001 key.
Info:Reusing FE010001 key.
Info:Connecting to cable (Parallel Port - parport2).
Info: libusb-driver.so version: 2007-05-27 00:37:02.
Info:Cable connection failed.
Info:Reusing 7B010001 key.
Info:Reusing FF010001 key.
Info:Connecting to cable (Parallel Port - parport3).
Info: libusb-driver.so version: 2007-05-27 00:37:02.
Info:Cable connection failed.
Info:Reusing A0010001 key.
Info:Reusing 24010001 key.
Info:Connecting to cable (Usb Port - USB21).
Info:Checking cable driver.
Info:File version of /home/svenand/cad/xilinx91i/bin/lin/xusbdfwu.hex = 1025(dec), 0x0401.
Info:File version of /usr/share/xusbdfwu.hex = 1025(dec), 0x0401.
Info: libusb-driver.so version: 2007-05-27 00:37:02.
Calling setinterface num=0, alternate=0.
DeviceAttach: received and accepted attach for:
vendor id 0x3fd, product id 0x8, device handle 0x830b558
Info: Cable PID = 0008.
Info: Max current requested during enumeration is 280 mA.
Info: Cable Type = 3, Revision = 0.
Info: Cable Type = 0x0605.
Info: Setting cable speed to 6 MHz.
Info:Cable connection established.
Info:Firmware version = 1025.
Info:CPLD file version = 0012h.
Info:CPLD version = 0012h.
JTAG chain configuration
--------------------------------------------------
Device ID Code IR Length Part Name
1 0a001093 8 System_ACE
2 05059093 16 XCF32P
3 01e58093 10 XC4VFX12
4 09608093 8 xc95144xl
MicroBlaze Processor Configuration :
-------------------------------------
Version............................6.00.b
No of PC Breakpoints...............2
No of Read Addr/Data Watchpoints...0
No of Write Addr/Data Watchpoints..0
Instruction Cache Support..........off
Data Cache Support.................off
Exceptions Support................off
FPU Support.......................off
Hard Divider Support...............off
Hard Multiplier Support............on - (Mul32)
Barrel Shifter Support.............off
MSR clr/set Instruction Support....on
Compare Instruction Support........on
Connected to MDM UART Target
Connected to "mb" target. id = 0
Starting GDB server for "mb" target (id = 0) at TCP port no 1234
Reading registers in MicroBlaze
XMD% rrd
rrd
r0: 00000000 r8: 00000001 r16: 00000000 r24: 00000000
r1: 00001440 r9: 00000008 r17: 00000000 r25: 00000000
r2: 000010f8 r10: 00000000 r18: 00000000 r26: 00000000
r3: 00000001 r11: 00000000 r19: 00000000 r27: 00000000
r4: 00000000 r12: 00000000 r20: 00000000 r28: 00000000
r5: 00000000 r13: 00001158 r21: 00000000 r29: 00000000
r6: 0000000d r14: 00000000 r22: 00000000 r30: 00000000
r7: 0000000a r15: 0000005c r23: 00000000 r31: 00000000
pc: 0000007c msr: 00000000
Load program
Command: dow elf_file_name
XMD% dow SDK_projects/ETC_system_program/Debug/ETC_system_program.elf
dow SDK_projects/ETC_system_program/Debug/ETC_system_program.elf
section, .vectors.reset: 0x00000000-0x00000003
section, .vectors.sw_exception: 0x00000008-0x0000000b
section, .vectors.interrupt: 0x00000010-0x00000013
section, .vectors.hw_exception: 0x00000020-0x00000023
section, .text: 0x00000050-0x00000f0b
section, .init: 0x00000f0c-0x00000f2f
section, .fini: 0x00000f30-0x00000f4b
section, .ctors: 0x00000f4c-0x00000f53
section, .dtors: 0x00000f54-0x00000f5b
section, .rodata: 0x00000f5c-0x00000f9d
section, .data: 0x00000fa0-0x00000ffb
section, .jcr: 0x00000ffc-0x00000fff
section, .bss: 0x00001000-0x0000143f
Downloaded Program SDK_projects/ETC_system_program/Debug/ETC_system_program.elf
Setting PC with Program Start Address 0x00000000
Set breakpoint
Command : bps <memory_loc>
XMD% bps 0x50
bps 0x50
Setting breakpoint at 0x00000050
Remove breakpoint
Command : bpr <memory_loc>
XMD% bpr 0x50
bpr 0x50
Display breakpoints
Command : bpl
XMD% bpl
bpl
0: HW BP: Address = 0x00000004
1: SW BP: Address = 0x00000050
Start program execution
Command : con [start_address] or con to continue from breakpoint
XMD% con 0
con
Info:Processor started. Type "stop" to stop processor
RUNNING> XMD% Info:Software Breakpoint 1 Hit, Processor Stopped at 0x00000050
Single step
Command : stp [number_of_instructions]
XMD% stp
stp
54: 304010F8 addik r2 , r0 , 4344
XMD% stp
stp
58: 30201430 addik r1 , r0 , 5168
XMD% stp
stp
5C: B9F40088 brlid r15, 136
XMD% stp 10
stp 10
10C: 20C01000 addi r6 , r0 , 4096
Stop program executionCommand : stop
RUNNING> XMD% stop
stop
XMD% Info:User Interrupt, Processor Stopped at 0x00000068
Display program code
Command : dis <start address, number_of_instructions>
XMD% dis 0x50 20
dis 0x50 20
50: 31A01158 addik r13, r0 , 4440
54: 304010F8 addik r2 , r0 , 4344
58: 30201430 addik r1 , r0 , 5168
5C: B9F40088 brlid r15, 136
60: 80000000 Or r0 , r0 , r0
64: 20210010 addi r1 , r1 , 16
68: B8000000 bri 0
6C: E0601000 lbui r3 , r0 , 4096
70: 3021FFE4 addik r1 , r1 , -28
74: F9E10000 swi r15, r1 , 0
78: BC030014 beqi r3 , 20
7C: B8000028 bri 40
80: F8600FA8 swi r3 , r0 , 4008
84: 99FC2000 brald r15, r4
88: 80000000 Or r0 , r0 , r0
8C: E8600FA8 lwi r3 , r0 , 4008
90: E8830000 lwi r4 , r3 , 0
94: BE24FFEC bneid r4 , -20
98: 30630004 addik r3 , r3 , 4
9C: 30600001 addik r3 , r0 , 1
Getting help
XMD% help
help
XMD Terminal Commands Types:
init......... Load/Initialize the System Files
connect...... Connect to System Target
files........ Load ELF/Data files
running...... Program Execution
breakpoints.. Setting Breakpoints/Watchpoints
trace........ Tracing and Profiling options
misc......... Miscellaneous Options
help......... Help on help
Type "help" to display XMD command types
Type "help" followed by above "type" for more options
XMD%
XMD% help running
help running
Program Execution, Reading/Writing Registers and Memory
----- Syntax ----- ----- Description -----
run Run program from <Start Address>
con [address] [-quit] Continue
stp [num_instrns] Step
cstp [num_cycles] Cycle Step (Simulator/VP targets)
rst [-processor] Reset the System/Processor
stop Stop
rrd [reg num] Register Read
srrd [reg name] Special Register Read
rwr <register> <word> Register Write
mrd <address> [num] [w|h|b] Memory Read (default: 'w'ord)
mrd_var <variable name> [ELF file] Read memory at global variable
mwr <address> <values> [<num> <w|h|b>] Memory Write (default: 'w'ord)
XMD%
XMD% help breakpoints
help breakpoints
Setting Breakpoints and Watchpoints
----- Syntax ----- ----- Description -----
bps <address|func name> [sw|hw] Breakpoint Set. xmd uses last
downloaded ELF file for function name
watch <r|w> <addr> [data] Set Read/Write Watchpoints.
bpr <address|func name|bp id|all> Breakpoint/Watchpoint Remove. xmd uses last
downloaded ELF file for function name
bpl Breakpoints List
XMD%
XMD% help files
help files
Specify/Download ELF or Data files to System Target
----- Syntax ----- ----- Description -----
dow <filename> Download Elf File
dow <filename> <addr> Download PIC Elf File from <addr>
dow <-data> <filename> <addr> Download Data/Binary File from <addr>
XMD%
XMD% help trace
help trace
Trace/Statistics/Profile Commands
----- Syntax ----- ----- Description -----
tracestart [<filename>] Start Tracing (For ISS/VP Targets)
tracestop [done] Stop Tracing
stats [filename] Generate Trace Stats (For Simulator Targets)
<filename> Trace file for PPC Sim Only
profile [-o <Gmon output File>] Configure or Write Profile Output File
[-config [sampling_freq_hz <value>]
[binsize <value>] [profile_mem <Start Address>]
XMD%
XMD% help misc
help misc
Misc Commands
----- Syntax ----- ----- Description -----
debugconfig [-step_mode <value>] Configure the Debug Session
[-memory_datawidth_matching <value>]
[-reset_on_run <system | processor> <enable | disable>]
[-vpoptions <bus_cycle_accuracy <enable | disable>>]
state [target id] Display the Current State of all targets
or <target id> target.
dis <address> [num_words] Disassemble (MicroBlaze Only)
terminal [-jtag_uart_server [portno]] Start JTAG-based Hyperterminal to
communicate with MDM UART interface
read_uart <start|stop> [TCL Channel ID] Read from MDM UART interface
verbose [<level>] Toggle Verbose mode. Verbose Level = 1-3
XMD%
Using XMD in Xilinx Platform StudioYou can run the Xilinx Microprocessor Debugger (XMD) from a command line and use it exclusively for debugging. Alternately, XMD can serve as a link between the GNU debug option and your target board.
To open XMD from Xilinx Platform Studio (XPS), click Debug > Launch XMD.
The first time you open XMD, you are prompted to set the XMD options, and the XMD Debug Options dialog box opens automatically. Select the settings.
If you want to change the debug option setting later, you can do so by clicking Debug > XMD Target Options.
After you have set the debug options, the XMD terminal command-line window opens. On Startup, XMD does the following:
If an XMD Tcl script is specified, XMD executes the script and quits.
Otherwise, XMD is started in an interactive mode. In this case, XMD does the following:
- Sources the ${HOME}/.xmdrc file. The configuration file can be used to form custom Tcl commands using XMD commands.
- Opens the XMD Socket server, if the -ipcport option is given.
- Loads system Xilinx® Microprocessor Project (XMP) file, if the -xmp option is given.
- Uses Connect option file to connect to processor target, if the -opt option is given.
- If –nx option is not specified, sources the xmd.ini file, if present in the directory.
The XMD% prompt is displayed. From the Tcl prompt, you can use XMD commands for debugging.
For a list of XMD commands, refer to the "Xilinx Microprocessor Debugger (XMD)" chapter of the Embedded System Tools Reference Manual.
Top Next Previous