Next: , Previous: Tap Creation, Up: Top


12 Target Configuration

This chapter discusses how to create a GDB Debug Target. Before creating a “target” a JTAG Tap DOTTED.NAME must exist first.

12.1 targets [NAME]

Note: This command name is PLURAL - not singular.

With NO parameter, this plural targets command lists all known targets in a human friendly form.

With a parameter, this pural targets command sets the current target to the given name. (ie: If there are multiple debug targets)

Example:

(gdb) mon targets
      CmdName     Type     Endian    ChainPos   State     
--  ---------- ---------- ---------- -------- ----------
    0: target0  arm7tdmi   little        0      halted

12.2 target COMMANDS

Note: This command name is SINGULAR - not plural. It is used to manipulate specific targets, to create targets and other things.

Once a target is created, a TARGETNAME (object) command is created; see below for details.

The TARGET command accepts these sub-commands:

12.3 TARGETNAME (object) commands

Use: Once a target is created, an “object name” that represents the target is created. By convention, the target name is identical to the tap name. In a multiple target system, one can preceed many common commands with a specific target name and effect only that target.

         str912.cpu    mww 0x1234 0x42
         omap3530.cpu  mww 0x5555 123

Model: The Tcl/Tk language has the concept of object commands. A good example is a on screen button, once a button is created a button has a name (a path in TK terms) and that name is useable as a 1st class command. For example in TK, one can create a button and later configure it like this:

         # Create
         button .foobar -background red -command { foo }
         # Modify
         .foobar configure -foreground blue
         # Query
         set x [.foobar cget -background]
         # Report
         puts [format "The button is %s" $x]

In OpenOCD's terms, the “target” is an object just like a Tcl/Tk button. Commands avaialble as a “target object” are:

12.4 Target Events

At various times, certain things can happen, or you want them to happen.

Examples:

All of the above items are handled by target events.

To specify an event action, either during target creation, or later via “$_TARGETNAME configure” see this example.

Syntactially, the option is: “-event NAME BODY” where NAME is a target event name, and BODY is a tcl procedure or string of commands to execute.

The programmers model is the “-command” option used in Tcl/Tk buttons and events. Below are two identical examples, the first creates and invokes small procedure. The second inlines the procedure.

        proc my_attach_proc { } {
            puts "RESET...."
            reset halt
        }
        mychip.cpu configure -event gdb-attach my_attach_proc
        mychip.cpu configure -event gdb-attach { puts "Reset..." ; reset halt }

12.5 Current Events

The following events are available:

12.6 target create

     target create <NAME> <TYPE> <PARAMS ...>


This command creates a GDB debug target that refers to a specific JTAG tap.

12.7 Target Config/Cget Options

These options can be specified when the target is created, or later via the configure option or to query the target via cget.

Example:
       for { set x 0 } { $x < [target count] } { incr x } {
         set name [target number $x]
         set y [$name cget -endian]
         set z [$name cget -type]
         puts [format "Chip %d is %s, Endian: %s, type: %s" $x $y $z]
       }

12.8 Target Varients

12.9 working_area - Command Removed


Please use the “$_TARGETNAME configure -work-area-... parameters instead
This documentation remains because there are existing scripts that still use this that need to be converted.

       working_area target# address  size backup| [virtualaddress]


The target# is a the 0 based target numerical index.

This command specifies a working area for the debugger to use. This may be used to speed-up downloads to target memory and flash operations, or to perform otherwise unavailable operations (some coprocessor operations on ARM7/9 systems, for example). The last parameter decides whether the memory should be preserved (<backup>) or can simply be overwritten (<nobackup>). If possible, use a working_area that doesn't need to be backed up, as performing a backup slows down operation.