Chapter 6. Sourcery G++ Debug Sprite

This chapter describes the use of the Sourcery G++ Debug Sprite for remote debugging. The Sprite is provided for debugging of the Linux or uClinux kernel on the target board. This chapter includes information about the debugging devices and boards supported by the Sprite for ARM GNU/Linux.

Table of Contents

Debug Sprite Example
Invoking Sourcery G++ Debug Sprite
Sourcery G++ Debug Sprite Options
Remote Debug Interface Devices
FlashPro Devices
Debugging a Remote Board
Supported Board Files
Board File Syntax

Sourcery G++ Lite contains the Sourcery G++ Debug Sprite for ARM GNU/Linux. This Sprite is provided to allow debugging of programs running on a bare board. You can use the Sprite to debug a program when there is no operating system on the board, or for debugging the operating system itself. If the board is running an operating system, and you wish to debug a program running on that OS, you should use the facilities provided by the OS itself (for instance, using gdbserver).

The Sprite acts as an interface between GDB and external debug devices and libraries. Refer to the section called “Invoking Sourcery G++ Debug Sprite” for information about the specific devices supported by this version of Sourcery G++ Lite.

Note for Linux/uClinux users

The Debug Sprite provided with Sourcery G++ Lite allows remote debugging of the Linux or uClinux kernel running on the target. For remote debugging of application programs, you should use gdbserver instead. See Chapter 3, Sourcery G++ Lite for ARM GNU/Linux for details about how to install and run gdbserver on the target.

Important

The Sourcery G++ Debug Sprite is not part of the GNU Debugger and is not free or open-source software. You may use the Sourcery G++ Debug Sprite only with the GNU Debugger. You may not distribute the Sourcery G++ Debug Sprite to any third party. You may use the ARM SWD support (as used for debugging Luminary Micro Stellaris CPUs) only with target systems which contain Cortex-M1 or Cortex-M3 microprocessor managed under license from ARM.

Debug Sprite Example

This section demonstrates execution and debugging of a simple application. Start by creating a file named fib.c:

#include <unistd.h>

static int Fib (unsigned n, unsigned a, unsigned b)
{
  unsigned count;

  for (count = 0; count != b; count++)
    write (1, ".", 1);
  write (1, "\n", 1);
  
  if (n)
    Fib (n - 1, b, a + b);
}

int main ()
{
  write (1, "Fibonacci\n", 10);
  Fib (9, 0, 1);
  return 0;
}

First compile and link the program for the target board. If it is a stand-alone program for a ARM M-profile Simulator board use:

> arm-none-linux-gnueabi-gcc -mcpu=cortex-m3 -mthumb \
  -Tgeneric-m-hosted.ld fib.c -o fib -g

For other boards you must make appropriate substitutions in the preceding command. If your program is an operating system kernel such as uClinux or Linux, your usual build method should be adequate, as the kernel contains the necessary initialization code for interrupt handlers.

Verify that the Sourcery G++ Debug Sprite can detect your debug hardware:

> arm-none-linux-gnueabi-sprite -i

This prints out a list of supported device types. For devices that can be autodetected, it additionally probes for and prints out a list of attached devices. For instance:

CodeSourcery ARM Debug Sprite
    (Sourcery G++ Lite Sourcery G++ Lite 2008q3-72)
rdi: (rdi-library=<file>&rdi-config=<file>) RDI Device
  rdi:/// - RDI Device
armusb: [speed=<n:0-7>] ARMUSB device
  armusb:/// - ARMUSB Device

This shows that RDI and ARM­USB devices are supported. The exact set of supported devices depends on your host system and the version of Sourcery G++ you have installed.

Start the debugger on your host system:

> arm-none-linux-gnueabi-gdb fib

Connecting GDB to the board depends on the debug device you are using. If you are using a ARM­USB debug device, use:

(gdb) target remote | arm-none-linux-gnueabi-sprite \
armusb:///?speed=2 lm3s8xx
Remote debugging using | arm-none-linux-gnueabi-sprite \
armusb:///?speed=2 lm3s8xx
arm-none-linux-gnueabi-sprite:Target reset
0x00008936 in ?? ()

If you are connecting via RDI, you must specify the full path to the RDI library file and configuration file for that library:

(gdb) target remote | arm-none-linux-gnueabi-sprite \
"rdi:///?rdi-library=library&rdi-config=config"
Remote debugging using | arm-none-linux-gnueabi-sprite \
"rdi:///?rdi-library=library&rdi-config=config"
ARMulator RVARMulatorISS1.4 [Build 297]
For support please contact support-sw@arm.com
Software supplied by: ARM Limited
ARM1136JF-S
ARM11 Instruction Set Simulator, May 24 2006
ARM Instruction Set Simulator for  [Build number 297]
, CP15, 8KB ICache, 8KB DCache 32KB DTCRam0 -Supports SmartCaching
32KB ITCRam0 -Supports SmartCaching , VFP11 (no support code), \
4GB, Pagetables, Mapfile, VIC - PL192
VIC: this is a RELEASE build
, Profiler, SIMRDI MemCallback, Tube, Millisecond [6666.67
cycles_per_millisecond], Tracer
Tracing: Instructions, Memory accesses, Events, Disassemble, \
Trace bus, Trace registers, Opcode Fetch Mask \
0x00000000-0x00000000, RDI Codesequences, Semihosting, \
CP14 Debug(6,2,2)
Little endian
arm-none-linux-gnueabi-sprite:Missing config file; \
this may not work
arm-none-linux-gnueabi-sprite:Target reset
0x00000000 in ?? ()

Refer to the section called “Invoking Sourcery G++ Debug Sprite” for more information about the supported devices in Sourcery G++ Lite and details about the command-line syntax for invoking the Sprite.

At this point you can use GDB to load your program onto the target board and control its execution as required:

(gdb) load
Loading section .text, size 0xaa0 lma 0x0
Loading section .ARM.exidx, size 0x8 lma 0xaa0
Loading section .data, size 0xfc lma 0xaa8
Start address 0x11, load size 2980
Transfer rate: 6231 bits/sec, 596 bytes/write.

Set a breakpoint so that the debugger stops when your program reaches main:

(gdb) break main
Breakpoint 1 at 0x20000524: file fib.c, line 17.

Allow the program to execute until it reaches main:

(gdb) continue
Continuing.
main () at fib.c:13
13         write (1, "Fibonacci\n", 10);
(gdb) next
Fibonacci
14         Fib (9, 0, 1);

Permit the program to finish executing with:

(gdb) continue
Continuing.
.
.
..
...
.....
........
.............
.....................
..................................
.......................................................

Program exited normally.