Software Development and Debugging Using SDK
description
Transcript of Software Development and Debugging Using SDK
This material exempt per Department of Commerce license exception TSU © 2005 Xilinx, Inc. All Rights Reserved
Software Development and Debugging Using SDK
© 2005 Xilinx, Inc. All Rights Reserved
Objectives
After completing this module, you will be able to:• Understand the basic concepts of the Eclipse IDE • List Xilinx Software Development Kit (SDK) features• Describe GNU Debugger (GDB) functionality• Describe Xilinx Microprocessor Debugger (XMD) functionality• Describe the integration of XMD and GDB with SDK
© 2005 Xilinx, Inc. All Rights Reserved
Outline
• Software Development Kit
• Debugging Tools• Debugging Using XPS • Debugging Using SDK• Simultaneous HW/SW Debug
© 2005 Xilinx, Inc. All Rights Reserved
• Java-based application development environment• Based on the open-source effort by the Eclipse Consortium\• Feature-rich C/C++ code editor and compilation environment• Project management• Application build configuration and automatic Makefile generation• Error Navigation• Well-integrated environment for seamless debugging of embedded
targets• Source code version control
Xilinx Platform Studio Software Development Kit (SDK)
© 2005 Xilinx, Inc. All Rights Reserved
Xilinx Extensions to Eclipse• SDK leverage on Eclipse + CDT
(C/C++ Development Toolkit)– Project Management– Makefile builder– Code editor, Error Navigation– Debug – Search
• SDK value add to CDT– Debug integration using XMD– Xilinx Custom Compiler settings for
PowerPC, MicroBlaze– Profiling Flow and Visualization– Productization
Java Virtual Machine
Platform Studio SDK Extensions
C/C++ Development Perspective
Eclipse platform
© 2005 Xilinx, Inc. All Rights Reserved
Eclipse/CDT Frameworks
• Builder framework– Compiles and Links Source files– Default Build options are specified when application is created: Choice of Debug, Release,
Profile configurations– User can custom build options later when developing application– Build types: Standard Make, Managed Make
• Launch framework– Specifies what action needs to be taken: Run (+ Profile) application or Debug application– In SDK, this is akin to the Target Connection settings
• Debug framework– Launches debugger (gdb), loads application and begins debug session– Debug views show information about state of debug session– Hides ugliness of debug details
• Search framework– Helps development of application
• Help System– Online help system; context-sensitive
More information at: http://www.eclipse.org/cdt/
© 2005 Xilinx, Inc. All Rights Reserved
SDK Application Development Flow
Create softwareApp Project
Add sources + Edit
Compile + Link
Generate HardwarePlatform
Done?Import ELF file,
Download to board
Debug / Profile
Platform Studio SDK
Yes
Generate SoftwarePlatform
libraries, drivers
Platform Studio
© 2005 Xilinx, Inc. All Rights Reserved
Workspaces and Perspectives
• Workspace– Location to store preferences & internal info about Projects– Transparent to SDK users– In SDK, source files not stored under Workspace
• Views, Editors– Basic User interface element
• Perspectives– Collection of functionally related views– Layout of views in a perspective can be customized according
to user preference
© 2005 Xilinx, Inc. All Rights Reserved
Perspectives
© 2005 Xilinx, Inc. All Rights Reserved
CVS Perspective
© 2005 Xilinx, Inc. All Rights Reserved
Views• Eclipse Platform views: Navigator view, Tasks view, Problems
view• Debug views: Stack view, Variables view• C/C++ views: Projects view, Outline view
© 2005 Xilinx, Inc. All Rights Reserved
Opening Perspectives and Views
• To open a Perspective, use Window Open Perspective
• To open a view, useWindow Show View
If the view is already present in the current perspective, the view is highlighted
© 2005 Xilinx, Inc. All Rights Reserved
Editors• bracket matching• syntax coloring• content assist• refactoring • keyboard shortcuts
© 2005 Xilinx, Inc. All Rights Reserved
SDK Workbench
C/C++ project outline displays the elements of a project with file decorators (icons) for easy identification
C/C++ editor for integrated software creation
Code outline displays elements of the software file under development with file decorators (icons) for easy identification
Problems, Console, Properties view lists output information associated with the software development flow
1
2
3
4
1 2 3
4
© 2005 Xilinx, Inc. All Rights Reserved
Outline
• Software Development Kit • Debugging Tools
• Debugging Using XPS• Debugging Using SDK• Simultaneous HW/SW Debug
© 2005 Xilinx, Inc. All Rights Reserved
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:– Functional debugging– Performance debugging
© 2005 Xilinx, Inc. All Rights Reserved
Hardware Debugging Support• ChipScope™ Pro tool cores are now included for adding to a Xilinx
Platform Studio design– PLB IBA (Integrated Bus Analyzer)– OPB IBA– VIO (Virtual I/O)
• ChipScope Pro tool evaluation version shipped with the 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
© 2005 Xilinx, Inc. All Rights Reserved
Software Debugging Support
• EDK supports software debugging via:– GNU Debugger (GDB) tools
• Unified interface for debugging and verifying MicroBlaze and PowerPC systems
– Xilinx Microprocessor Debugger (XMD)• Runs all of the hardware debugging tools and
communicates with the hardware– GNU tools communicate with the hardware through
XMD
© 2005 Xilinx, Inc. All Rights Reserved
GDB Functionality
User Interface
User Interface
Target Hardware
(TCP/IP) (TCP/IP)
GDB Remote Protocol
GDB Remote Protocol
JTAG UART
PowerPC™ System MicroBlaze™ System
PPC405 Debug Port JTAG UART
UARTlite
XMD stub
Host Software
PowerPC-eabi-gdb
Host Software
mb-gdb
Host Software
Tcl/Terminal Interface
XMD
JTAG
MB Cycle-Accurate Instruction Set Simulator
JTAG
MicroBlaze System
MDM
Host Software
© 2005 Xilinx, Inc. All Rights Reserved
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 that you can experiment with correcting the effects of one bug and go on to another
• You can use GDB to debug programs written in C and C++
© 2005 Xilinx, Inc. All Rights Reserved
GDB
MemoryLocation
AssemblyInstructions
C Code
© 2005 Xilinx, Inc. All Rights Reserved
GDB GUI
• Runtime control– 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)
© 2005 Xilinx, Inc. All Rights Reserved
GDB Functionality• Breakpoints can be enabled or disabled• To change any memory value, simply double-click in a memory field
© 2005 Xilinx, Inc. All Rights Reserved
GDB Functionality
• Blue represents registers that have changed• To change any value, double-click in a field
© 2005 Xilinx, Inc. All Rights Reserved
XMD Functionality
User Interface
User Interface
Target Hardware
(TCP/IP) (TCP/IP)
GDB Remote Protocol
GDB Remote Protocol
JTAG UART
PowerPC™ System MicroBlaze™ System
PPC405 Debug Port JTAG UART
UARTlite
XMD stub
Host Software
PowerPC-eabi-gdb
Host Software
mb-gdb
Host Software
Tcl/Terminal Interface
XMD
JTAG
MB Cycle-Accurate Instruction Set Simulator
JTAG
MicroBlaze System
MDM
Host Software
© 2005 Xilinx, Inc. All Rights Reserved
XMD Functionality
• Xilinx Microprocessor Debug (XMD) engine – A program that facilitates a unified GDB interface– A Tool command language (Tcl) interface
• XMD supports debugging user programs on different targets:– Cycle-accurate MicroBlaze processor instruction set simulator– MicroBlaze systems running xmdstub on a hardware board– MicroBlaze systems using the MDM peripheral– PowerPC systems on a hardware board
• mb-gdb and powerpc-eabi-gdb communicate with xmd by using the Remote TCP protocol and controlling the corresponding targets
• GDB can connect to xmd on the same computer or on a remote computer on the Internet
© 2005 Xilinx, Inc. All Rights Reserved
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
© 2005 Xilinx, Inc. All Rights Reserved
MicroBlaze Processor: XMD
• Three ways to debug MicroBlaze processor code:– OPB JTAG UART core
• Intrusive: requires xmdstub software
– OPB UART core• Intrusive: requires
xmdstub software– OPB MDM core
• Non-intrusive: hardware interface
MicroBlaze
(TCP/IP)
GDB Remote Protocol
UART
Host Software
mb-gdb
Host Software
Tcl/Terminal Interface
XMD
JTAG
MB Cycle-Accurate Instruction Set Simulator
JTAG
JTAGUART UART MDM
OPB Bus
© 2005 Xilinx, Inc. All Rights Reserved
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 system2. A JTAG UART or a UART must be specified as the DEBUG_PERIPHERAL3. 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
• Connect to a MicroBlaze processor target via a stub, using JTAC communication, and an FPGA which is second in the JTAG chain
© 2005 Xilinx, Inc. All Rights Reserved
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– XMD% mbconnect sim
© 2005 Xilinx, Inc. All Rights Reserved
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– XMD% mbconnect mdm
© 2005 Xilinx, Inc. All Rights Reserved
XMD Options
• mbconnect <sim|stub|mdm> [options]• Simulator target options
– -memsize size
• xmdstub target options– -comm <serial|jtag>– -posit device position– -chain device count <list of BSDL files>– -port serial port– -baud baud rate
© 2005 Xilinx, Inc. All Rights Reserved
Outline
• Software Development Kit • Debugging Tools• Debugging Using XPS
• Debugging Using SDK• Simultaneous HW/SW Debug
© 2005 Xilinx, Inc. All Rights Reserved
A Debugging Sample
This will go through the necessary steps, generate a bitstream file, and download the file
Compile with the debugging option
Compile with the debugging option
1Download the bitstreamDownload the bitstream
2
© 2005 Xilinx, Inc. All Rights Reserved
Start XMD
Set XMD Debug OptionsSet XMD Debug Options3
This opens a connection with the hardware, indicating whether the connecting ports and are enabled or not
Start the XMD shellStart the XMD shell4
Set connection type and JTAG properties
© 2005 Xilinx, Inc. All Rights Reserved
Start Software Debugger
Start Software DebuggerStart Software Debugger5
A source code window displays
A source code window displays
6
Change the code window display from SOURCE to MIXED to show C and assembly code
If there are more than one application in the project then the tools will provide choice to select an application
© 2005 Xilinx, Inc. All Rights Reserved
Software Debugger Connect
A window displayingC and assembly code
A window displayingC and assembly code
7
Select the target as Remote/TCP: XMD
Select the target as Remote/TCP: XMD
8
Enter the port number that was displayed when connecting to the target
© 2005 Xilinx, Inc. All Rights Reserved
Debug Program
Set any breakpoints as necessarySet any breakpoints as necessary9
Click the Run button
Click the Run button
10
When a breakpoint is encountered, the debugger stops
When a breakpoint is encountered, the debugger stops
11
View the necessary windowsView the necessary windows12
Exit the debugger by typing quit in the console window
© 2005 Xilinx, Inc. All Rights Reserved
Outline
• Software Development Kit • Debugging Tools• Debugging Using XPS• Debugging Using SDK
• Simultaneous HW/SW Debug
© 2005 Xilinx, Inc. All Rights Reserved
Debugging Using SDK
Eclipse CDT
XMD
powerpc-eabi-gdb (or)
mb-gdb
JTAG / XMD protocolXilinx custom graphical debug interface
auto-launched
auto-launched
gdb remote protocol
© 2005 Xilinx, Inc. All Rights Reserved
SDK Debug Perspective
The stack frame for target threads that you are debugging. Each thread in your program is represented as a node in the tree
Variables, Breakpoints, and Registers views allow for viewing and real-time interaction with the view contents for more powerful debugging potential
C/C++ editor highlights the location of the execution pointer, along with allowing the setting of breakpoints
Code outline and disassembly view provide compiler level insight to what is occurring in the running source
Console view lists output information
1
2
3
4 5
5
43
2
1
© 2005 Xilinx, Inc. All Rights Reserved
Debugging in XPS vs SDKDebugging in XPS
- Download bitstream from XPS
- Launch XMD- Provide Target Connection
Options- Launch GDB (Insight GUI)- Set GDB Server connection
port in GDB- Download program - Begin Debugging
Debugging in SDK
- Download bitstream from XPS
- Launch XMD- Provide Target Connection
Options- Launch GDB (Insight GUI)- Set GDB Server connection
port in GDB- Download program - Begin Debugging
© 2005 Xilinx, Inc. All Rights Reserved
Knowledge Check
• 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?
© 2005 Xilinx, Inc. All Rights Reserved
Answers
• What is the XMD command line used to connect to a MicroBlaze processor core via JTAG?– XMD% mbconnect stub -comm jtag -posit 2
• What is the advantage of using MDM over a JTAG UART?– Non-intrusive– Less memory required
• Into what parts of the design do debuggers provide visibility?– Registers– Memory– Stack– Variables – Expressions
© 2005 Xilinx, Inc. All Rights Reserved
Knowledge Check
• Describe XPS-SDK flow
© 2005 Xilinx, Inc. All Rights Reserved
Answers
• Describe XPS-SDK flow– Using XPS, design the embedded system hardware platform and specify
the software platform settings (libraries, device drivers, etc.)– Launch SDK, create a software application project, and point to the XPS
project containing the embedded system platform– Using SDK, develop and compile applications for the selected embedded
system– Using SDK, download the software executable to the target device to debug
and profile your software application. (Use XPS or iMPACT tools to first download the hardware platform bitstream to the FPGA device)
– In XPS, point to the software executable created in SDK and merge it into the FPGA bitstream for production use
© 2005 Xilinx, Inc. All Rights Reserved
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– Xilinx Platform Studio SDK Online Documentation
• Support Website– EDK Website: www.xilinx.com/edk
© 2005 Xilinx, Inc. All Rights Reserved
Outline
• Software Development Kit• Debugging Tools• Debugging Using XPS • Debugging Using SDK• Simultaneous HW/SW Debug
© 2005 Xilinx, Inc. All Rights Reserved
Simultaneous HW/SW Debug• 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
– Treated like the peripheral cores
Set breakpoint in GDB: when hit → triggers the ChipScope tool
Set trigger in ChipScope: when hit → halts CPU and debugger stops
UART GPIOOn-Chip
PeripheralHi-Speed
PeripheralGB
E-Net
e.g.Memory
Controller
ArbiterOn-Chip Peripheral Bus
Arb
iter
Processor Local Bus
PowerPC405 Core
DSOCMBRAM
ISOCMBRAM
BusBridge
UART GPIOOn-Chip
PeripheralUARTUART GPIOGPIO
On-ChipPeripheralOn-Chip
PeripheralHi-Speed
PeripheralGB
E-Net
e.g.Memory
Controller
Hi-SpeedPeripheralHi-Speed
PeripheralGB
E-NetGB
E-Net
e.g.Memory
Controller
e.g.Memory
Controller
ArbiterOn-Chip Peripheral Bus
Arb
iter
Processor Local Bus
PowerPC405 Core
DSOCMBRAM
ISOCMBRAM
DSOCMBRAM
DSOCMBRAM
DSOCMBRAM
ISOCMBRAMISOCMBRAMISOCMBRAM
BusBridge
BusBridge
IBAIBA
MicroBlaze32-Bit RISC CoreMicroBlaze
32-Bit RISC CoreMDM
Minimal skid-by as cross-triggering is done on chip between IBA cores and PPC and MicroBlaze™ debug
interfaces
© 2005 Xilinx, Inc. All Rights Reserved
Simultaneous HW/SW Debug
Flexible Soft IPFlexible Soft IPMicroBlaze
32-Bit RISC CoreMicroBlaze
32-Bit RISC Core
Arb
iter OPB
On-Chip Peripheral Bus
Arb
iter
Arb
iter OPB
On-Chip Peripheral BusOn-Chip Peripheral Bus
MDMMDM
IBAIBA
JTAGJTAG Flexible Soft IPFlexible Soft IPMicroBlaze
32-Bit RISC CoreMicroBlaze
32-Bit RISC Core
Arb
iter OPB
On-Chip Peripheral Bus
Arb
iter
Arb
iter OPB
On-Chip Peripheral BusOn-Chip Peripheral Bus
MDMMDM
IBAIBA
JTAGJTAG
XMDXMD
Xilinx parallel cable
Active trigger when addr bus = 0xC200
Trigger out signal from IBA to CPU debug halt signal in