New Horizons

Welcome to my blog

My name is Sven Andersson and I
work as a consultant in embedded
system design, implemented in ASIC
and FPGA.
In my spare time I write this blog
and I hope it will inspire others to
learn more about this fantastic field.
I live in Stockholm Sweden and have
my own company


You are welcome to contact me
and ask questions or make comments
about my blog.


New Horizons
What's new
Starting a blog
Writing a blog
Using an RSS reader

Zynq Design From Scratch
Started February 2014
1 Introduction
Changes and updates
2 Zynq-7000 All Programmable SoC
3 ZedBoard and other boards
4 Computer platform and VirtualBox
5 Installing Ubuntu
6 Fixing Ubuntu
7 Installing Vivado
8 Starting Vivado
9 Using Vivado
10 Lab 1. Create a Zynq project
11 Lab 1. Build a hardware platform
12 Lab 1. Create a software application
13 Lab 1. Connect to ZedBoard
14 Lab 1. Run a software application
15 Lab 1. Benchmarking ARM Cortex-A9
16 Lab 2. Adding a GPIO peripheral
17 Lab 2. Create a custom HDL module
18 Lab 2. Connect package pins and implement
19 Lab 2. Create a software application and configure the PL
20 Lab 2. Debugging a software application
21 Running Linux from SD card
22 Installing PetaLinux
23 Booting PetaLinux
24 Connect to ZedBoad via ethernet
25 Rebuilding the PetaLinux kernel image
26 Running a DHCP server on the host
27 Running a TFTP server on the host
28 PetaLinux boot via U-boot
29 PetaLinux application development
30 Fixing the host computer
31 Running NFS servers
32 VirtualBox seamless mode
33 Mounting guest file system using sshfs
34 PetaLinux. Setting up a web server
35 PetaLinux. Using cgi scripts
36 PetaLinux. Web enabled application
37 Convert from VirtualBox to VMware
38 Running Linaro Ubuntu on ZedBoard
39 Running Android on ZedBoard
40 Lab2. Booting from SD card and SPI flash
41 Lab2. PetaLinux board bringup
42 Lab2. Writing userspace IO device driver
43 Lab2. Hardware debugging
44 MicroZed quick start
45 Installing Vivado 2014.1
46 Lab3. Adding push buttons to our Zynq system
47 Lab3. Adding an interrupt service routine
48 Installing Ubuntu 14.04
49 Installing Vivado and Petalinux 2014.2
50 Using Vivado 2014.2
51 Upgrading to Ubuntu 14.04
52 Using Petalinux 2014.2
53 Booting from SD card and SPI flash
54 Booting Petalinux 2014.2 from SD card
55 Booting Petalinux 2014.2 from SPI flash
56 Installing Vivado 2014.3

Chipotle Verification System

EE Times Retrospective Series
It all started more than 40 years ago
My first job as an electrical engineer
The Memory (R)evolution
The Microprocessor (R)evolution

Four soft-core processors
Started January 2012
Table of contents
OpenRISC 1200
Nios II

Using the Spartan-6 LX9 MicroBoard
Started August 2011
Table of contents
Problems, fixes and solutions

FPGA Design From Scratch
Started December 2006
Table of contents
Acronyms and abbreviations

Actel FPGA design
Designing with an Actel FPGA. Part 1
Designing with an Actel FPGA. Part 2
Designing with an Actel FPGA. Part 3
Designing with an Actel FPGA. Part 4
Designing with an Actel FPGA. Part 5

A hardware designer's best friend
Zoo Design Platform

Installing Cobra Command Tool
A processor benchmark

Porting a Unix program to Mac OS X
Fixing a HyperTerminal in Mac OS X
A dream come true

Stockholm by bike

The New York City Marathon

Kittelfjall Lappland

Tour skating in Sweden and around the world
Wild skating
Tour day
Safety equipment
A look at the equipment you need
Skate maintenance
Books, photos, films and videos
Weather forecasts

38000 feet above see level
A trip to Spain
Florida the sunshine state

Photo Albums
Seaside Florida
Ronda Spain
Sevilla Spain
Cordoba Spain
Alhambra Spain
Kittelfjäll Lapland
Landsort Art Walk
Skating on thin ice

100 Power Tips for FPGA Designers

Adventures in ASIC
Computer History Museum
Design & Reuse
d9 Tech Blog
EDA Cafe
EDA DesignLine
Eli's tech Blog
FPGA Arcade
FPGA Central
FPGA developer
FPGA Journal
FPGA World
Lesley Shannon Courses
Mac 2 Ubuntu
Programmable Logic DesignLine
World of ASIC

If you want to be updated on this weblog Enter your email here:

rss feed

Monday, June 25, 2007
FPGA design from scratch. Part 37
Debugging our design

What to do if our design is not doing what we expected it to do. Then we need a

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: 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: 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: 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: 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: 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 :
No of PC Breakpoints...............2
No of Read Addr/Data Watchpoints...0
No of Write Addr/Data Watchpoints..0
Instruction Cache
Data Cache
Hard Divider
Hard Multiplier Support............on - (Mul32)
Barrel Shifter
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

    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
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
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
      54:   304010F8  addik    r2 , r0 , 4344

XMD% stp
      58:   30201430  addik    r1 , r0 , 5168

XMD% stp
      5C:   B9F40088  brlid    r15, 136

XMD% stp 10
stp 10
     10C:   20C01000  addi     r6 , r0 , 4096

Stop program execution

Command : 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

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% 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% 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% 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% 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% 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

Using XMD in Xilinx Platform Studio

You 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

Posted at 10:18 by

July 23, 2008   02:28 PM PDT
What about printing something to stdout?
Is it working under EDK9.2 with PLB?

For me it works only when jtagppc is absent (= Enable Software Debugging for this processor = 0 / under Debug / Debug configuration / ppc405_0 tab).

Leave a Comment:


Homepage (optional)


Previous Entry Home Next Entry