Sample Course Title Slide Insert Presentation Title

Download Report

Transcript Sample Course Title Slide Insert Presentation Title

Debugging
© 2003 Xilinx, Inc. All Rights Reserved
Objectives
After completing this module, you will be able to:
•
•
•
•
Describe GDB functionality
Describe XMD functionality
Describe the integration of GDB with XMD
List supported third-party tools
Debugging - 11 - 3
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Outline
•
•
•
Debugging - 11 - 4
Introduction
GDB Functionality
XMD Functionality
– MicroBlaze Processor
– PowerPC Processor
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Introduction
•
•
•
Debugging is an integral part of embedded systems development
The debugging process is defined as testing, stabilizing, localizing, and
correcting errors
Two methods of debugging
–
–
Hardware debugging via a logic probe, logic analyzer, in-circuit emulator, or
background debugger
Software debugging via a debugging instrument
•
•
A software debugging instrument is source code that is added to the program
for the purpose of debugging
Debugging types
–
–
Debugging - 11 - 5
Functional debugging
Performance debugging
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Hardware Debugging Support
•
•
ChipScope™ Pro cores are now included for adding to a Platform Studio
design
–
PLB IBA (Integrated Bus Analyzer)
–
OPB IBA
–
VIO (Virtual I/O)
ChipScope Pro evaluation version shipped with EDK
–
Analyzer evaluation ends after 90 days
–
Core insertion/generation works indefinitely
–
Supports Solaris™ OS and Windows® platforms
•
•
Linux to be added in an upcoming release
Enables co-debug of software with GNU gdb and hardware with ChipScope
Analyzer
Debugging - 11 - 6
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Simultaneous HW/SW Debug
•
•
•
–
Are treated like the peripheral cores
DSOCM
BRAM
PowerPC
405 Core
MDM MicroBlaze
32-Bit RISC Core
IBA
IBA
Processor Local Bus
Hi-Speed
Peripheral
ISOCM
BRAM
e.g.
Memory
Controller
GB
E-Net
Bus
Bridge On-Chip Peripheral Bus
UART
GPIO
Arbiter
•
ChipScope™ Pro PLB & IBA cores in
target
ChipScope Pro Analyzer on host
GDB debugger on host
XMD supports simultaneous access
over Xilinx parallel cables
PLB/OPB IBA instantiation in XPS
Arbiter
•
Minimal “skid-by” as cross triggering is done on chip
between IBA cores and PPC & MicroBlaze debug interfaces
On-Chip
Peripheral
Set breakpoint in GDB – when hit → triggers ChipScope
Set trigger in ChipScope – when hit → halts CPU and debugger stops
Debugging - 11 - 7
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Simultaneous HW/SW Debug
Active trigger when
addr bus = 0xC200
Trigger out signal
from IBA to CPU
debug halt signal in
XMD
JTAG
MDM
Arbiter
Xilinx Parallel Cable
Debugging - 11 - 8
IBA
MicroBlaze
Flexible Soft IP
32-Bit RISC Core
OPB
On-Chip Peripheral Bus
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Software Debugging Support
•
EDK supports software debugging via:
–
GNU Debugger (GDB) tools
•
–
Xilinx Microprocessor Debugger (XMD)
•
–
•
Unified interface for debugging and verifying MicroBlaze and PowerPC
systems
Runs all of the hardware debugging tools and communicates with the hardware
GNU tools communicate with hardware through XMD
Third-party support
–
Wind River:
•
•
–
Nohau:
•
Debugging - 11 - 9
SingleStep XE debugger
visionPROBE II XE debugger
EMUL-MicroBlaze-PC debugger
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Outline
•
•
•
Debugging - 11 - 10
Introduction
GDB Functionality
XMD Functionality
– MicroBlaze Processor
– PowerPC Processor
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
GDB Functionality
Tcl/Terminal Interface
Host Software
User
Interface
PowerPC-eabi-gdb
Host Software
Host Software
Host Software
GDB Remote
Protocol
GDB Remote
Protocol
XMD
(TCP/IP)
(TCP/IP)
MB Cycle-Accurate
Instruction Set Simulator
JTAG
PPC405 Debug Port
JTAG
UART
UARTlite
MDM
XMD stub
PowerPC System
Debugging - 11 - 11
User
Interface
JTAG
UART
JTAG
mb-gdb
MicroBlaze System
© 2003 Xilinx, Inc. All Rights Reserved
MicroBlaze System
For Academic Use Only
Target Hardware
GDB Functionality
•
GDB is a source-level debugger that helps you debug your program:
–
–
–
Start your program
Set breakpoints (make your program stop on specified conditions)
Examine what has happened, when your program encounters breakpoints
•
•
•
•
•
–
•
Registers
Memory
Stack
Variables
Expressions
Change things in your program, so you can experiment with correcting the
effects of one bug and go on to learn about another
You can use GDB to debug programs written in C and C++
Debugging - 11 - 12
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
GDB
Assembly
Instructions
Memory
Location
C Code
Debugging - 11 - 13
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
GDB GUI
•
Run-time control
–
–
–
–
–
–
Debugging - 11 - 14
S: Step by source lines (Step into functions)
SI: Step by machine instruction
C: Continue to next breakpoint
N: Next source line (Steps over functions)
NI: Next machine instruction
F: Finish (Ignores all breakpoints)
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
GDB Functionality
•
•
Breakpoints can be enabled or disabled
To change any memory value, simply double-click in a memory field
Debugging - 11 - 15
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
GDB Functionality
•
•
Blue represents registers that have changed
To change any value, double-click in a field
Debugging - 11 - 16
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Outline
•
•
•
Debugging - 11 - 17
Introduction
GDB Functionality
XMD Functionality
– MicroBlaze Processor
– PowerPC Processor
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
XMD Functionality
Tcl/Terminal Interface
Host Software
User
Interface
PowerPC-eabi-gdb
Host Software
Host Software
Host Software
GDB Remote
Protocol
GDB Remote
Protocol
XMD
(TCP/IP)
(TCP/IP)
MB Cycle-Accurate
Instruction Set Simulator
JTAG
PPC405 Debug Port
JTAG
UART
UARTlite
MDM
XMD stub
PowerPC System
Debugging - 11 - 18
User
Interface
JTAG
UART
JTAG
mb-gdb
MicroBlaze System
© 2003 Xilinx, Inc. All Rights Reserved
MicroBlaze System
For Academic Use Only
Target Hardware
XMD Functionality
•
Xilinx Microprocessor Debug (XMD) engine
–
–
•
XMD supports debugging user programs on different targets
–
–
–
–
•
•
A program that facilitates a unified GDB interface
A Tcl (Tool command language) interface
Cycle-accurate MicroBlaze processor instruction set simulator
MicroBlaze system running xmdstub on a hardware board
MicroBlaze system using MDM peripheral
PowerPC system on a hardware board
mb-gdb and powerpc-eabi-gdb communicate with xmd by using the
Remote TCP protocol and control the corresponding targets
GDB can connect to xmd on the same computer or on a remote
computer on the Internet
Debugging - 11 - 19
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
XMD Tcl Interface
•
•
•
•
•
•
•
•
x? - lists all Tcl commands
xrmem target addr [num] - Reads num bytes or 1 byte from the
memory address addr
xwmem target addr value - Writes an 8-bit byte value at the specified
memory addr
xrreg target [reg] - Reads all registers or only register number reg
xwreg target reg value - Writes a 32-bit value into register number reg
xdownload target [-data] filename [addr] - Downloads the given ELF
or data file (with -data option) onto the memory of the current target
xcontinue target [addr] - Continues execution from the current PC or
from the optional address argument
xstep target - Single steps one MicroBlaze processor instruction. If
the PC is at an IMM instruction, the next instruction is executed as well
Debugging - 11 - 20
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Outline
•
•
•
Debugging - 11 - 21
Introduction
GDB Functionality
XMD Functionality
– MicroBlaze Processor
– PowerPC Processor
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
MicroBlaze Processor: XMD
•
There are three ways to
debug MicroBlaze
processor code:
–
–
XMD
Host Software
(TCP/IP)
MB Cycle-Accurate
Instruction Set Simulator
Intrusive: requires
xmdstub software
JTAG
OPB UART core
•
GDB Remote
Protocol
Host Software
OPB JTAG UART core
•
–
Tcl/Terminal Interface
Intrusive: requires
xmdstub software
JTAG
UART
UART
UART
JTAG
MDM
OPB MDM core
•
Non-intrusive: hardware
interface
OPB Bus
MicroBlaze
Debugging - 11 - 22
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
mb-gdb
MicroBlaze Processor: XMD
•
MicroBlaze processor stub target (xmdstub)
–
•
User programs can be downloaded or executed directly from mb-gdb
To debug programs on the hardware by using xmdstub
1. A JTAG UART or a UART must be included in the hardware system
2. A JTAG UART or a UART must be specified as the DEBUG_PERIPHERAL
3. The xmdstub executable must be included in the MicroBlaze processor’s
local memory at system startup
•
Sample session of XMD with a hardware stub target
–
XMD% mbconnect stub -comm jtag -posit 2
•
Debugging - 11 - 23
Connect to a MicroBlaze processor target via a stub, using JTAC
communication, and an FPGA which is second in the JTAG chain
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
MicroBlaze Processor: XMD
•
•
•
MicroBlaze processor simulator target
mb-gdb and xmd can be used to debug programs on the cycle-accurate
simulator built into XMD
Simulator target requirements
–
–
–
•
Programs should be compiled for debugging and should be linked with the
startup code in crt0.o
Programs can have a maximum size of 64 KB only
Does not support the simulation of OPB peripherals
Sample session of XMD and GDB
–
Debugging - 11 - 24
XMD% mbconnect sim
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
MicroBlaze Processor: XMD
•
•
MicroBlaze processor MDM (hardware OPB_MDM debug core
on-board)
The MDM target supports non-intrusive debugging by using:
–
–
–
–
•
Hardware breakpoints
Hardware single step
This removes the need to run xmdstub
This removes the requirement to have large memory
Sample session of XMD and GDB
–
Debugging - 11 - 25
XMD% mbconnect mdm
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
XMD Options
•
•
mbconnect <sim|stub|mdm> [options]
Simulator target options
–
•
-memsize size
xmdstub target options
–
–
–
–
–
Debugging - 11 - 26
-comm <serial|jtag>
-posit device position
-chain device count <list of BSDL files>
-port serial port
-baud baud rate
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Outline
•
•
•
Debugging - 11 - 27
Introduction
GDB Functionality
XMD Functionality
– MicroBlaze Processor
– PowerPC Processor
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
PowerPC Processor: XMD
•
•
Use xmd to connect a hardware
PowerPC target over a JTAG
connection to a board containing
a Virtex-II Pro device
Use the ppcconnect command
to connect to the PowerPC
processor target and start a
remote GDB server
Tcl/Terminal Interface
Host Software
PowerPC-eabi-gdb
GDB Remote
Protocol
(TCP/IP)
Host Software
XMD
JTAG
PPC405 Debug Port
PowerPC System
Debugging - 11 - 28
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
A Debugging Sample
1
2
Compile with the debugging option
Download the bitstream
This will go through the necessary steps,
generate a bitstream file, and download
the file
Debugging - 11 - 29
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Start XMD
3
Start the XMD shell
4
In XMD, type ppc to
connect to the hardware
This opens a connection with the hardware,
indicating the connecting port, caches, DCR,
TLB enabled or not
Debugging - 11 - 30
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Start Software Debugger
5
Start Software Debugger
6
A source code window
will be displayed
Change the code window display from SOURCE
to MIXED to show C and assembly code
Debugging - 11 - 31
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Software Debugger Connect
7
A window displaying
C and assembly code
8
Select the target as
Remote/TCP: XMD
Enter that port number that was
displayed during ppc-connect
Debugging - 11 - 32
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Debug Program
9
Set any breakpoints as necessary
10
11
12
Click the Run button
When a breakpoint is encountered, the
debugger will stop
View the necessary windows
Exit debugger by typing quit in the
console window
Debugging - 11 - 33
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Review Questions
•
What is the XMD command line used to connect to a MicroBlaze
processor core via JTAG?
•
What is the advantage of using MDM over a JTAG UART?
•
Into what parts of the design do debuggers provide visibility?
Debugging - 11 - 35
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Answers
•
What is the XMD command line used to connect to a MicroBlaze
processor core via JTAG?
–
•
What is the advantage of using MDM over a JTAG UART?
–
–
•
XMD% mbconnect stub -comm jtag -posit 2
Non-intrusive
Less memory required
Into what parts of the design do debuggers provide visibility?
–
–
–
–
–
Debugging - 11 - 36
Registers
Memory
Stack
Variables
Expressions
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only
Where Can I Learn More?
•
Tool documentation
–
–
–
•
Embedded System Tools Guide  GNU Compiler Tools
Embedded System Tools Guide  GNU Debugger
Embedded System Tools Guide  Xilinx Microprocessor Debugger
Support website
–
Debugging - 11 - 37
EDK Home Page: support.xilinx.com/edk
© 2003 Xilinx, Inc. All Rights Reserved
For Academic Use Only