\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename openocd.info
-@settitle Open On-Chip Debugger (openocd)
+@settitle Open On-Chip Debugger (OpenOCD)
@dircategory Development
@direntry
* OpenOCD: (openocd). Open On-Chip Debugger.
@end copying
@titlepage
-@title Open On-Chip Debugger (openocd)
-@subtitle Edition @value{EDITION} for openocd version @value{VERSION}
+@title Open On-Chip Debugger (OpenOCD)
+@subtitle Edition @value{EDITION} for OpenOCD version @value{VERSION}
@subtitle @value{UPDATED}
@page
@vskip 0pt plus 1filll
@top OpenOCD
This manual documents edition @value{EDITION} of the Open On-Chip Debugger
-(openocd) version @value{VERSION}, @value{UPDATED}.
+(OpenOCD) version @value{VERSION}, @value{UPDATED}.
@insertcopying
@menu
-* About:: About Openocd.
-* Developers:: Openocd developers
-* Building:: Building Openocd
-* Running:: Running Openocd
-* Configuration:: Openocd Configuration.
+* About:: About OpenOCD.
+* Developers:: OpenOCD developers
+* Building:: Building OpenOCD
+* Running:: Running OpenOCD
+* Configuration:: OpenOCD Configuration.
* Target library:: Target library
-* Commands:: Openocd Commands
+* Commands:: OpenOCD Commands
* Sample Scripts:: Sample Target Scripts
-* GDB and Openocd:: Using GDB and Openocd
+* GDB and OpenOCD:: Using GDB and OpenOCD
+* TCL and OpenOCD:: Using TCL and OpenOCD
+* TCL scripting API:: Tcl scripting API
* Upgrading:: Deprecated/Removed Commands
* FAQ:: Frequently Asked Questions
* License:: GNU Free Documentation License
@unnumbered About
@cindex about
-The Open On-Chip Debugger (openocd) aims to provide debugging, in-system programming
+The Open On-Chip Debugger (OpenOCD) aims to provide debugging, in-system programming
and boundary-scan testing for embedded target devices. The targets are interfaced
using JTAG (IEEE 1149.1) compliant hardware, but this may be extended to other
connection types in the future.
-Openocd currently supports Wiggler (clones), FTDI FT2232 based JTAG interfaces, the
+OpenOCD currently supports Wiggler (clones), FTDI FT2232 based JTAG interfaces, the
Amontec JTAG Accelerator, and the Gateworks GW1602. It allows ARM7 (ARM7TDMI and ARM720t),
ARM9 (ARM920t, ARM922t, ARM926ej--s, ARM966e--s), XScale (PXA25x, IXP42x) and
Cortex-M3 (Luminary Stellaris LM3 and ST STM32) based cores to be debugged.
@chapter Developers
@cindex developers
-Openocd has been created by Dominic Rath as part of a diploma thesis written at the
+OpenOCD was created by Dominic Rath as part of a diploma thesis written at the
University of Applied Sciences Augsburg (@uref{http://www.fh-augsburg.de}).
Others interested in improving the state of free and open debug and testing technology
are welcome to participate.
Other developers have contributed support for additional targets and flashes as well
as numerous bugfixes and enhancements. See the AUTHORS file for regular contributors.
+The main OpenOCD web site is available at @uref{http://openocd.berlios.de/web/}
+
@node Building
@chapter Building
-@cindex building openocd
+@cindex building OpenOCD
You can download the current SVN version with SVN client of your choice from the
following repositories:
(@uref{http://svn.berlios.de/svnroot/repos/openocd/trunk})
-Using the SVN command line client, you could use the following command to fetch the
+Using the SVN command line client, you can use the following command to fetch the
latest version (make sure there is no (non-svn) directory called "openocd" in the
current directory):
svn checkout svn://svn.berlios.de/openocd/trunk openocd
@end smallexample
-Building the OpenOCD requires a recent version of the GNU autotools.
+Building OpenOCD requires a recent version of the GNU autotools.
On my build system, I'm using autoconf 2.13 and automake 1.9. For building on Windows,
you have to use Cygwin. Make sure that your @env{PATH} environment variable contains no
other locations with Unix utils (like UnxUtils) - these can't handle the Cygwin
homepage (@uref{www.amontec.com}), as the JTAGkey uses a non-standard VID/PID.
@end itemize
-Please note that the ftdi2232 variant (using libftdi) isn't supported under Cygwin.
-You have to use the ftd2xx variant (using FTDI's D2XX) on Cygwin.
+libftdi is supported under windows. Versions earlier than 0.13 will require patching.
+see contrib/libftdi for more details.
In general, the D2XX driver provides superior performance (several times as fast),
-but has the draw-back of being binary-only - though that isn't as worse, as it isn't
+but has the draw-back of being binary-only - though that isn't that bad, as it isn't
a kernel module, only a user space library.
To build OpenOCD (on both Linux and Cygwin), use the following commands:
@smallexample
make
@end smallexample
-Make builds the OpenOCD, and places the final executable in ./src/.
+Make builds OpenOCD, and places the final executable in ./src/.
The configure script takes several options, specifying which JTAG interfaces
should be included:
@item
@option{--enable-ft2232_ftd2xx}
@footnote{Using the latest D2XX drivers from FTDI and following their installation
-instructions, I had to use @option{--enable-ft2232_libftd2xx} for the OpenOCD to
+instructions, I had to use @option{--enable-ft2232_libftd2xx} for OpenOCD to
build properly.}
@item
@option{--enable-ft2232_libftdi}
@option{--enable-presto_libftdi}
@item
@option{--enable-presto_ftd2xx}
+@item
+@option{--enable-jlink}
@end itemize
If you want to access the parallel port using the PPDEV interface you have to specify
@node Running
@chapter Running
-@cindex running openocd
+@cindex running OpenOCD
@cindex --configfile
@cindex --debug_level
@cindex --logfile
@cindex --search
-The OpenOCD runs as a daemon, waiting for connections from clients (Telnet or GDB).
-Run with @option{--help} or @option{-h} to view the available command line arguments.
+OpenOCD runs as a daemon, waiting for connections from clients (Telnet, GDB, Other).
+Run with @option{--help} or @option{-h} to view the available command line switches.
It reads its configuration by default from the file openocd.cfg located in the current
working directory. This may be overwritten with the @option{-f <configfile>} command line
-switch. @option{-f} can be specified multiple times, in which case the config files
+switch. The @option{-f} command line switch can be specified multiple times, in which case the config files
are executed in order.
-Also it is possible to interleave commands w/config scripts using the @option{-c}.
+Also it is possible to interleave commands w/config scripts using the @option{-c} command line switch.
To enable debug output (when reporting problems or working on OpenOCD itself), use
the @option{-d} command line switch. This sets the debug_level to "3", outputting
You can redirect all output from the daemon to a file using the @option{-l <logfile>} switch.
-Search paths for config/script files can be added to openocd by using
+Search paths for config/script files can be added to OpenOCD by using
the @option{-s <search>} switch. The current directory and the OpenOCD target library
is in the search path by default.
-NB! OpenOCD will launch the GDB & telnet server even if it can not establish a connection
+Note! OpenOCD will launch the GDB & telnet server even if it can not establish a connection
with the target. In general, it is possible for the JTAG controller to be unresponsive until
the target is set up correctly via e.g. GDB monitor commands in a GDB init script.
@node Configuration
@chapter Configuration
@cindex configuration
-The Open On-Chip Debugger (OpenOCD) runs as a daemon, and reads it current configuration
+OpenOCD runs as a daemon, and reads it current configuration
by default from the file openocd.cfg in the current directory. A different configuration
-file can be specified with the @option{-f <conf.file>} given at the openocd command line.
+file can be specified with the @option{-f <conf.file>} command line switch specified when starting OpenOCD.
The configuration file is used to specify on which ports the daemon listens for new
connections, the JTAG interface used to connect to the target, the layout of the JTAG
command mode. This can be useful to add commands to the startup scripts and commands
such as resetting the target, programming flash, etc. To reset the CPU upon startup,
add "init" and "reset" at the end of the config script or at the end of the
-openocd command line using the -c option.
+OpenOCD command line using the @option{-c} command line switch.
@cindex init
@item @b{telnet_port} <@var{number}>
@cindex telnet_port
first target will be gdb_port, the second target will listen on gdb_port + 1, and so on.
@item @b{gdb_detach} <@var{resume|reset|halt|nothing}>
@cindex gdb_detach
-Configures what openocd will do when gdb detaches from the daeman.
+Configures what OpenOCD will do when gdb detaches from the daeman.
Default behaviour is <@var{resume}>
@item @b{gdb_memory_map} <@var{enable|disable}>
@cindex gdb_memory_map
-Set to <@var{enable}> so that openocd will send the memory configuration to gdb when
+Set to <@var{enable}> to cause OpenOCD to send the memory configuration to gdb when
requested. gdb will then know when to set hardware breakpoints, and program flash
using the gdb load command. @option{gdb_flash_program enable} will also need enabling
for flash programming to work.
-Default behaviour is <@var{disable}>
+Default behaviour is <@var{enable}>
@item @b{gdb_flash_program} <@var{enable|disable}>
@cindex gdb_flash_program
-Set to <@var{enable}> so that openocd will program the flash memory when a
+Set to <@var{enable}> to cause OpenOCD to program the flash memory when a
vFlash packet is received.
Default behaviour is <@var{enable}>
-@item @b{daemon_startup} <@var{mode}>
-@cindex daemon_startup
-@option{mode} can either @option{attach} or @option{reset}
-This is equivalent to adding "init" and "reset" to the end of the config script.
-
-It is availble as a command mainly for backwards compatibility.
+ at item @b{tcl_port} <@var{number}>
+ at cindex tcl_port
+Port on which to listen for incoming TCL syntax. This port is intended as
+a simplified RPC connection that can be used by clients to issue commands
+and get the output from the TCL engine.
@end itemize
@section JTAG interface configuration
@item @b{gw16012}
Gateworks GW16012 JTAG programmer.
@end itemize
+@itemize @minus
+@item @b{jlink}
+Segger jlink usb adapter
+@end itemize
@end itemize
@itemize @bullet
-@item @b{jtag_speed} <@var{reset speed}> <@var{post reset speed}>
+@item @b{jtag_speed} <@var{reset speed}>
@cindex jtag_speed
Limit the maximum speed of the JTAG interface. Usually, a value of zero means maximum
-speed. The actual effect of this option depends on the JTAG interface used. Reset
-speed is used during reset and post reset speed after reset. post reset speed
-is optional, in which case the reset speed is used.
+speed. The actual effect of this option depends on the JTAG interface used.
+
+The speed used during reset can be adjusted using setting jtag_speed during
+pre_reset and post_reset events.
@itemize @minus
@item wiggler: maximum speed / @var{number}
@item ft2232: 6MHz / (@var{number}+1)
@item amt jtagaccel: 8 / 2**@var{number}
+@item jlink: maximum speed in kHz (0-12000), 0 will use RTCK
@end itemize
Note: Make sure the jtag clock is no more than @math{1/6th × CPU-Clock}. This is
especially true for synthesized cores (-S).
-@item @b{jtag_khz} <@var{reset speed kHz}> <@var{post reset speed kHz}>
+@item @b{jtag_khz} <@var{reset speed kHz}>
@cindex jtag_khz
Same as jtag_speed, except that the speed is specified in maximum kHz. If
the device can not support the rate asked for, or can not translate from
@item @b{jtag_nsrst_delay} <@var{ms}>
@cindex jtag_nsrst_delay
-How long (in miliseconds) the OpenOCD should wait after deasserting nSRST before
+How long (in milliseconds) OpenOCD should wait after deasserting nSRST before
starting new JTAG operations.
@item @b{jtag_ntrst_delay} <@var{ms}>
@cindex jtag_ntrst_delay
-How long (in miliseconds) the OpenOCD should wait after deasserting nTRST before
+How long (in milliseconds) OpenOCD should wait after deasserting nTRST before
starting new JTAG operations.
The jtag_n[st]rst_delay options are useful if reset circuitry (like a reset supervisor,
@itemize @minus
@item @b{wiggler}
@cindex wiggler
-Original Wiggler layout, also supported by several clones, such
+The original Wiggler layout, also supported by several clones, such
as the Olimex ARM-JTAG
@item @b{old_amt_wiggler}
@cindex old_amt_wiggler
version available from the website uses the original Wiggler layout ('@var{wiggler}')
@item @b{chameleon}
@cindex chameleon
-Describes the connection of the Amontec Chameleon's CPLD when operated in
-configuration mode. This is only used to program the Chameleon itself, not
-a connected target.
+The Amontec Chameleon's CPLD when operated in configuration mode. This is only used to program the Chameleon itself, not a connected target.
@item @b{dlc5}
@cindex dlc5
-Xilinx Parallel cable III.
+The Xilinx Parallel cable III.
@item @b{triton}
@cindex triton
The parallel port adapter found on the 'Karo Triton 1 Development Board'.
(see @uref{http://www.lartmaker.nl/projects/jtag/}).
@item @b{flashlink}
@cindex flashlink
-ST Parallel cable.
+The ST Parallel cable.
@end itemize
@item @b{parport_write_on_exit} <@var{on|off}>
@cindex parport_write_on_exit
This will configure the parallel driver to write a known value to the parallel
-interface on exiting openocd
+interface on exiting OpenOCD
@end itemize
@section amt_jtagaccel options
signals. Valid layouts are
@itemize @minus
@item @b{usbjtag}
-The "USBJTAG-1" layout described in the original OpenOCD diploma thesis
+"USBJTAG-1" layout described in the original OpenOCD diploma thesis
@item @b{jtagkey}
Amontec JTAGkey and JTAGkey-tiny
@item @b{signalyzer}
@item @b{ft2232_vid_pid} <@var{vid}> <@var{pid}>
The vendor ID and product ID of the FTDI FT2232 device. If not specified, the FTDI
-default values are used. This command is not available on Windows.
+default values are used. Multiple <@var{vid}>, <@var{pid}> pairs may be given, eg.
+@smallexample
+ft2232_vid_pid 0x0403 0xcff8 0x15ba 0x0003
+@end smallexample
@item @b{ft2232_latency} <@var{ms}>
On some systems using ft2232 based JTAG interfaces the FT_Read function call in
ft2232_read() fails to return the expected number of bytes. This can be caused by
@section Target configuration
@itemize @bullet
-@item @b{target} <@var{type}> <@var{endianess}> <@var{reset_mode}> <@var{JTAG pos}>
+@item @b{target} <@var{type}> <@var{endianess}> <@var{JTAG pos}>
<@var{variant}>
@cindex target
Defines a target that should be debugged. Currently supported types are:
Endianess may be @option{little} or @option{big}.
-The reset_mode specifies what should happen to the target when a reset occurs:
-@itemize @minus
-@item @b{reset_halt}
-@cindex reset_halt
-Immediately request a target halt after reset. This allows targets to be debugged
-from the very first instruction. This is only possible with targets and JTAG
-interfaces that correctly implement the reset signals.
-@item @b{reset_init}
-@cindex reset_init
-Similar to @option{reset_halt}, but executes the script file defined to handle the
-'reset' event for the target. Like @option{reset_halt} this only works with
-correct reset implementations.
-@item @b{reset_run}
-@cindex reset_run
-Simply let the target run after a reset.
-@item @b{run_and_halt}
-@cindex run_and_halt
-Let the target run for some time (default: 1s), and then request halt.
-@item @b{run_and_init}
-@cindex run_and_init
-A combination of @option{reset_init} and @option{run_and_halt}. The target is allowed
-to run for some time, then halted, and the @option{reset} event script is executed.
-@end itemize
-
-On JTAG interfaces / targets where system reset and test-logic reset can't be driven
-completely independent (like the LPC2000 series), or where the JTAG interface is
-unavailable for some time during startup (like the STR7 series), you can't use
-@option{reset_halt} or @option{reset_init}.
-
@item @b{target_script} <@var{target#}> <@var{event}> <@var{script_file}>
@cindex target_script
-Event is either @option{reset}, @option{post_halt}, @option{pre_resume} or @option{gdb_program_config}
-
-TODO: describe exact semantic of events
-@item @b{run_and_halt_time} <@var{target#}> <@var{time_in_ms}>
-@cindex run_and_halt_time
-The amount of time the debugger should wait after releasing reset before it asserts
-a debug request. This is used by the @option{run_and_halt} and @option{run_and_init}
-reset modes.
+Event is one of the following:
+@option{pre_reset}, @option{reset}, @option{post_reset}, @option{post_halt},
+@option{pre_resume} or @option{gdb_program_config}.
+@option{post_reset} and @option{reset} will produce the same results.
+
@item @b{working_area} <@var{target#}> <@var{address}> <@var{size}>
<@var{backup}|@var{nobackup}>
@cindex working_area
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 <@var{backup}>. If possible, use
-a working_area that doesn't need to be backed up, as that slows down operation.
+parameter decides whether the memory should be preserved (<@var{backup}>) or can simply be overwritten (<@var{nobackup}>). If possible, use
+a working_area that doesn't need to be backed up, as performing a backup slows down operation.
@end itemize
@subsection arm7tdmi options
@cindex arm7tdmi options
-target arm7tdmi <@var{endianess}> <@var{reset_mode}> <@var{jtag#}>
+target arm7tdmi <@var{endianess}> <@var{jtag#}>
The arm7tdmi target definition requires at least one additional argument, specifying
the position of the target in the JTAG daisy-chain. The first JTAG device is number 0.
The optional [@var{variant}] parameter has been removed in recent versions.
@cindex arm966e options
ARM966e options are similar to ARM9TDMI options.
+@subsection cortex_m3 options
+@cindex cortex_m3 options
+use variant <@var{variant}> @option{lm3s} when debugging luminary lm3s targets. This will cause
+openocd to use a software reset rather than asserting SRST to avoid a issue with clearing
+the debug registers. This is fixed in Fury Rev B, DustDevil Rev B, Tempest, these revisions will
+be detected and the normal reset behaviour used.
+
@subsection xscale options
@cindex xscale options
Supported variants are @option{ixp42x}, @option{ixp45x}, @option{ixp46x},
Similarly there are example scripts for configuring the JTAG interface.
The command line below uses the example parport configuration scripts
-that ships with OpenOCD, then configures the str710.cfg target and
+that ship with OpenOCD, then configures the str710.cfg target and
finally issues the init and reset command. The communication speed
is set to 10kHz for reset and 8MHz for post reset.
@smallexample
-openocd -f interface/parport.cfg -c "jtag_khz 10 8000" -f target/str710.cfg -c "init" -c "reset"
+openocd -f interface/parport.cfg -f target/str710.cfg -c "init" -c "reset"
@end smallexample
@chapter Commands
@cindex commands
-The Open On-Chip Debugger (OpenOCD) allows user interaction through a telnet interface
-(default: port 4444) and a GDB server (default: port 3333). The command line interpreter
+OpenOCD allows user interaction through a GDB server (default: port 3333),
+a telnet interface (default: port 4444), and a TCL interface (default: port 5555). The command line interpreter
is available from both the telnet interface and a GDB session. To issue commands to the
interpreter from within a GDB session, use the @option{monitor} command, e.g. use
@option{monitor poll} to issue the @option{poll} command. All output is relayed through the
GDB session.
+The TCL interface is used as a simplified RPC mechanism that feeds all the
+input into the TCL interpreter and returns the output from the evaluation of
+the commands.
+
@section Daemon
@itemize @bullet
@item @b{shutdown}
@cindex shutdown
-Close the OpenOCD daemon, disconnecting all clients (GDB, Telnet).
+Close the OpenOCD daemon, disconnecting all clients (GDB, Telnet, Other).
@item @b{debug_level} [@var{n}]
@cindex debug_level
Typically the "fast enable" is specified first on the command line:
+@smallexample
openocd -c "fast enable" -c "interface dummy" -f target/str710.cfg
+@end smallexample
@item @b{log_output} <@var{file}>
@cindex log_output
@item @b{poll} [@option{on}|@option{off}]
@cindex poll
Poll the target for its current state. If the target is in debug mode, architecture
-specific information about the current state are printed. An optional parameter
+specific information about the current state is printed. An optional parameter
allows continuous polling to be enabled and disabled.
@item @b{halt} [@option{ms}]
@cindex halt
-Send a halt request to the target and waits for it to halt for [@option{ms}].
+Send a halt request to the target and wait for it to halt for up to [@option{ms}] milliseconds.
Default [@option{ms}] is 5 seconds if no arg given.
Optional arg @option{ms} is a timeout in milliseconds. Using 0 as the [@option{ms}]
-will stop openocd from waiting.
+will stop OpenOCD from waiting.
@item @b{wait_halt} [@option{ms}]
@cindex wait_halt
@item @b{resume} [@var{address}]
@cindex resume
Resume the target at its current code position, or at an optional address.
-Openocd will wait 5 seconds for the target to resume.
+OpenOCD will wait 5 seconds for the target to resume.
@item @b{step} [@var{address}]
@cindex step
Single-step the target at its current code position, or at an optional address.
-@item @b{reset} [@option{run}|@option{halt}|@option{init}|@option{run_and_halt}
-|@option{run_and_init}]
+@item @b{reset} [@option{run}|@option{halt}|@option{init}]
@cindex reset
-Do a hard-reset. The optional parameter specifies what should happen after the reset.
-This optional parameter overwrites the setting specified in the configuration file,
-making the new behaviour the default for the @option{reset} command.
+Perform a hard-reset. The optional parameter specifies what should happen after the reset.
+
+With no arguments a "reset run" is executed
@itemize @minus
@item @b{run}
@cindex reset run
@cindex reset init
Immediately halt the target, and execute the reset script (works only with certain
configurations)
-@item @b{run_and_halt}
-@cindex reset run_and_halt
-Let the target run for a certain amount of time, then request a halt.
-@item @b{run_and_init}
-@cindex reset run_and_init
-Let the target run for a certain amount of time, then request a halt. Execute the
-reset script once the target entered debug mode.
@end itemize
@end itemize
(binary) <@var{file}>.
@item @b{verify_image} <@var{file}> <@var{address}> [@option{bin}|@option{ihex}|@option{elf}]
@cindex verify_image
-Verify <@var{file}> to target memory starting at <@var{address}>.
-This will first attempt using a crc checksum, if this fails it will try a binary compare.
+Verify <@var{file}> against target memory starting at <@var{address}>.
+This will first attempt comparison using a crc checksum, if this fails it will try a binary compare.
@end itemize
@subsection Flash commands
@item @b{flash erase_sector} <@var{num}> <@var{first}> <@var{last}>
@cindex flash erase_sector
Erase sectors at bank <@var{num}>, starting at sector <@var{first}> up to and including
-<@var{last}>. Sector numbering starts at 0. Depending on the flash type, erasing might
+<@var{last}>. Sector numbering starts at 0. Depending on the flash type, erasing may
require the protection to be disabled first (e.g. Intel Advanced Bootblock flash using
the CFI driver).
@item @b{flash erase_address} <@var{address}> <@var{length}>
@cindex flash erase_address
-Erase sectors starting at <@var{address}> for <@var{length}> number of bytes
+Erase sectors starting at <@var{address}> for <@var{length}> bytes
@item @b{flash write_bank} <@var{num}> <@var{file}> <@var{offset}>
@cindex flash write_bank
Write the binary <@var{file}> to flash bank <@var{num}>, starting at
controller handles erases automatically on a page (128/265 byte) basis so erase is
not necessary for flash programming. AT91SAM7 processors with less than 512K flash
only have a single flash bank embedded on chip. AT91SAM7xx512 have two flash planes
-that can be erased separatly.Only an EraseAll command is supported by the controller
+that can be erased separatly. Only an EraseAll command is supported by the controller
for each flash plane and this is called with
@itemize @bullet
@item @b{flash erase} <@var{num}> @var{first_plane} @var{last_plane}
mass erase flash memory.
@end itemize
+@subsection Stellaris specific commands
+@cindex Stellaris specific commands
+
+These are flash specific commands when using the Stellaris driver.
+@itemize @bullet
+@item @b{stellaris mass_erase} <@var{num}>
+@cindex stellaris mass_erase
+mass erase flash memory.
+@end itemize
+
@page
@section Architecture Specific Commands
@cindex Architecture Specific Commands
safe for all but ARM7TDMI--S cores (like Philips LPC).
@item @b{arm7_9 fast_memory_access} <@var{enable}|@var{disable}>
@cindex arm7_9 fast_memory_access
-Allow the OpenOCD to read and write memory without checking completion of
+Allow OpenOCD to read and write memory without checking completion of
the operation. This provides a huge speed increase, especially with USB JTAG
cables (FT2232), but might be unsafe if used with targets running at a very low
speed, like the 32kHz startup clock of an AT91RM9200.
@section Debug commands
@cindex Debug commands
The following commands give direct access to the core, and are most likely
-only useful while debugging the OpenOCD.
+only useful while debugging OpenOCD.
@itemize @bullet
@item @b{arm7_9 write_xpsr} <@var{32-bit value}> <@option{0=cpsr}, @option{1=spsr}>
@cindex arm7_9 write_xpsr
@page
@section Target Requests
@cindex Target Requests
-Openocd can handle certain target requests, currently debugmsg are only supported for arm7_9 and cortex_m3.
+OpenOCD can handle certain target requests, currently debugmsg are only supported for arm7_9 and cortex_m3.
See libdcc in the contrib dir for more details.
@itemize @bullet
@item @b{target_request debugmsgs} <@var{enable}|@var{disable}>
@end smallexample
-@node GDB and Openocd
-@chapter GDB and Openocd
-@cindex GDB and Openocd
-Openocd complies with the remote gdbserver protocol, and as such can be used
+@node GDB and OpenOCD
+@chapter GDB and OpenOCD
+@cindex GDB and OpenOCD
+OpenOCD complies with the remote gdbserver protocol, and as such can be used
to debug remote targets.
@section Connecting to gdb
@end smallexample
This would cause gdb to connect to the gdbserver on the local pc using port 3333.
-To see a list of available openocd commands type @option{monitor help} on the
+To see a list of available OpenOCD commands type @option{monitor help} on the
gdb commandline.
-Openocd supports the gdb @option{qSupported} packet, this enables information
+OpenOCD supports the gdb @option{qSupported} packet, this enables information
to be sent by the gdb server (openocd) to gdb. Typical information includes
packet size and device memory map.
-Previous versions of openocd required the following gdb options to increase
+Previous versions of OpenOCD required the following gdb options to increase
the packet size and speed up gdb communication.
@smallexample
set remote memory-write-packet-size 1024
@cindex Programming using gdb
By default the target memory map is sent to gdb, this can be disabled by
-the following openocd config option:
+the following OpenOCD config option:
@smallexample
gdb_memory_map disable
@end smallexample
For this to function correctly a valid flash config must also be configured
-in openocd. For speed also configure a valid working area.
+in OpenOCD. For faster performance you should also configure a valid
+working area.
Informing gdb of the memory map of the target will enable gdb to protect any
flash area of the target and use hardware breakpoints by default. This means
-that the openocd option @option{arm7_9 force_hw_bkpts} is not required when
+that the OpenOCD option @option{arm7_9 force_hw_bkpts} is not required when
using a memory map.
To view the configured memory map in gdb, use the gdb command @option{info mem}
areas to be programmed lie within the target flash area the vFlash packets
will be used.
-Incase the target needs configuring before gdb programming, a script can be executed.
+If the target needs configuring before gdb programming, a script can be executed.
@smallexample
target_script 0 gdb_program_config config.script
@end smallexample
To verify any flash programming the gdb command @option{compare-sections}
can be used.
+@node TCL and OpenOCD
+@chapter TCL and OpenOCD
+@cindex TCL and OpenOCD
+OpenOCD embeds a TCL interpreter (see JIM) for command parsing and scripting
+support.
+
+The TCL interpreter can be invoked from the interactive command line, files, and a network port.
+
+The command and file interfaces are fairly straightforward, while the network
+port is geared toward intergration with external clients. A small example
+of an external TCL script that can connect to openocd is shown below.
+
+@verbatim
+# Simple tcl client to connect to openocd
+puts "Use empty line to exit"
+set fo [socket 127.0.0.1 6666]
+puts -nonewline stdout "> "
+flush stdout
+while {[gets stdin line] >= 0} {
+ if {$line eq {}} break
+ puts $fo $line
+ flush $fo
+ gets $fo line
+ puts $line
+ puts -nonewline stdout "> "
+ flush stdout
+}
+close $fo
+@end verbatim
+
+This script can easily be modified to front various GUIs or be a sub
+component of a larger framework for control and interaction.
+
+
+@node TCL scripting API
+@chapter TCL scripting API
+@cindex TCL scripting API
+API rules
+
+The commands are stateless. E.g. the telnet command line has a concept
+of currently active target, the Tcl API proc's take this sort of state
+information as an argument to each proc.
+
+There are three main types of return values: single value, name value
+pair list and lists.
+
+Name value pair. The proc 'foo' below returns a name/value pair
+list.
+
+@verbatim
+
+ > set foo(me) Duane
+ > set foo(you) Oyvind
+ > set foo(mouse) Micky
+ > set foo(duck) Donald
+
+If one does this:
+
+ > set foo
+
+The result is:
+
+ me Duane you Oyvind mouse Micky duck Donald
+
+Thus, to get the names of the associative array is easy:
+
+ foreach { name value } [set foo] {
+ puts "Name: $name, Value: $value"
+ }
+@end verbatim
+
+Lists returned must be relatively small. Otherwise a range
+should be passed in to the proc in question.
+
+Low level commands are prefixed with "openocd_", e.g. openocd_flash_banks
+is the low level API upon which "flash banks" is implemented.
+
+OpenOCD commands can consist of two words, e.g. "flash banks". The
+startup.tcl "unknown" proc will translate this into a tcl proc
+called "flash_banks".
+
+
@node Upgrading
@chapter Deprecated/Removed Commands
@cindex Deprecated/Removed Commands
-Certain openocd commands have been deprecated/removed during the various revisions.
+Certain OpenOCD commands have been deprecated/removed during the various revisions.
@itemize @bullet
@item @b{load_binary}
@item @b{flash auto_erase}
@cindex flash auto_erase
use @option{flash write_image} command passing @option{erase} as the first parameter.
+@item @b{daemon_startup}
+@cindex daemon_startup
+this config option has been removed, simply adding @option{init} and @option{reset halt} to
+the end of your config script will give the same behaviour as using @option{daemon_startup reset}
+and @option{target cortex_m3 little reset_halt 0}.
@end itemize
@node FAQ
Make sure you have Cygwin installed, or at least a version of OpenOCD that
claims to come with all the necessary dlls. When using Cygwin, try launching
-the OpenOCD from the Cygwin shell.
+OpenOCD from the Cygwin shell.
@item I'm trying to set a breakpoint using GDB (or a frontend like Insight or
Eclipse), but OpenOCD complains that "Info: arm7_9_common.c:213
Make sure your PC's parallel port operates in EPP mode. You might have to try several
settings in your PC BIOS (ECP, EPP, and different versions of those).
-@item When debugging with the OpenOCD and GDB (plain GDB, Insight, or Eclipse),
+@item When debugging with OpenOCD and GDB (plain GDB, Insight, or Eclipse),
I get lots of "Error: arm7_9_common.c:1771 arm7_9_read_memory():
memory read caused data abort".
This warning doesn't indicate any serious problem, as long as you don't want to
debug your core right out of reset. Your .cfg file specified @option{jtag_reset
-trst_and_srst srst_pulls_trst} to tell the OpenOCD that either your board,
+trst_and_srst srst_pulls_trst} to tell OpenOCD that either your board,
your debugger or your target uC (e.g. LPC2000) can't assert the two reset signals
independently. With this setup, it's not possible to halt the core right out of
reset, everything else should work fine.