- updated docs with new commands/features
[openocd.git] / doc / openocd.texi
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename openocd.info
4 @settitle Open On-Chip Debugger (openocd)
5 @dircategory Development
6 @direntry
7 * OpenOCD: (openocd). Open On-Chip Debugger.
8 @end direntry
9 @c %**end of header
10
11 @include version.texi
12
13 @copying
14 Copyright @copyright{} 2007-2008 Spen @email{spen@@spen-soft.co.uk}
15 @quotation
16 Permission is granted to copy, distribute and/or modify this document
17 under the terms of the GNU Free Documentation License, Version 1.2 or
18 any later version published by the Free Software Foundation; with no
19 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
20 Texts. A copy of the license is included in the section entitled ``GNU
21 Free Documentation License''.
22 @end quotation
23 @end copying
24
25 @titlepage
26 @title Open On-Chip Debugger (openocd)
27 @subtitle Edition @value{EDITION} for openocd version @value{VERSION}
28 @subtitle @value{UPDATED}
29 @page
30 @vskip 0pt plus 1filll
31 @insertcopying
32 @end titlepage
33
34 @contents
35
36 @node Top, About, , (dir)
37 @top OpenOCD
38
39 This manual documents edition @value{EDITION} of the Open On-Chip Debugger
40 (openocd) version @value{VERSION}, @value{UPDATED}.
41
42 @insertcopying
43
44 @menu
45 * About:: About Openocd.
46 * Developers:: Openocd developers
47 * Building:: Building Openocd
48 * Running:: Running Openocd
49 * Configuration:: Openocd Configuration.
50 * Commands:: Openocd Commands
51 * Sample Scripts:: Sample Target Scripts
52 * GDB and Openocd:: Using GDB and Openocd
53 * Upgrading:: Deprecated/Removed Commands
54 * FAQ:: Frequently Asked Questions
55 * License:: GNU Free Documentation License
56 * Index:: Main index.
57 @end menu
58
59 @node About
60 @unnumbered About
61 @cindex about
62
63 The Open On-Chip Debugger (openocd) aims to provide debugging, in-system programming
64 and boundary-scan testing for embedded target devices. The targets are interfaced
65 using JTAG (IEEE 1149.1) compliant hardware, but this may be extended to other
66 connection types in the future.
67
68 Openocd currently supports Wiggler (clones), FTDI FT2232 based JTAG interfaces, the
69 Amontec JTAG Accelerator, and the Gateworks GW1602. It allows ARM7 (ARM7TDMI and ARM720t),
70 ARM9 (ARM920t, ARM922t, ARM926ej--s, ARM966e--s), XScale (PXA25x, IXP42x) and
71 Cortex-M3 (Luminary Stellaris LM3 and ST STM32) based cores to be debugged.
72
73 Flash writing is supported for external CFI compatible flashes (Intel and AMD/Spansion
74 command set) and several internal flashes (LPC2000, AT91SAM7, STR7x, STR9x, LM3
75 and STM32x). Preliminary support for using the LPC3180's NAND flash controller is included.
76
77 @node Developers
78 @chapter Developers
79 @cindex developers
80
81 Openocd has been created by Dominic Rath as part of a diploma thesis written at the
82 University of Applied Sciences Augsburg (@uref{http://www.fh-augsburg.de}).
83 Others interested in improving the state of free and open debug and testing technology
84 are welcome to participate.
85
86 Other developers have contributed support for additional targets and flashes as well
87 as numerous bugfixes and enhancements. See the AUTHORS file for regular contributors.
88
89 @node Building
90 @chapter Building
91 @cindex building openocd
92
93 You can download the current SVN version with SVN client of your choice from the
94 following repositories:
95
96 (@uref{svn://svn.berlios.de/openocd/trunk})
97
98 or
99
100 (@uref{http://svn.berlios.de/svnroot/repos/openocd/trunk})
101
102 Using the SVN command line client, you could use the following command to fetch the
103 latest version (make sure there is no (non-svn) directory called "openocd" in the
104 current directory):
105
106 @smallexample
107 svn checkout svn://svn.berlios.de/openocd/trunk openocd
108 @end smallexample
109
110 Building the OpenOCD requires a recent version of the GNU autotools.
111 On my build system, I'm using autoconf 2.13 and automake 1.9. For building on Windows,
112 you have to use Cygwin. Make sure that your @env{PATH} environment variable contains no
113 other locations with Unix utils (like UnxUtils) - these can't handle the Cygwin
114 paths, resulting in obscure dependency errors (This is an observation I've gathered
115 from the logs of one user - correct me if I'm wrong).
116
117 You further need the appropriate driver files, if you want to build support for
118 a FTDI FT2232 based interface:
119 @itemize @bullet
120 @item @b{ftdi2232} libftdi (@uref{http://www.intra2net.com/opensource/ftdi/})
121 @item @b{ftd2xx} libftd2xx (@uref{http://www.ftdichip.com/Drivers/D2XX.htm})
122 @item When using the Amontec JTAGkey, you have to get the drivers from the Amontec
123 homepage (@uref{www.amontec.com}), as the JTAGkey uses a non-standard VID/PID.
124 @end itemize
125
126 Please note that the ftdi2232 variant (using libftdi) isn't supported under Cygwin.
127 You have to use the ftd2xx variant (using FTDI's D2XX) on Cygwin.
128
129 In general, the D2XX driver provides superior performance (several times as fast),
130 but has the draw-back of being binary-only - though that isn't as worse, as it isn't
131 a kernel module, only a user space library.
132
133 To build OpenOCD (on both Linux and Cygwin), use the following commands:
134 @smallexample
135 ./bootstrap
136 @end smallexample
137 Bootstrap generates the configure script, and prepares building on your system.
138 @smallexample
139 ./configure
140 @end smallexample
141 Configure generates the Makefiles used to build OpenOCD.
142 @smallexample
143 make
144 @end smallexample
145 Make builds the OpenOCD, and places the final executable in ./src/.
146
147 The configure script takes several options, specifying which JTAG interfaces
148 should be included:
149
150 @itemize @bullet
151 @item
152 @option{--enable-parport}
153 @item
154 @option{--enable-parport_ppdev}
155 @item
156 @option{--enable-amtjtagaccel}
157 @item
158 @option{--enable-ft2232_ftd2xx}
159 @footnote{Using the latest D2XX drivers from FTDI and following their installation
160 instructions, I had to use @option{--enable-ft2232_libftd2xx} for the OpenOCD to
161 build properly.}
162 @item
163 @option{--enable-ft2232_libftdi}
164 @item
165 @option{--with-ftd2xx=/path/to/d2xx/}
166 @item
167 @option{--enable-gw16012}
168 @item
169 @option{--enable-usbprog}
170 @item
171 @option{--enable-presto_libftdi}
172 @item
173 @option{--enable-presto_ftd2xx}
174 @end itemize
175
176 If you want to access the parallel port using the PPDEV interface you have to specify
177 both the @option{--enable-parport} AND the @option{--enable-parport_ppdev} option since
178 the @option{--enable-parport_ppdev} option actually is an option to the parport driver
179 (see @uref{http://forum.sparkfun.com/viewtopic.php?t=3795} for more info).
180
181 Cygwin users have to specify the location of the FTDI D2XX package. This should be an
182 absolute path containing no spaces.
183
184 Linux users should copy the various parts of the D2XX package to the appropriate
185 locations, i.e. /usr/include, /usr/lib.
186
187 @node Running
188 @chapter Running
189 @cindex running openocd
190 @cindex --configfile
191 @cindex --debug_level
192 @cindex --logfile
193 @cindex --search
194 The OpenOCD runs as a daemon, waiting for connections from clients (Telnet or GDB).
195 Run with @option{--help} or @option{-h} to view the available command line arguments.
196
197 It reads its configuration by default from the file openocd.cfg located in the current
198 working directory. This may be overwritten with the @option{-f <configfile>} command line
199 switch.
200
201 To enable debug output (when reporting problems or working on OpenOCD itself), use
202 the @option{-d} command line switch. This sets the debug_level to "3", outputting
203 the most information, including debug messages. The default setting is "2", outputting
204 only informational messages, warnings and errors. You can also change this setting
205 from within a telnet or gdb session (@option{debug_level <n>}).
206
207 You can redirect all output from the daemon to a file using the @option{-l <logfile>} switch.
208
209 Search paths for config/script files can be added to openocd by using
210 the @option{-s <search>} switch.
211
212 @node Configuration
213 @chapter Configuration
214 @cindex configuration
215 The Open On-Chip Debugger (OpenOCD) runs as a daemon, and reads it current configuration
216 by default from the file openocd.cfg in the current directory. A different configuration
217 file can be specified with the @option{-f <conf.file>} given at the openocd command line.
218
219 The configuration file is used to specify on which ports the daemon listens for new
220 connections, the JTAG interface used to connect to the target, the layout of the JTAG
221 chain, the targets that should be debugged, and connected flashes.
222
223 @section Daemon configuration
224
225 @itemize @bullet
226 @item @b{telnet_port} <@var{number}>
227 @cindex telnet_port
228 Port on which to listen for incoming telnet connections
229 @item @b{gdb_port} <@var{number}>
230 @cindex gdb_port
231 First port on which to listen for incoming GDB connections. The GDB port for the
232 first target will be gdb_port, the second target will listen on gdb_port + 1, and so on.
233 @item @b{gdb_detach} <@var{resume|reset|halt|nothing}>
234 @cindex gdb_detach
235 Configures what openocd will do when gdb detaches from the daeman.
236 Default behaviour is <@var{resume}>
237 @item @b{gdb_memory_map} <@var{enable|disable}>
238 @cindex gdb_memory_map
239 Set to <@var{enable}> so that openocd will send the memory configuration to gdb when
240 requested. gdb will then know when to set hardware breakpoints, and program flash
241 using the gdb load command. @option{gdb_flash_program enable} will also need enabling
242 for flash programming to work.
243 Default behaviour is <@var{disable}>
244 @item @b{gdb_flash_program} <@var{enable|disable}>
245 @cindex gdb_flash_program
246 Set to <@var{enable}> so that openocd will program the flash memory when a
247 vFlash packet is received.
248 Default behaviour is <@var{disable}>
249 @item @b{daemon_startup} <@var{mode}>
250 @cindex daemon_startup
251 @option{mode} can either @option{attach} or @option{reset}
252 Tells the OpenOCD whether it should reset the target when the daemon is launched, or
253 if it should just attach to the target.
254 @end itemize
255
256 @section JTAG interface configuration
257
258 @itemize @bullet
259 @item @b{interface} <@var{name}>
260 @cindex interface
261 Use the interface driver <@var{name}> to connect to the target. Currently supported
262 interfaces are
263 @itemize @minus
264 @item @b{parport}
265 PC parallel port bit-banging (Wigglers, PLD download cable, ...)
266 @end itemize
267 @itemize @minus
268 @item @b{amt_jtagaccel}
269 Amontec Chameleon in its JTAG Accelerator configuration connected to a PC's EPP
270 mode parallel port
271 @end itemize
272 @itemize @minus
273 @item @b{ft2232}
274 FTDI FT2232 based devices using either the open-source libftdi or the binary only
275 FTD2XX driver. The FTD2XX is superior in performance, but not available on every
276 platform. The libftdi uses libusb, and should be portable to all systems that provide
277 libusb.
278 @end itemize
279 @itemize @minus
280 @item @b{ep93xx}
281 Cirrus Logic EP93xx based single-board computer bit-banging (in development)
282 @end itemize
283 @itemize @minus
284 @item @b{presto}
285 ASIX PRESTO USB JTAG programmer.
286 @end itemize
287 @itemize @minus
288 @item @b{usbprog}
289 usbprog is a freely programmable USB adapter.
290 @end itemize
291 @itemize @minus
292 @item @b{gw16012}
293 Gateworks GW16012 JTAG programmer.
294 @end itemize
295 @end itemize
296
297 @itemize @bullet
298 @item @b{jtag_speed} <@var{reset speed}> <@var{post reset speed}>
299 @cindex jtag_speed
300 Limit the maximum speed of the JTAG interface. Usually, a value of zero means maximum
301 speed. The actual effect of this option depends on the JTAG interface used. Reset
302 speed is used during reset and post reset speed after reset. post reset speed
303 is optional, in which case the reset speed is used.
304 @itemize @minus
305
306 @item wiggler: maximum speed / @var{number}
307 @item ft2232: 6MHz / (@var{number}+1)
308 @item amt jtagaccel: 8 / 2**@var{number}
309 @end itemize
310
311 Note: Make sure the jtag clock is no more than @math{1/6th × CPU-Clock}. This is
312 especially true for synthesized cores (-S).
313
314 @item @b{jtag_khz} <@var{reset speed kHz}> <@var{post reset speed kHz}>
315 @cindex jtag_khz
316 Same as jtag_speed, except that the speed is specified in maximum kHz. If
317 the device can not support the rate asked for, or can not translate from
318 kHz to jtag_speed, then an error is returned. 0 means RTCK. If RTCK
319 is not supported, then an error is reported.
320
321 @item @b{reset_config} <@var{signals}> [@var{combination}] [@var{trst_type}] [@var{srst_type}]
322 @cindex reset_config
323 The configuration of the reset signals available on the JTAG interface AND the target.
324 If the JTAG interface provides SRST, but the target doesn't connect that signal properly,
325 then OpenOCD can't use it. <@var{signals}> can be @option{none}, @option{trst_only},
326 @option{srst_only} or @option{trst_and_srst}.
327
328 [@var{combination}] is an optional value specifying broken reset signal implementations.
329 @option{srst_pulls_trst} states that the testlogic is reset together with the reset of
330 the system (e.g. Philips LPC2000, "broken" board layout), @option{trst_pulls_srst} says
331 that the system is reset together with the test logic (only hypothetical, I haven't
332 seen hardware with such a bug, and can be worked around).
333 @option{combined} imples both @option{srst_pulls_trst} and @option{trst_pulls_srst}.
334 The default behaviour if no option given is @option{separate}.
335
336 The [@var{trst_type}] and [@var{srst_type}] parameters allow the driver type of the
337 reset lines to be specified. Possible values are @option{trst_push_pull} (default)
338 and @option{trst_open_drain} for the test reset signal, and @option{srst_open_drain}
339 (default) and @option{srst_push_pull} for the system reset. These values only affect
340 JTAG interfaces with support for different drivers, like the Amontec JTAGkey and JTAGAccelerator.
341
342 @item @b{jtag_device} <@var{IR length}> <@var{IR capture}> <@var{IR mask}> <@var{IDCODE instruction}>
343 @cindex jtag_device
344 Describes the devices that form the JTAG daisy chain, with the first device being
345 the one closest to TDO. The parameters are the length of the instruction register
346 (4 for all ARM7/9s), the value captured during Capture-IR (0x1 for ARM7/9), and a mask
347 of bits that should be validated when doing IR scans (all four bits (0xf) for ARM7/9).
348 The IDCODE instruction will in future be used to query devices for their JTAG
349 identification code. This line is the same for all ARM7 and ARM9 devices.
350 Other devices, like CPLDs, require different parameters. An example configuration
351 line for a Xilinx XC9500 CPLD would look like this:
352 @smallexample
353 jtag_device 8 0x01 0x0e3 0xfe
354 @end smallexample
355 The instruction register (IR) is 8 bits long, during Capture-IR 0x01 is loaded into
356 the IR, but only bits 0-1 and 5-7 should be checked, the others (2-4) might vary.
357 The IDCODE instruction is 0xfe.
358
359 @item @b{jtag_nsrst_delay} <@var{ms}>
360 @cindex jtag_nsrst_delay
361 How long (in miliseconds) the OpenOCD should wait after deasserting nSRST before
362 starting new JTAG operations.
363 @item @b{jtag_ntrst_delay} <@var{ms}>
364 @cindex jtag_ntrst_delay
365 How long (in miliseconds) the OpenOCD should wait after deasserting nTRST before
366 starting new JTAG operations.
367
368 The jtag_n[st]rst_delay options are useful if reset circuitry (like a reset supervisor,
369 or on-chip features) keep a reset line asserted for some time after the external reset
370 got deasserted.
371 @end itemize
372
373 @section parport options
374
375 @itemize @bullet
376 @item @b{parport_port} <@var{number}>
377 @cindex parport_port
378 Either the address of the I/O port (default: 0x378 for LPT1) or the number of
379 the @file{/dev/parport} device
380
381 When using PPDEV to access the parallel port, use the number of the parallel port:
382 @option{parport_port 0} (the default). If @option{parport_port 0x378} is specified
383 you may encounter a problem.
384 @item @b{parport_cable} <@var{name}>
385 @cindex parport_cable
386 The layout of the parallel port cable used to connect to the target.
387 Currently supported cables are
388 @itemize @minus
389 @item @b{wiggler}
390 @cindex wiggler
391 Original Wiggler layout, also supported by several clones, such
392 as the Olimex ARM-JTAG
393 @item @b{old_amt_wiggler}
394 @cindex old_amt_wiggler
395 The Wiggler configuration that comes with Amontec's Chameleon Programmer. The new
396 version available from the website uses the original Wiggler layout ('@var{wiggler}')
397 @item @b{chameleon}
398 @cindex chameleon
399 Describes the connection of the Amontec Chameleon's CPLD when operated in
400 configuration mode. This is only used to program the Chameleon itself, not
401 a connected target.
402 @item @b{dlc5}
403 @cindex dlc5
404 Xilinx Parallel cable III.
405 @item @b{triton}
406 @cindex triton
407 The parallel port adapter found on the 'Karo Triton 1 Development Board'.
408 This is also the layout used by the HollyGates design
409 (see @uref{http://www.lartmaker.nl/projects/jtag/}).
410 @item @b{flashlink}
411 @cindex flashlink
412 ST Parallel cable.
413 @end itemize
414 @item @b{parport_write_on_exit} <@var{on|off}>
415 @cindex parport_write_on_exit
416 This will configure the parallel driver to write a known value to the parallel
417 interface on exiting openocd
418 @end itemize
419
420 @section amt_jtagaccel options
421 @itemize @bullet
422 @item @b{parport_port} <@var{number}>
423 @cindex parport_port
424 Either the address of the I/O port (default: 0x378 for LPT1) or the number of the
425 @file{/dev/parport} device
426 @end itemize
427 @section ft2232 options
428
429 @itemize @bullet
430 @item @b{ft2232_device_desc} <@var{description}>
431 @cindex ft2232_device_desc
432 The USB device description of the FTDI FT2232 device. If not specified, the FTDI
433 default value is used. This setting is only valid if compiled with FTD2XX support.
434 @item @b{ft2232_layout} <@var{name}>
435 @cindex ft2232_layout
436 The layout of the FT2232 GPIO signals used to control output-enables and reset
437 signals. Valid layouts are
438 @itemize @minus
439 @item @b{usbjtag}
440 The "USBJTAG-1" layout described in the original OpenOCD diploma thesis
441 @item @b{jtagkey}
442 Amontec JTAGkey and JTAGkey-tiny
443 @item @b{signalyzer}
444 Signalyzer
445 @item @b{olimex-jtag}
446 Olimex ARM-USB-OCD
447 @item @b{m5960}
448 American Microsystems M5960
449 @item @b{evb_lm3s811}
450 Luminary Micro EVB_LM3S811 as a JTAG interface (not onboard processor), no TRST or
451 SRST signals on external connector
452 @item @b{comstick}
453 Hitex STR9 comstick
454 @item @b{stm32stick}
455 Hitex STM32 Performance Stick
456 @item @b{flyswatter}
457 Tin Can Tools Flyswatter
458 @item @b{turtelizer2}
459 egnite Software turtelizer2
460 @item @b{oocdlink}
461 OOCDLink
462 @end itemize
463
464 @item @b{ft2232_vid_pid} <@var{vid}> <@var{pid}>
465 The vendor ID and product ID of the FTDI FT2232 device. If not specified, the FTDI
466 default values are used. This command is not available on Windows.
467 @item @b{ft2232_latency} <@var{ms}>
468 On some systems using ft2232 based JTAG interfaces the FT_Read function call in
469 ft2232_read() fails to return the expected number of bytes. This can be caused by
470 USB communication delays and has proved hard to reproduce and debug. Setting the
471 FT2232 latency timer to a larger value increases delays for short USB packages but it
472 also reduces the risk of timeouts before receiving the expected number of bytes.
473 The OpenOCD default value is 2 and for some systems a value of 10 has proved useful.
474 @end itemize
475
476 @section ep93xx options
477 @cindex ep93xx options
478 Currently, there are no options available for the ep93xx interface.
479
480 @page
481 @section Target configuration
482
483 @itemize @bullet
484 @item @b{target} <@var{type}> <@var{endianess}> <@var{reset_mode}> <@var{JTAG pos}>
485 <@var{variant}>
486 @cindex target
487 Defines a target that should be debugged. Currently supported types are:
488 @itemize @minus
489 @item @b{arm7tdmi}
490 @item @b{arm720t}
491 @item @b{arm9tdmi}
492 @item @b{arm920t}
493 @item @b{arm922t}
494 @item @b{arm926ejs}
495 @item @b{arm966e}
496 @item @b{cortex_m3}
497 @item @b{feroceon}
498 @item @b{xscale}
499 @end itemize
500
501 If you want to use a target board that is not on this list, see Adding a new
502 target board
503
504 Endianess may be @option{little} or @option{big}.
505
506 The reset_mode specifies what should happen to the target when a reset occurs:
507 @itemize @minus
508 @item @b{reset_halt}
509 @cindex reset_halt
510 Immediately request a target halt after reset. This allows targets to be debugged
511 from the very first instruction. This is only possible with targets and JTAG
512 interfaces that correctly implement the reset signals.
513 @item @b{reset_init}
514 @cindex reset_init
515 Similar to @option{reset_halt}, but executes the script file defined to handle the
516 'reset' event for the target. Like @option{reset_halt} this only works with
517 correct reset implementations.
518 @item @b{reset_run}
519 @cindex reset_run
520 Simply let the target run after a reset.
521 @item @b{run_and_halt}
522 @cindex run_and_halt
523 Let the target run for some time (default: 1s), and then request halt.
524 @item @b{run_and_init}
525 @cindex run_and_init
526 A combination of @option{reset_init} and @option{run_and_halt}. The target is allowed
527 to run for some time, then halted, and the @option{reset} event script is executed.
528 @end itemize
529
530 On JTAG interfaces / targets where system reset and test-logic reset can't be driven
531 completely independent (like the LPC2000 series), or where the JTAG interface is
532 unavailable for some time during startup (like the STR7 series), you can't use
533 @option{reset_halt} or @option{reset_init}.
534
535 @item @b{target_script} <@var{target#}> <@var{event}> <@var{script_file}>
536 @cindex target_script
537 Event is either @option{reset}, @option{post_halt}, @option{pre_resume} or @option{gdb_program_config}
538
539 TODO: describe exact semantic of events
540 @item @b{run_and_halt_time} <@var{target#}> <@var{time_in_ms}>
541 @cindex run_and_halt_time
542 The amount of time the debugger should wait after releasing reset before it asserts
543 a debug request. This is used by the @option{run_and_halt} and @option{run_and_init}
544 reset modes.
545 @item @b{working_area} <@var{target#}> <@var{address}> <@var{size}>
546 <@var{backup}|@var{nobackup}>
547 @cindex working_area
548 Specifies a working area for the debugger to use. This may be used to speed-up
549 downloads to target memory and flash operations, or to perform otherwise unavailable
550 operations (some coprocessor operations on ARM7/9 systems, for example). The last
551 parameter decides whether the memory should be preserved <@var{backup}>. If possible, use
552 a working_area that doesn't need to be backed up, as that slows down operation.
553 @end itemize
554
555 @subsection arm7tdmi options
556 @cindex arm7tdmi options
557 target arm7tdmi <@var{endianess}> <@var{reset_mode}> <@var{jtag#}>
558 The arm7tdmi target definition requires at least one additional argument, specifying
559 the position of the target in the JTAG daisy-chain. The first JTAG device is number 0.
560 The optional [@var{variant}] parameter has been removed in recent versions.
561 The correct feature set is determined at runtime.
562
563 @subsection arm720t options
564 @cindex arm720t options
565 ARM720t options are similar to ARM7TDMI options.
566
567 @subsection arm9tdmi options
568 @cindex arm9tdmi options
569 ARM9TDMI options are similar to ARM7TDMI options. Supported variants are
570 @option{arm920t}, @option{arm922t} and @option{arm940t}.
571 This enables the hardware single-stepping support found on these cores.
572
573 @subsection arm920t options
574 @cindex arm920t options
575 ARM920t options are similar to ARM9TDMI options.
576
577 @subsection arm966e options
578 @cindex arm966e options
579 ARM966e options are similar to ARM9TDMI options.
580
581 @subsection xscale options
582 @cindex xscale options
583 Supported variants are @option{ixp42x}, @option{ixp45x}, @option{ixp46x},
584 @option{pxa250}, @option{pxa255}, @option{pxa26x}.
585
586 @section Flash configuration
587 @cindex Flash configuration
588
589 @itemize @bullet
590 @item @b{flash bank} <@var{driver}> <@var{base}> <@var{size}> <@var{chip_width}>
591 <@var{bus_width}> <@var{target#}> [@var{driver_options ...}]
592 @cindex flash bank
593 Configures a flash bank at <@var{base}> of <@var{size}> bytes and <@var{chip_width}>
594 and <@var{bus_width}> bytes using the selected flash <driver>.
595
596 @item @b{flash auto_erase} <@option{on}|@option{off}>
597 @cindex flash auto_erase
598 auto erase flash banks prior to writing. Currently only works when using
599 @option{flash write_image} command. Default is @option{off}.
600 @end itemize
601
602 @subsection lpc2000 options
603 @cindex lpc2000 options
604
605 @b{flash bank lpc2000} <@var{base}> <@var{size}> 0 0 <@var{target#}> <@var{variant}>
606 <@var{clock}> [@var{calc_checksum}]
607 LPC flashes don't require the chip and bus width to be specified. Additional
608 parameters are the <@var{variant}>, which may be @var{lpc2000_v1} (older LPC21xx and LPC22xx)
609 or @var{lpc2000_v2} (LPC213x, LPC214x, LPC210[123], LPC23xx and LPC24xx), the number
610 of the target this flash belongs to (first is 0), the frequency at which the core
611 is currently running (in kHz - must be an integral number), and the optional keyword
612 @var{calc_checksum}, telling the driver to calculate a valid checksum for the exception
613 vector table.
614
615 @subsection cfi options
616 @cindex cfi options
617
618 @b{flash bank cfi} <@var{base}> <@var{size}> <@var{chip_width}> <@var{bus_width}>
619 <@var{target#}>
620 CFI flashes require the number of the target they're connected to as an additional
621 argument. The CFI driver makes use of a working area (specified for the target)
622 to significantly speed up operation.
623
624 @var{chip_width} and @var{bus_width} are specified in bytes.
625
626 @subsection at91sam7 options
627 @cindex at91sam7 options
628
629 @b{flash bank at91sam7} 0 0 0 0 <@var{target#}>
630 AT91SAM7 flashes only require the @var{target#}, all other values are looked up after
631 reading the chip-id and type.
632
633 @subsection str7 options
634 @cindex str7 options
635
636 @b{flash bank str7x} <@var{base}> <@var{size}> 0 0 <@var{target#}> <@var{variant}>
637 variant can be either STR71x, STR73x or STR75x.
638
639 @subsection str9 options
640 @cindex str9 options
641
642 @b{flash bank str9x} <@var{base}> <@var{size}> 0 0 <@var{target#}>
643 The str9 needs the flash controller to be configured prior to Flash programming, eg.
644 @smallexample
645 str9x flash_config 0 4 2 0 0x80000
646 @end smallexample
647 This will setup the BBSR, NBBSR, BBADR and NBBADR registers respectively.
648
649 @subsection str9 options (str9xpec driver)
650
651 @b{flash bank str9xpec} <@var{base}> <@var{size}> 0 0 <@var{target#}>
652 Before using the flash commands the turbo mode will need enabling using str9xpec
653 @option{enable_turbo} <@var{num>.}
654
655 Only use this driver for locking/unlocking the device or configuring the option bytes.
656 Use the standard str9 driver for programming.
657
658 @subsection stellaris (LM3Sxxx) options
659 @cindex stellaris (LM3Sxxx) options
660
661 @b{flash bank stellaris} <@var{base}> <@var{size}> 0 0 <@var{target#}>
662 stellaris flash plugin only require the @var{target#}.
663
664 @subsection stm32x options
665 @cindex stm32x options
666
667 @b{flash bank stm32x} <@var{base}> <@var{size}> 0 0 <@var{target#}>
668 stm32x flash plugin only require the @var{target#}.
669
670 @node Commands
671 @chapter Commands
672 @cindex commands
673
674 The Open On-Chip Debugger (OpenOCD) allows user interaction through a telnet interface
675 (default: port 4444) and a GDB server (default: port 3333). The command line interpreter
676 is available from both the telnet interface and a GDB session. To issue commands to the
677 interpreter from within a GDB session, use the @option{monitor} command, e.g. use
678 @option{monitor poll} to issue the @option{poll} command. All output is relayed through the
679 GDB session.
680
681 @section Daemon
682
683 @itemize @bullet
684 @item @b{sleep} <@var{msec}>
685 @cindex sleep
686 Wait for n milliseconds before resuming. Useful in connection with script files
687 (@var{script} command and @var{target_script} configuration).
688
689 @item @b{shutdown}
690 @cindex shutdown
691 Close the OpenOCD daemon, disconnecting all clients (GDB, Telnet).
692
693 @item @b{debug_level} [@var{n}]
694 @cindex debug_level
695 Display or adjust debug level to n<0-3>
696
697 @item @b{log_output} <@var{file}>
698 @cindex log_output
699 Redirect logging to <file> (default: stderr)
700
701 @item @b{script} <@var{file}>
702 @cindex script
703 Execute commands from <file>
704
705 @end itemize
706
707 @subsection Target state handling
708 @itemize @bullet
709 @item @b{poll} [@option{on}|@option{off}]
710 @cindex poll
711 Poll the target for its current state. If the target is in debug mode, architecture
712 specific information about the current state are printed. An optional parameter
713 allows continuous polling to be enabled and disabled.
714
715 @item @b{halt} [@option{ms}]
716 @cindex halt
717 Send a halt request to the target and waits for it to halt for [@option{ms}].
718 Default [@option{ms}] is 5 seconds if no arg given.
719 Optional arg @option{ms} is a timeout in milliseconds. Using 0 as the [@option{ms}]
720 will stop openocd from waiting.
721
722 @item @b{wait_halt} [@option{ms}]
723 @cindex wait_halt
724 Wait for the target to enter debug mode. Optional [@option{ms}] is
725 a timeout in milliseconds. Default [@option{ms}] is 5 seconds if no
726 arg given.
727
728 @item @b{resume} [@var{address}]
729 @cindex resume
730 Resume the target at its current code position, or at an optional address.
731 Openocd will wait 5 seconds for the target to resume.
732
733 @item @b{step} [@var{address}]
734 @cindex step
735 Single-step the target at its current code position, or at an optional address.
736
737 @item @b{reset} [@option{run}|@option{halt}|@option{init}|@option{run_and_halt}
738 |@option{run_and_init}]
739 @cindex reset
740 Do a hard-reset. The optional parameter specifies what should happen after the reset.
741 This optional parameter overwrites the setting specified in the configuration file,
742 making the new behaviour the default for the @option{reset} command.
743 @itemize @minus
744 @item @b{run}
745 @cindex reset run
746 Let the target run.
747 @item @b{halt}
748 @cindex reset halt
749 Immediately halt the target (works only with certain configurations).
750 @item @b{init}
751 @cindex reset init
752 Immediately halt the target, and execute the reset script (works only with certain
753 configurations)
754 @item @b{run_and_halt}
755 @cindex reset run_and_halt
756 Let the target run for a certain amount of time, then request a halt.
757 @item @b{run_and_init}
758 @cindex reset run_and_init
759 Let the target run for a certain amount of time, then request a halt. Execute the
760 reset script once the target entered debug mode.
761 @end itemize
762 @end itemize
763
764 @subsection Memory access commands
765 These commands allow accesses of a specific size to the memory system:
766 @itemize @bullet
767 @item @b{mdw} <@var{addr}> [@var{count}]
768 @cindex mdw
769 display memory words
770 @item @b{mdh} <@var{addr}> [@var{count}]
771 @cindex mdh
772 display memory half-words
773 @item @b{mdb} <@var{addr}> [@var{count}]
774 @cindex mdb
775 display memory bytes
776 @item @b{mww} <@var{addr}> <@var{value}>
777 @cindex mww
778 write memory word
779 @item @b{mwh} <@var{addr}> <@var{value}>
780 @cindex mwh
781 write memory half-word
782 @item @b{mwb} <@var{addr}> <@var{value}>
783 @cindex mwb
784 write memory byte
785
786 @item @b{load_image} <@var{file}> <@var{address}> [@option{bin}|@option{ihex}|@option{elf}]
787 @cindex load_image
788 Load image <@var{file}> to target memory at <@var{address}>
789 @item @b{dump_image} <@var{file}> <@var{address}> <@var{size}>
790 @cindex dump_image
791 Dump <@var{size}> bytes of target memory starting at <@var{address}> to a
792 (binary) <@var{file}>.
793 @item @b{verify_image} <@var{file}> <@var{address}> [@option{bin}|@option{ihex}|@option{elf}]
794 @cindex verify_image
795 Verify <@var{file}> to target memory starting at <@var{address}>.
796 This will first attempt using a crc checksum, if this fails it will try a binary compare.
797 @end itemize
798
799 @subsection Flash commands
800 @cindex Flash commands
801 @itemize @bullet
802 @item @b{flash banks}
803 @cindex flash banks
804 List configured flash banks
805 @item @b{flash info} <@var{num}>
806 @cindex flash info
807 Print info about flash bank <@option{num}>
808 @item @b{flash probe} <@var{num}>
809 @cindex flash probe
810 Identify the flash, or validate the parameters of the configured flash. Operation
811 depends on the flash type.
812 @item @b{flash erase_check} <@var{num}>
813 @cindex flash erase_check
814 Check erase state of sectors in flash bank <@var{num}>. This is the only operation that
815 updates the erase state information displayed by @option{flash info}. That means you have
816 to issue an @option{erase_check} command after erasing or programming the device to get
817 updated information.
818 @item @b{flash protect_check} <@var{num}>
819 @cindex flash protect_check
820 Check protection state of sectors in flash bank <num>.
821 @option{flash erase_sector} using the same syntax.
822 @item @b{flash erase_sector} <@var{num}> <@var{first}> <@var{last}>
823 @cindex flash erase_sector
824 Erase sectors at bank <@var{num}>, starting at sector <@var{first}> up to and including
825 <@var{last}>. Sector numbering starts at 0. Depending on the flash type, erasing might
826 require the protection to be disabled first (e.g. Intel Advanced Bootblock flash using
827 the CFI driver).
828 @item @b{flash erase_address} <@var{address}> <@var{length}>
829 @cindex flash erase_address
830 Erase sectors starting at <@var{address}> for <@var{length}> number of bytes
831 @item @b{flash write_bank} <@var{num}> <@var{file}> <@var{offset}>
832 @cindex flash write_bank
833 Write the binary <@var{file}> to flash bank <@var{num}>, starting at
834 <@option{offset}> bytes from the beginning of the bank.
835 @item @b{flash write_image} <@var{file}> [@var{offset}] [@var{type}]
836 @cindex flash write_image
837 Write the image <@var{file}> to the current target's flash bank(s). A relocation
838 [@var{offset}] can be specified and the file [@var{type}] can be specified
839 explicitly as @option{bin} (binary), @option{ihex} (Intel hex), @option{elf}
840 (ELF file) or @option{s19} (Motorola s19).
841 @item @b{flash protect} <@var{num}> <@var{first}> <@var{last}> <@option{on}|@option{off}>
842 @cindex flash protect
843 Enable (@var{on}) or disable (@var{off}) protection of flash sectors <@var{first}> to
844 <@var{last}> of @option{flash bank} <@var{num}>.
845 @item @b{flash auto_erase} <@var{on}|@var{off}>
846 @cindex flash auto_erase
847 Enable (@option{on}) to erase flash banks prior to writing using the flash @option{write_image} command
848 only. Default is (@option{off}), flash banks have to be erased using @option{flash erase} command.
849 @end itemize
850
851 @page
852 @section Target Specific Commands
853 @cindex Target Specific Commands
854
855 @subsection AT91SAM7 specific commands
856 @cindex AT91SAM7 specific commands
857 The flash configuration is deduced from the chip identification register. The flash
858 controller handles erases automatically on a page (128/265 byte) basis so erase is
859 not necessary for flash programming. AT91SAM7 processors with less than 512K flash
860 only have a single flash bank embedded on chip. AT91SAM7xx512 have two flash planes
861 that can be erased separatly.Only an EraseAll command is supported by the controller
862 for each flash plane and this is called with
863 @itemize @bullet
864 @item @b{flash erase} <@var{num}> @var{first_plane} @var{last_plane}
865 bulk erase flash planes first_plane to last_plane.
866 @item @b{at91sam7 gpnvm} <@var{num}> <@var{bit}> <@option{set}|@option{clear}>
867 @cindex at91sam7 gpnvm
868 set or clear a gpnvm bit for the processor
869 @end itemize
870
871 @subsection STR9 specific commands
872 @cindex STR9 specific commands
873 These are flash specific commands when using the str9xpec driver.
874 @itemize @bullet
875 @item @b{str9xpec enable_turbo} <@var{num}>
876 @cindex str9xpec enable_turbo
877 enable turbo mode, simply this will remove the str9 from the chain and talk
878 directly to the embedded flash controller.
879 @item @b{str9xpec disable_turbo} <@var{num}>
880 @cindex str9xpec disable_turbo
881 restore the str9 into jtag chain.
882 @item @b{str9xpec lock} <@var{num}>
883 @cindex str9xpec lock
884 lock str9 device. The str9 will only respond to an unlock command that will
885 erase the device.
886 @item @b{str9xpec unlock} <@var{num}>
887 @cindex str9xpec unlock
888 unlock str9 device.
889 @item @b{str9xpec options_read} <@var{num}>
890 @cindex str9xpec options_read
891 read str9 option bytes.
892 @item @b{str9xpec options_write} <@var{num}>
893 @cindex str9xpec options_write
894 write str9 option bytes.
895 @end itemize
896
897 @subsection STR9 configuration
898 @cindex STR9 configuration
899 @itemize @bullet
900 @item @b{str9x flash_config} <@var{bank}> <@var{BBSR}> <@var{NBBSR}>
901 <@var{BBADR}> <@var{NBBADR}>
902 @cindex str9x flash_config
903 Configure str9 flash controller.
904 @smallexample
905 eg. str9x flash_config 0 4 2 0 0x80000
906 This will setup
907 BBSR - Boot Bank Size register
908 NBBSR - Non Boot Bank Size register
909 BBADR - Boot Bank Start Address register
910 NBBADR - Boot Bank Start Address register
911 @end smallexample
912 @end itemize
913
914 @subsection STR9 option byte configuration
915 @cindex STR9 option byte configuration
916 @itemize @bullet
917 @item @b{str9xpec options_cmap} <@var{num}> <@option{bank0}|@option{bank1}>
918 @cindex str9xpec options_cmap
919 configure str9 boot bank.
920 @item @b{str9xpec options_lvdthd} <@var{num}> <@option{2.4v}|@option{2.7v}>
921 @cindex str9xpec options_lvdthd
922 configure str9 lvd threshold.
923 @item @b{str9xpec options_lvdsel} <@var{num}> <@option{vdd}|@option{vdd_vddq}>
924 @cindex str9xpec options_lvdsel
925 configure str9 lvd source.
926 @item @b{str9xpec options_lvdwarn} <@var{bank}> <@option{vdd}|@option{vdd_vddq}>
927 @cindex str9xpec options_lvdwarn
928 configure str9 lvd reset warning source.
929 @end itemize
930
931 @subsection STM32x specific commands
932 @cindex STM32x specific commands
933
934 These are flash specific commands when using the stm32x driver.
935 @itemize @bullet
936 @item @b{stm32x lock} <@var{num}>
937 @cindex stm32x lock
938 lock stm32 device.
939 @item @b{stm32x unlock} <@var{num}>
940 @cindex stm32x unlock
941 unlock stm32 device.
942 @item @b{stm32x options_read} <@var{num}>
943 @cindex stm32x options_read
944 read stm32 option bytes.
945 @item @b{stm32x options_write} <@var{num}> <@option{SWWDG}|@option{HWWDG}>
946 <@option{RSTSTNDBY}|@option{NORSTSTNDBY}> <@option{RSTSTOP}|@option{NORSTSTOP}>
947 @cindex stm32x options_write
948 write stm32 option bytes.
949 @item @b{stm32x mass_erase} <@var{num}>
950 @cindex stm32x mass_erase
951 mass erase flash memory.
952 @end itemize
953
954 @page
955 @section Architecture Specific Commands
956 @cindex Architecture Specific Commands
957
958 @subsection ARMV4/5 specific commands
959 @cindex ARMV4/5 specific commands
960
961 These commands are specific to ARM architecture v4 and v5, like all ARM7/9 systems
962 or Intel XScale (XScale isn't supported yet).
963 @itemize @bullet
964 @item @b{armv4_5 reg}
965 @cindex armv4_5 reg
966 Display a list of all banked core registers, fetching the current value from every
967 core mode if necessary. OpenOCD versions before rev. 60 didn't fetch the current
968 register value.
969 @item @b{armv4_5 core_mode} [@var{arm}|@var{thumb}]
970 @cindex armv4_5 core_mode
971 Displays the core_mode, optionally changing it to either ARM or Thumb mode.
972 The target is resumed in the currently set @option{core_mode}.
973 @end itemize
974
975 @subsection ARM7/9 specific commands
976 @cindex ARM7/9 specific commands
977
978 These commands are specific to ARM7 and ARM9 targets, like ARM7TDMI, ARM720t,
979 ARM920t or ARM926EJ-S.
980 @itemize @bullet
981 @item @b{arm7_9 sw_bkpts} <@var{enable}|@var{disable}>
982 @cindex arm7_9 sw_bkpts
983 Enable/disable use of software breakpoints. On ARMv4 systems, this reserves
984 one of the watchpoint registers to implement software breakpoints. Disabling
985 SW Bkpts frees that register again.
986 @item @b{arm7_9 force_hw_bkpts} <@var{enable}|@var{disable}>
987 @cindex arm7_9 force_hw_bkpts
988 When @option{force_hw_bkpts} is enabled, the @option{sw_bkpts} support is disabled, and all
989 breakpoints are turned into hardware breakpoints.
990 @item @b{arm7_9 dbgrq} <@var{enable}|@var{disable}>
991 @cindex arm7_9 dbgrq
992 Enable use of the DBGRQ bit to force entry into debug mode. This should be
993 safe for all but ARM7TDMI--S cores (like Philips LPC).
994 @item @b{arm7_9 fast_memory_access} <@var{enable}|@var{disable}>
995 @cindex arm7_9 fast_memory_access
996 Allow the OpenOCD to read and write memory without checking completion of
997 the operation. This provides a huge speed increase, especially with USB JTAG
998 cables (FT2232), but might be unsafe if used with targets running at a very low
999 speed, like the 32kHz startup clock of an AT91RM9200.
1000 @item @b{arm7_9 dcc_downloads} <@var{enable}|@var{disable}>
1001 @cindex arm7_9 dcc_downloads
1002 Enable the use of the debug communications channel (DCC) to write larger (>128 byte)
1003 amounts of memory. DCC downloads offer a huge speed increase, but might be potentially
1004 unsafe, especially with targets running at a very low speed. This command was introduced
1005 with OpenOCD rev. 60.
1006 @end itemize
1007
1008 @subsection ARM720T specific commands
1009 @cindex ARM720T specific commands
1010
1011 @itemize @bullet
1012 @item @b{arm720t cp15} <@var{num}> [@var{value}]
1013 @cindex arm720t cp15
1014 display/modify cp15 register <@option{num}> [@option{value}].
1015 @item @b{arm720t md<bhw>_phys} <@var{addr}> [@var{count}]
1016 @cindex arm720t md<bhw>_phys
1017 Display memory at physical address addr.
1018 @item @b{arm720t mw<bhw>_phys} <@var{addr}> <@var{value}>
1019 @cindex arm720t mw<bhw>_phys
1020 Write memory at physical address addr.
1021 @item @b{arm720t virt2phys} <@var{va}>
1022 @cindex arm720t virt2phys
1023 Translate a virtual address to a physical address.
1024 @end itemize
1025
1026 @subsection ARM9TDMI specific commands
1027 @cindex ARM9TDMI specific commands
1028
1029 @itemize @bullet
1030 @item @b{arm9tdmi vector_catch} <@var{all}|@var{none}>
1031 @cindex arm9tdmi vector_catch
1032 Catch arm9 interrupt vectors, can be @option{all} @option{none} or any of the following:
1033 @option{reset} @option{undef} @option{swi} @option{pabt} @option{dabt} @option{reserved}
1034 @option{irq} @option{fiq}.
1035
1036 Can also be used on other arm9 based cores, arm966, arm920t and arm926ejs.
1037 @end itemize
1038
1039 @subsection ARM966E specific commands
1040 @cindex ARM966E specific commands
1041
1042 @itemize @bullet
1043 @item @b{arm966e cp15} <@var{num}> [@var{value}]
1044 @cindex arm966e cp15
1045 display/modify cp15 register <@option{num}> [@option{value}].
1046 @end itemize
1047
1048 @subsection ARM920T specific commands
1049 @cindex ARM920T specific commands
1050
1051 @itemize @bullet
1052 @item @b{arm920t cp15} <@var{num}> [@var{value}]
1053 @cindex arm920t cp15
1054 display/modify cp15 register <@option{num}> [@option{value}].
1055 @item @b{arm920t cp15i} <@var{num}> [@var{value}] [@var{address}]
1056 @cindex arm920t cp15i
1057 display/modify cp15 (interpreted access) <@option{opcode}> [@option{value}] [@option{address}]
1058 @item @b{arm920t cache_info}
1059 @cindex arm920t cache_info
1060 Print information about the caches found. This allows you to see if your target
1061 is a ARM920T (2x16kByte cache) or ARM922T (2x8kByte cache).
1062 @item @b{arm920t md<bhw>_phys} <@var{addr}> [@var{count}]
1063 @cindex arm920t md<bhw>_phys
1064 Display memory at physical address addr.
1065 @item @b{arm920t mw<bhw>_phys} <@var{addr}> <@var{value}>
1066 @cindex arm920t mw<bhw>_phys
1067 Write memory at physical address addr.
1068 @item @b{arm920t read_cache} <@var{filename}>
1069 @cindex arm920t read_cache
1070 Dump the content of ICache and DCache to a file.
1071 @item @b{arm920t read_mmu} <@var{filename}>
1072 @cindex arm920t read_mmu
1073 Dump the content of the ITLB and DTLB to a file.
1074 @item @b{arm920t virt2phys} <@var{va}>
1075 @cindex arm920t virt2phys
1076 Translate a virtual address to a physical address.
1077 @end itemize
1078
1079 @subsection ARM926EJS specific commands
1080 @cindex ARM926EJS specific commands
1081
1082 @itemize @bullet
1083 @item @b{arm926ejs cp15} <@var{num}> [@var{value}]
1084 @cindex arm926ejs cp15
1085 display/modify cp15 register <@option{num}> [@option{value}].
1086 @item @b{arm926ejs cache_info}
1087 @cindex arm926ejs cache_info
1088 Print information about the caches found.
1089 @item @b{arm926ejs md<bhw>_phys} <@var{addr}> [@var{count}]
1090 @cindex arm926ejs md<bhw>_phys
1091 Display memory at physical address addr.
1092 @item @b{arm926ejs mw<bhw>_phys} <@var{addr}> <@var{value}>
1093 @cindex arm926ejs mw<bhw>_phys
1094 Write memory at physical address addr.
1095 @item @b{arm926ejs virt2phys} <@var{va}>
1096 @cindex arm926ejs virt2phys
1097 Translate a virtual address to a physical address.
1098 @end itemize
1099
1100 @page
1101 @section Debug commands
1102 @cindex Debug commands
1103 The following commands give direct access to the core, and are most likely
1104 only useful while debugging the OpenOCD.
1105 @itemize @bullet
1106 @item @b{arm7_9 write_xpsr} <@var{32-bit value}> <@option{0=cpsr}, @option{1=spsr}>
1107 @cindex arm7_9 write_xpsr
1108 Immediately write either the current program status register (CPSR) or the saved
1109 program status register (SPSR), without changing the register cache (as displayed
1110 by the @option{reg} and @option{armv4_5 reg} commands).
1111 @item @b{arm7_9 write_xpsr_im8} <@var{8-bit value}> <@var{rotate 4-bit}>
1112 <@var{0=cpsr},@var{1=spsr}>
1113 @cindex arm7_9 write_xpsr_im8
1114 Write the 8-bit value rotated right by 2*rotate bits, using an immediate write
1115 operation (similar to @option{write_xpsr}).
1116 @item @b{arm7_9 write_core_reg} <@var{num}> <@var{mode}> <@var{value}>
1117 @cindex arm7_9 write_core_reg
1118 Write a core register, without changing the register cache (as displayed by the
1119 @option{reg} and @option{armv4_5 reg} commands). The <@var{mode}> argument takes the
1120 encoding of the [M4:M0] bits of the PSR.
1121 @end itemize
1122
1123 @page
1124 @section JTAG commands
1125 @cindex JTAG commands
1126 @itemize @bullet
1127 @item @b{scan_chain}
1128 @cindex scan_chain
1129 Print current scan chain configuration.
1130 @item @b{jtag_reset} <@var{trst}> <@var{srst}>
1131 @cindex jtag_reset
1132 Toggle reset lines.
1133 @item @b{endstate} <@var{tap_state}>
1134 @cindex endstate
1135 Finish JTAG operations in <@var{tap_state}>.
1136 @item @b{runtest} <@var{num_cycles}>
1137 @cindex runtest
1138 Move to Run-Test/Idle, and execute <@var{num_cycles}>
1139 @item @b{statemove} [@var{tap_state}]
1140 @cindex statemove
1141 Move to current endstate or [@var{tap_state}]
1142 @item @b{irscan} <@var{device}> <@var{instr}> [@var{dev2}] [@var{instr2}] ...
1143 @cindex irscan
1144 Execute IR scan <@var{device}> <@var{instr}> [@var{dev2}] [@var{instr2}] ...
1145 @item @b{drscan} <@var{device}> [@var{dev2}] [@var{var2}] ...
1146 @cindex drscan
1147 Execute DR scan <@var{device}> [@var{dev2}] [@var{var2}] ...
1148 @item @b{verify_ircapture} <@option{enable}|@option{disable}>
1149 @cindex verify_ircapture
1150 Verify value captured during Capture-IR. Default is enabled.
1151 @item @b{var} <@var{name}> [@var{num_fields}|@var{del}] [@var{size1}] ...
1152 @cindex var
1153 Allocate, display or delete variable <@var{name}> [@var{num_fields}|@var{del}] [@var{size1}] ...
1154 @item @b{field} <@var{var}> <@var{field}> [@var{value}|@var{flip}]
1155 @cindex field
1156 Display/modify variable field <@var{var}> <@var{field}> [@var{value}|@var{flip}].
1157 @end itemize
1158
1159 @page
1160 @section Target Requests
1161 @cindex Target Requests
1162 Openocd can handle certain target requests, currently debugmsg are only supported for arm7_9 and cortex_m3.
1163 See libdcc in the contrib dir for more details.
1164 @itemize @bullet
1165 @item @b{target_request debugmsgs} <@var{enable}|@var{disable}>
1166 @cindex target_request debugmsgs
1167 Enable/disable target debugmsgs requests. debugmsgs enable messages to be sent to the debugger while the target is running.
1168 @end itemize
1169
1170 @node Sample Scripts
1171 @chapter Sample Scripts
1172 @cindex scripts
1173
1174 This page will collect some script examples for different CPUs.
1175
1176 The configuration script can be divided in the following section:
1177 @itemize @bullet
1178 @item daemon configuration
1179 @item interface
1180 @item jtag scan chain
1181 @item target configuration
1182 @item flash configuration
1183 @end itemize
1184
1185 Detailed information about each section can be found at OpenOCD configuration
1186
1187 @section OMAP5912 Flash Debug
1188 @cindex OMAP5912 Flash Debug
1189 The following two scripts were used with a wiggler PP and and a TI OMAP5912
1190 dual core processor - (@uref{http://www.ti.com}), on a OMAP5912 OSK board
1191 - (@uref{http://www.spectrumdigital.com}).
1192 @subsection Openocd config
1193 @smallexample
1194 #daemon configuration
1195 telnet_port 4444
1196 gdb_port 3333
1197
1198 #interface
1199 interface parport
1200 parport_port 0x378
1201 parport_cable wiggler
1202 jtag_speed 0
1203
1204 #use combined on interfaces or targets that can't set TRST/SRST separately
1205 reset_config trst_and_srst
1206
1207 #jtag scan chain
1208 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1209 jtag_device 38 0x0 0x0 0x0
1210 jtag_device 4 0x1 0x0 0xe
1211 jtag_device 8 0x0 0x0 0x0
1212
1213 #target configuration
1214 daemon_startup reset
1215
1216 #target <type> <endianness> <reset mode> <chainpos> <variant>
1217 target arm926ejs little run_and_init 1 arm926ejs
1218 target_script 0 reset omap5912_osk.init
1219 run_and_halt_time 0 30
1220
1221 # omap5912 lcd frame buffer as working area
1222 working_area 0 0x20000000 0x3e800 nobackup
1223
1224 #flash bank <driver> <base> <size> <chip_width> <bus_width>
1225 flash bank cfi 0x00000000 0x1000000 2 2 0
1226 @end smallexample
1227
1228 @subsection Openocd init
1229 @smallexample
1230 #
1231 # halt target
1232 #
1233 poll
1234 sleep 1
1235 halt
1236 wait_halt
1237 #
1238 # disable wdt
1239 #
1240 mww 0xfffec808 0x000000f5
1241 mww 0xfffec808 0x000000a0
1242
1243 mww 0xfffeb048 0x0000aaaa
1244 sleep 500
1245 mww 0xfffeb048 0x00005555
1246 sleep 500
1247 #
1248 # detect flash
1249 #
1250 flash probe 0
1251
1252 @end smallexample
1253
1254 @section STR71x Script
1255 @cindex STR71x Script
1256 The following script was used with an Amontec JTAGkey and a STR710 / STR711 CPU:
1257 @smallexample
1258 #daemon configuration
1259 telnet_port 4444
1260 gdb_port 3333
1261
1262 #interface
1263 interface ft2232
1264 ft2232_device_desc "Amontec JTAGkey A"
1265 ft2232_layout jtagkey
1266 ft2232_vid_pid 0x0403 0xcff8
1267 jtag_speed 0
1268
1269 #use combined on interfaces or targets that can't set TRST/SRST separately
1270 reset_config trst_and_srst srst_pulls_trst
1271
1272 #jtag scan chain
1273 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1274 jtag_device 4 0x1 0xf 0xe
1275
1276 #target configuration
1277 daemon_startup reset
1278
1279 #target <type> <startup mode>
1280 #target arm7tdmi <endianness> <reset mode> <chainpos> <variant>
1281 target arm7tdmi little run_and_halt 0 arm7tdmi
1282 run_and_halt_time 0 30
1283
1284 working_area 0 0x2000C000 0x4000 nobackup
1285
1286 #flash bank <driver> <base> <size> <chip_width> <bus_width>
1287 flash bank str7x 0x40000000 0x00040000 0 0 0 STR71x
1288 @end smallexample
1289
1290 @section STR750 Script
1291 @cindex STR750 Script
1292 The following script was used with an Amontec JTAGkey and a STR750 CPU:
1293 @smallexample
1294 #daemon configuration
1295 telnet_port 4444
1296 gdb_port 3333
1297
1298 #interface
1299 interface ft2232
1300 ft2232_device_desc "Amontec JTAGkey A"
1301 ft2232_layout jtagkey
1302 ft2232_vid_pid 0x0403 0xcff8
1303 jtag_speed 19
1304
1305 #use combined on interfaces or targets that can't set TRST/SRST separately
1306 #reset_config trst_and_srst srst_pulls_trst
1307 reset_config trst_and_srst srst_pulls_trst
1308
1309 #jtag scan chain
1310 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1311 jtag_device 4 0x1 0xf 0xe
1312
1313 #jtag nTRST and nSRST delay
1314 jtag_nsrst_delay 500
1315 jtag_ntrst_delay 500
1316
1317 #target configuration
1318 daemon_startup reset
1319
1320 #target <type> <startup mode>
1321 #target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
1322 target arm7tdmi little run_and_halt 0 arm7tdmi
1323 run_and_halt_time 0 30
1324
1325 working_area 0 0x40000000 0x4000 nobackup
1326
1327 #flash bank <driver> <base> <size> <chip_width> <bus_width>
1328 flash bank str7x 0x20000000 0x000040000 0 0 0 STR75x
1329 @end smallexample
1330
1331 @section STR912 Script
1332 @cindex STR912 Script
1333 The following script was used with an Amontec JTAGkey and a STR912 CPU:
1334 @smallexample
1335 #daemon configuration
1336 telnet_port 4444
1337 gdb_port 3333
1338
1339 #interface
1340 interface ft2232
1341 ft2232_device_desc "Amontec JTAGkey A"
1342 ft2232_layout jtagkey
1343 jtag_speed 1
1344
1345 #use combined on interfaces or targets that can't set TRST/SRST separately
1346 reset_config trst_and_srst
1347
1348 #jtag scan chain
1349 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1350 jtag_device 8 0x1 0x1 0xfe
1351 jtag_device 4 0x1 0xf 0xe
1352 jtag_device 5 0x1 0x1 0x1e
1353
1354 #target configuration
1355 daemon_startup reset
1356
1357 #target <type> <startup mode>
1358 #target arm966e <endianness> <reset mode> <chainpos> <variant>
1359 target arm966e little reset_halt 1 arm966e
1360 run_and_halt_time 0 30
1361
1362 working_area 0 0x50000000 16384 nobackup
1363
1364 #flash bank <driver> <base> <size> <chip_width> <bus_width>
1365 flash bank str9x 0x00000000 0x00080000 0 0 0
1366 @end smallexample
1367
1368 @section STR912 comstick
1369 @cindex STR912 comstick Script
1370 The following script was used with a Hitex STR9 Comstick:
1371 @smallexample
1372 #daemon configuration
1373 telnet_port 4444
1374 gdb_port 3333
1375
1376 #interface
1377 interface ft2232
1378 ft2232_device_desc "STR9-comStick A"
1379 ft2232_layout comstick
1380 jtag_speed 1
1381
1382 jtag_nsrst_delay 100
1383 jtag_ntrst_delay 100
1384
1385 #use combined on interfaces or targets that can't set TRST/SRST separately
1386 reset_config trst_and_srst
1387
1388 #jtag scan chain
1389 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1390 jtag_device 8 0x1 0x1 0xfe
1391 jtag_device 4 0x1 0xf 0xe
1392 jtag_device 5 0x1 0x1 0x1e
1393
1394 #target configuration
1395 daemon_startup reset
1396
1397 #target <type> <startup mode>
1398 #target arm966e <endianness> <reset mode> <chainpos> <variant>
1399 target arm966e little reset_halt 1 arm966e
1400 run_and_halt_time 0 30
1401
1402 working_area 0 0x50000000 16384 nobackup
1403
1404 #flash bank <driver> <base> <size> <chip_width> <bus_width>
1405 flash bank str9x 0x00000000 0x00080000 0 0 0
1406 @end smallexample
1407
1408 @section STM32x Script
1409 @cindex STM32x Script
1410 The following script was used with an Amontec JTAGkey and a STM32x CPU:
1411 @smallexample
1412 #daemon configuration
1413 telnet_port 4444
1414 gdb_port 3333
1415
1416 #interface
1417 interface ft2232
1418 ft2232_device_desc "Amontec JTAGkey A"
1419 ft2232_layout jtagkey
1420 jtag_speed 10
1421
1422 jtag_nsrst_delay 100
1423 jtag_ntrst_delay 100
1424
1425 #use combined on interfaces or targets that can't set TRST/SRST separately
1426 reset_config trst_and_srst
1427
1428 #jtag scan chain
1429 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1430 jtag_device 4 0x1 0xf 0xe
1431 jtag_device 5 0x1 0x1 0x1e
1432
1433 #target configuration
1434 daemon_startup reset
1435
1436 #target <type> <startup mode>
1437 #target cortex_m3 <endianness> <reset mode> <chainpos> <variant>
1438 target cortex_m3 little run_and_halt 0
1439 run_and_halt_time 0 30
1440
1441 working_area 0 0x20000000 16384 nobackup
1442
1443 #flash bank <driver> <base> <size> <chip_width> <bus_width>
1444 flash bank stm32x 0x08000000 0x00020000 0 0 0
1445 @end smallexample
1446
1447 @section STM32x Performance Stick
1448 @cindex STM32x Performance Stick Script
1449 The following script was used with the Hitex STM32 Performance Stick
1450 @smallexample
1451 #daemon configuration
1452 telnet_port 4444
1453 gdb_port 3333
1454
1455 #interface
1456 interface ft2232
1457 ft2232_device_desc "STM32-PerformanceStick A"
1458 ft2232_layout stm32stick
1459 jtag_speed 10
1460
1461 jtag_nsrst_delay 100
1462 jtag_ntrst_delay 100
1463
1464 #use combined on interfaces or targets that can't set TRST/SRST separately
1465 reset_config trst_and_srst
1466
1467 #jtag scan chain
1468 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1469 jtag_device 4 0x1 0xf 0xe
1470 jtag_device 5 0x1 0x1 0x1e
1471 jtag_device 4 0x1 0xf 0xe
1472
1473 #target configuration
1474 daemon_startup reset
1475
1476 #target <type> <startup mode>
1477 #target cortex_m3 <endianness> <reset mode> <chainpos> <variant>
1478 target cortex_m3 little run_and_halt 0
1479 run_and_halt_time 0 30
1480
1481 working_area 0 0x20000000 16384 nobackup
1482
1483 #flash bank <driver> <base> <size> <chip_width> <bus_width>
1484 flash bank stm32x 0x08000000 0x00020000 0 0 0
1485 @end smallexample
1486
1487 @section LPC2129 Script
1488 @cindex LPC2129 Script
1489 The following script was used with an wiggler PP and a LPC-2129 CPU:
1490 @smallexample
1491 #daemon configuration
1492 telnet_port 4444
1493 gdb_port 3333
1494
1495 #interface
1496 interface parport
1497 parport_port 0x378
1498 parport_cable wiggler
1499 jtag_speed 0
1500
1501 #use combined on interfaces or targets that can't set TRST/SRST separately
1502 reset_config trst_and_srst srst_pulls_trst
1503
1504 #jtag scan chain
1505 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1506 jtag_device 4 0x1 0xf 0xe
1507
1508 #target configuration
1509 daemon_startup reset
1510
1511 #target <type> <startup mode>
1512 #target arm7tdmi <endianness> <reset mode> <chainpos> <variant>
1513 target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4
1514 run_and_halt_time 0 30
1515
1516 working_area 0 0x40000000 0x4000 nobackup
1517
1518 #flash bank <driver> <base> <size> <chip_width> <bus_width>
1519 flash bank lpc2000 0x0 0x40000 0 0 0 lpc2000_v1 14765 calc_checksum
1520 @end smallexample
1521
1522 @section LPC2148 Script
1523 @cindex LPC2148 Script
1524 The following script was used with an Amontec JTAGkey and a LPC2148 CPU:
1525 @smallexample
1526 #daemon configuration
1527 telnet_port 4444
1528 gdb_port 3333
1529
1530 #interface
1531 interface ft2232
1532 ft2232_device_desc "Amontec JTAGkey A"
1533 ft2232_layout jtagkey
1534 ft2232_vid_pid 0x0403 0xcff8
1535 jtag_speed 3
1536
1537 #use combined on interfaces or targets that can't set TRST/SRST separately
1538 reset_config trst_and_srst srst_pulls_trst
1539
1540 #jtag scan chain
1541 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1542 jtag_device 4 0x1 0xf 0xe
1543
1544 #target configuration
1545 daemon_startup reset
1546
1547 #target <type> <startup mode>
1548 #target arm7tdmi <endianness> <reset mode> <chainpos> <variant>
1549 target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4
1550 run_and_halt_time 0 30
1551
1552 working_area 0 0x40000000 0x8000 nobackup
1553
1554 #flash configuration
1555 flash bank lpc2000 0x0 0x7d000 0 0 0 lpc2000_v1 14765 calc_checksum
1556 @end smallexample
1557
1558 @section LPC2294 Script
1559 @cindex LPC2294 Script
1560 The following script was used with an Amontec JTAGkey and a LPC2294 CPU:
1561 @smallexample
1562 #daemon configuration
1563 telnet_port 4444
1564 gdb_port 3333
1565
1566 #interface
1567 interface ft2232
1568 ft2232_device_desc "Amontec JTAGkey A"
1569 ft2232_layout jtagkey
1570 ft2232_vid_pid 0x0403 0xcff8
1571 jtag_speed 3
1572
1573 #use combined on interfaces or targets that can't set TRST/SRST separately
1574 reset_config trst_and_srst srst_pulls_trst
1575
1576 #jtag scan chain
1577 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1578 jtag_device 4 0x1 0xf 0xe
1579
1580 #target configuration
1581 daemon_startup reset
1582
1583 #target <type> <startup mode>
1584 #target arm7tdmi <endianness> <reset mode> <chainpos> <variant>
1585 target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4
1586 run_and_halt_time 0 30
1587
1588 working_area 0 0x40000000 0x4000 nobackup
1589
1590 #flash configuration
1591 flash bank lpc2000 0x0 0x40000 0 0 0 lpc2000_v1 14765 calc_checksum
1592 @end smallexample
1593
1594 @section AT91R40008 Script
1595 @cindex AT91R40008 Script
1596 The following script was used with an Amontec JTAGkey and a AT91R40008 CPU:
1597 @smallexample
1598 #daemon configuration
1599 telnet_port 4444
1600 gdb_port 3333
1601
1602 #interface
1603 interface ft2232
1604 ft2232_device_desc "Amontec JTAGkey A"
1605 ft2232_layout jtagkey
1606 ft2232_vid_pid 0x0403 0xcff8
1607 jtag_speed 0
1608 jtag_nsrst_delay 200
1609 jtag_ntrst_delay 200
1610
1611 #use combined on interfaces or targets that can't set TRST/SRST separately
1612 reset_config srst_only srst_pulls_trst
1613
1614 #jtag scan chain
1615 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1616 jtag_device 4 0x1 0xf 0xe
1617
1618 #target configuration
1619 daemon_startup reset
1620
1621 #target <type> <startup mode>
1622 #target arm7tdmi <endianness> <reset mode> <chainpos> <variant>
1623 target arm7tdmi little run_and_halt 0 arm7tdmi
1624 run_and_halt_time 0 30
1625 @end smallexample
1626
1627 @section AT91SAM7s Script
1628 @cindex AT91SAM7s Script
1629 The following script was used with an Olimex ARM-JTAG-OCD and a AT91SAM7S64 CPU:
1630 @smallexample
1631 #daemon configuration
1632 telnet_port 4444
1633 gdb_port 3333
1634
1635 #interface
1636 interface ft2232
1637 ft2232_device_desc "Olimex OpenOCD JTAG A"
1638 ft2232_layout olimex-jtag
1639 ft2232_vid_pid 0x15BA 0x0003
1640 jtag_speed 0
1641 jtag_nsrst_delay 200
1642 jtag_ntrst_delay 200
1643
1644 #use combined on interfaces or targets that can't set TRST/SRST separately
1645 reset_config srst_only srst_pulls_trst
1646
1647 #jtag scan chain
1648 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1649 jtag_device 4 0x1 0xf 0xe
1650
1651 #target configuration
1652 daemon_startup reset
1653
1654 #target <type> <startup mode>
1655 #target arm7tdmi <endianness> <reset mode> <chainpos> <variant>
1656 target arm7tdmi little run_and_halt 0 arm7tdmi
1657 run_and_halt_time 0 30
1658
1659 # flash-options AT91
1660 working_area 0 0x00200000 0x4000 nobackup
1661 flash bank at91sam7 0 0 0 0 0
1662
1663 # Information:
1664 # erase command (telnet-interface) for complete flash:
1665 # flash erase <num> 0 numlockbits-1 (can be seen from output of flash info 0)
1666 # SAM7S64 with 16 lockbits and bank 0: flash erase 0 0 15
1667 # set/clear NVM-Bits:
1668 # at91sam7 gpnvm <num> <bit> <set|clear>
1669 # disable locking from SAM-BA:
1670 # flash protect 0 0 1 off
1671 @end smallexample
1672
1673 @section XSCALE IXP42x Script
1674 @cindex XSCALE IXP42x Script
1675 The following script was used with an Amontec JTAGkey-Tiny and a xscale ixp42x CPU:
1676 @smallexample
1677 #daemon configuration
1678 telnet_port 4444
1679 gdb_port 3333
1680
1681 #interface
1682 interface ft2232
1683 ft2232_device_desc "Amontec JTAGkey A"
1684 ft2232_layout jtagkey
1685 ft2232_vid_pid 0x0403 0xcff8
1686 jtag_speed 0
1687 jtag_nsrst_delay 200
1688 jtag_ntrst_delay 200
1689
1690 #use combined on interfaces or targets that can't set TRST/SRST separately
1691 reset_config srst_only srst_pulls_trst
1692
1693 #jtag scan chain
1694 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1695 jtag_device 7 0x1 0x7f 0x7e
1696
1697 #target configuration
1698 daemon_startup reset
1699
1700 #target <type> <startup mode>
1701 #target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
1702 target xscale big run_and_halt 0 IXP42x
1703 run_and_halt_time 0 30
1704 @end smallexample
1705
1706 @section Cirrus Logic EP9301 Script
1707 @cindex Cirrus Logic EP9301 Script
1708 The following script was used with FT2232 based JTAG interfaces and a
1709 Cirrus Logic EP9301 processor on an Olimex CS-E9301 board.
1710 @smallexample
1711 #daemon configuration
1712 telnet_port 4444
1713 gdb_port 3333
1714
1715 #interface
1716 interface ft2232
1717
1718 #Olimex ARM-USB-OCD
1719 #ft2232_device_desc "Olimex OpenOCD JTAG"
1720 #ft2232_layout olimex-jtag
1721 #ft2232_vid_pid 0x15ba 0x0003
1722
1723 #Amontec JTAGkey (and JTAGkey-Tiny)
1724 #Serial is only necessary if more than one JTAGkey is connected
1725 ft2232_device_desc "Amontec JTAGkey A"
1726 #ft2232_serial AMTJKV31
1727 #ft2232_serial T1P3S2W8
1728 ft2232_layout jtagkey
1729 ft2232_vid_pid 0x0403 0xcff8
1730
1731 #wiggler/parallel port interface
1732 #interface parport
1733 #parport_port 0x378
1734 #parport_cable wiggler
1735 #jtag_speed 0
1736 jtag_speed 1
1737 reset_config trst_and_srst
1738
1739 #jtag scan chain
1740 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1741 jtag_device 4 0x1 0xf 0xe
1742
1743 jtag_nsrst_delay 100
1744 jtag_ntrst_delay 100
1745
1746 #target configuration
1747 daemon_startup attach
1748
1749 #target <type> <endianess> <reset mode>
1750 target arm920t little reset_halt 0
1751 working_area 0 0x80014000 0x1000 backup
1752
1753 #flash configuration
1754 #flash bank <driver> <base> <size> <chip_width> <bus_width> [driver_options ...]
1755 flash bank cfi 0x60000000 0x1000000 2 2 0
1756 @end smallexample
1757
1758 @section Hilscher netX 100 / 500 Script
1759 @cindex Hilscher netX 100 / 500 Script
1760 The following script was used with an Amontec JTAGkey and a Hilscher
1761 netX 500 CPU:
1762 @smallexample
1763 #daemon configuration
1764 telnet_port 4444
1765 gdb_port 3333
1766
1767 #interface
1768 interface ft2232
1769 ft2232_device_desc "Amontec JTAGkey A"
1770 ft2232_layout jtagkey
1771 ft2232_vid_pid 0x0403 0xcff8
1772 jtag_speed 5
1773
1774 #use combined on interfaces or targets that can't set TRST/SRST separately
1775 reset_config trst_and_srst
1776
1777 #jtag scan chain
1778 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1779 jtag_device 4 0x1 0xf 0xe
1780
1781 jtag_nsrst_delay 100
1782 jtag_ntrst_delay 100
1783
1784 #target configuration
1785 daemon_startup reset
1786
1787 #target <type> <endianness> <startup mode> <chainpos> <variant>
1788 target arm926ejs little run_and_halt 0 arm926ejs
1789 run_and_halt_time 0 500
1790 @end smallexample
1791
1792 @section Marvell/Intel PXA270 Script
1793 @cindex Marvell/Intel PXA270 Script
1794 @smallexample
1795 # config for Intel PXA270
1796 # not, as of 2007-06-22, openocd only works with the
1797 # libftd2xx library from ftdi. libftdi does not work.
1798
1799 telnet_port 3333
1800 gdb_port 4444
1801
1802 interface ft2232
1803 ft2232_layout olimex-jtag
1804 ft2232_vid_pid 0x15BA 0x0003
1805 ft2232_device_desc "Olimex OpenOCD JTAG"
1806 jtag_speed 0
1807 # set jtag_nsrst_delay to the delay introduced by your reset circuit
1808 # the rest of the needed delays are built into the openocd program
1809 jtag_nsrst_delay 260
1810 # set the jtag_ntrst_delay to the delay introduced by a reset circuit
1811 # the rest of the needed delays are built into the openocd program
1812 jtag_ntrst_delay 0
1813
1814 #use combined on interfaces or targets that can't set TRST/SRST separately
1815 reset_config trst_and_srst separate
1816
1817 #jtag scan chain
1818 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
1819 jtag_device 7 0x1 0x7f 0x7e
1820
1821 #target configuration
1822 daemon_startup reset
1823
1824 target xscale little reset_halt 0 pxa27x
1825
1826 # maps to PXA internal RAM. If you are using a PXA255
1827 # you must initialize SDRAM or leave this option off
1828 working_area 0 0x5c000000 0x10000 nobackup
1829
1830 run_and_halt_time 0 30
1831
1832 #flash bank <driver> <base> <size> <chip_width> <bus_width>
1833 # works for P30 flash
1834 flash bank cfi 0x00000000 0x1000000 2 4 0
1835 @end smallexample
1836
1837 @node GDB and Openocd
1838 @chapter GDB and Openocd
1839 @cindex GDB and Openocd
1840 Openocd complies with the remote gdbserver protocol, and as such can be used
1841 to debug remote targets.
1842
1843 @section Connecting to gdb
1844 @cindex Connecting to gdb
1845 A connection is typically started as follows:
1846 @smallexample
1847 target remote localhost:3333
1848 @end smallexample
1849 This would cause gdb to connect to the gdbserver on the local pc using port 3333.
1850
1851 To see a list of available openocd commands type @option{monitor help} on the
1852 gdb commandline.
1853
1854 Openocd supports the gdb @option{qSupported} packet, this enables information
1855 to be sent by the gdb server (openocd) to gdb. Typical information includes
1856 packet size and device memory map.
1857
1858 Previous versions of openocd required the following gdb options to increase
1859 the packet size and speed up gdb communication.
1860 @smallexample
1861 set remote memory-write-packet-size 1024
1862 set remote memory-write-packet-size fixed
1863 set remote memory-read-packet-size 1024
1864 set remote memory-read-packet-size fixed
1865 @end smallexample
1866 This is now handled in the @option{qSupported} PacketSize.
1867
1868 @section Programming using gdb
1869 @cindex Programming using gdb
1870
1871 By default the target memory map is not sent to gdb, this can be enabled by
1872 the following openocd config option:
1873 @smallexample
1874 gdb_memory_map enable
1875 @end smallexample
1876 For this to function correctly a valid flash config must also be configured
1877 in openocd. For speed also configure a valid working area.
1878
1879 Informing gdb of the memory map of the target will enable gdb to protect any
1880 flash area of the target and use hardware breakpoints by default. This means
1881 that the openocd option @option{arm7_9 force_hw_bkpts} is not required when
1882 using a memory map.
1883
1884 To view the configured memory map in gdb, use the gdb command @option{info mem}
1885 All other unasigned addresses within gdb are treated as RAM.
1886
1887 If @option{gdb_flash_program enable} is also used, gdb will be able to
1888 program any flash memory using the vFlash interface.
1889
1890 gdb will look at the target memory map when a load command is given, if any
1891 areas to be programmed lie within the target flash area the vFlash packets
1892 will be used.
1893
1894 Incase the target needs configuring before gdb programming, a script can be executed.
1895 @smallexample
1896 target_script 0 gdb_program_config config.script
1897 @end smallexample
1898
1899 To verify any flash programming the gdb command @option{compare-sections}
1900 can be used.
1901
1902 @node Upgrading
1903 @chapter Deprecated/Removed Commands
1904 @cindex Deprecated/Removed Commands
1905 Certain openocd commands have been deprecated/removed during the various revisions.
1906
1907 @itemize @bullet
1908 @item @b{load_binary}
1909 @cindex load_binary
1910 use @option{load_image} command with same args
1911 @item @b{dump_binary}
1912 @cindex dump_binary
1913 use @option{dump_image} command with same args
1914 @item @b{flash erase}
1915 @cindex flash erase
1916 use @option{flash erase_sector} command with same args
1917 @item @b{flash write}
1918 @cindex flash write
1919 use @option{flash write_bank} command with same args
1920 @item @b{flash write_binary}
1921 @cindex flash write_binary
1922 use @option{flash write_bank} command with same args
1923 @item @b{arm7_9 fast_writes}
1924 @cindex arm7_9 fast_writes
1925 use @option{arm7_9 fast_memory_access} command with same args
1926 @end itemize
1927
1928 @node FAQ
1929 @chapter FAQ
1930 @cindex faq
1931 @enumerate
1932 @item OpenOCD complains about a missing cygwin1.dll.
1933
1934 Make sure you have Cygwin installed, or at least a version of OpenOCD that
1935 claims to come with all the necessary dlls. When using Cygwin, try launching
1936 the OpenOCD from the Cygwin shell.
1937
1938 @item I'm trying to set a breakpoint using GDB (or a frontend like Insight or
1939 Eclipse), but OpenOCD complains that "Info: arm7_9_common.c:213
1940 arm7_9_add_breakpoint(): sw breakpoint requested, but software breakpoints not enabled".
1941
1942 GDB issues software breakpoints when a normal breakpoint is requested, or to implement
1943 source-line single-stepping. On ARMv4T systems, like ARM7TDMI, ARM720t or ARM920t,
1944 software breakpoints consume one of the two available hardware breakpoints,
1945 and are therefore disabled by default. If your code is running from RAM, you
1946 can enable software breakpoints with the @option{arm7_9 sw_bkpts enable} command. If
1947 your code resides in Flash, you can't use software breakpoints, but you can force
1948 OpenOCD to use hardware breakpoints instead: @option{arm7_9 force_hw_bkpts enable}.
1949
1950 @item When erasing or writing LPC2000 on-chip flash, the operation fails sometimes
1951 and works sometimes fine.
1952
1953 Make sure the core frequency specified in the @option{flash lpc2000} line matches the
1954 clock at the time you're programming the flash. If you've specified the crystal's
1955 frequency, make sure the PLL is disabled, if you've specified the full core speed
1956 (e.g. 60MHz), make sure the PLL is enabled.
1957
1958 @item When debugging using an Amontec Chameleon in its JTAG Accelerator configuration,
1959 I keep getting "Error: amt_jtagaccel.c:184 amt_wait_scan_busy(): amt_jtagaccel timed
1960 out while waiting for end of scan, rtck was disabled".
1961
1962 Make sure your PC's parallel port operates in EPP mode. You might have to try several
1963 settings in your PC BIOS (ECP, EPP, and different versions of those).
1964
1965 @item When debugging with the OpenOCD and GDB (plain GDB, Insight, or Eclipse),
1966 I get lots of "Error: arm7_9_common.c:1771 arm7_9_read_memory():
1967 memory read caused data abort".
1968
1969 The errors are non-fatal, and are the result of GDB trying to trace stack frames
1970 beyond the last valid frame. It might be possible to prevent this by setting up
1971 a proper "initial" stack frame, if you happen to know what exactly has to
1972 be done, feel free to add this here.
1973
1974 @item I get the following message in the OpenOCD console (or log file):
1975 "Warning: arm7_9_common.c:679 arm7_9_assert_reset(): srst resets test logic, too".
1976
1977 This warning doesn't indicate any serious problem, as long as you don't want to
1978 debug your core right out of reset. Your .cfg file specified @option{jtag_reset
1979 trst_and_srst srst_pulls_trst} to tell the OpenOCD that either your board,
1980 your debugger or your target uC (e.g. LPC2000) can't assert the two reset signals
1981 independently. With this setup, it's not possible to halt the core right out of
1982 reset, everything else should work fine.
1983
1984 @item When using OpenOCD in conjunction with Amontec JTAGkey and the Yagarto
1985 Toolchain (Eclipse, arm-elf-gcc, arm-elf-gdb), the debugging seems to be
1986 unstable. When single-stepping over large blocks of code, GDB and OpenOCD
1987 quit with an error message. Is there a stability issue with OpenOCD?
1988
1989 No, this is not a stability issue concerning OpenOCD. Most users have solved
1990 this issue by simply using a self-powered USB hub, which they connect their
1991 Amontec JTAGkey to. Apparently, some computers do not provide a USB power
1992 supply stable enough for the Amontec JTAGkey to be operated.
1993
1994 @item When using the Amontec JTAGkey, sometimes OpenOCD crashes with the
1995 following error messages: "Error: ft2232.c:201 ft2232_read(): FT_Read returned:
1996 4" and "Error: ft2232.c:365 ft2232_send_and_recv(): couldn't read from FT2232".
1997 What does that mean and what might be the reason for this?
1998
1999 First of all, the reason might be the USB power supply. Try using a self-powered
2000 hub instead of a direct connection to your computer. Secondly, the error code 4
2001 corresponds to an FT_IO_ERROR, which means that the driver for the FTDI USB
2002 chip ran into some sort of error - this points us to a USB problem.
2003
2004 @item When using the Amontec JTAGkey, sometimes OpenOCD crashes with the following
2005 error message: "Error: gdb_server.c:101 gdb_get_char(): read: 10054".
2006 What does that mean and what might be the reason for this?
2007
2008 Error code 10054 corresponds to WSAECONNRESET, which means that the debugger (GDB)
2009 has closed the connection to OpenOCD. This might be a GDB issue.
2010
2011 @item In the configuration file in the section where flash device configurations
2012 are described, there is a parameter for specifying the clock frequency for
2013 LPC2000 internal flash devices (e.g.
2014 @option{flash bank lpc2000 0x0 0x40000 0 0 0 lpc2000_v1 14746 calc_checksum}),
2015 which must be specified in kilohertz. However, I do have a quartz crystal of a
2016 frequency that contains fractions of kilohertz (e.g. 14,745,600 Hz, i.e. 14,745.600 kHz).
2017 Is it possible to specify real numbers for the clock frequency?
2018
2019 No. The clock frequency specified here must be given as an integral number.
2020 However, this clock frequency is used by the In-Application-Programming (IAP)
2021 routines of the LPC2000 family only, which seems to be very tolerant concerning
2022 the given clock frequency, so a slight difference between the specified clock
2023 frequency and the actual clock frequency will not cause any trouble.
2024
2025 @item Do I have to keep a specific order for the commands in the configuration file?
2026
2027 Well, yes and no. Commands can be given in arbitrary order, yet the devices
2028 listed for the JTAG scan chain must be given in the right order (jtag_device),
2029 with the device closest to the TDO-Pin being listed first. In general,
2030 whenever objects of the same type exist which require an index number, then
2031 these objects must be given in the right order (jtag_devices, targets and flash
2032 banks - a target references a jtag_device and a flash bank references a target).
2033
2034 @item Sometimes my debugging session terminates with an error. When I look into the
2035 log file, I can see these error messages: Error: arm7_9_common.c:561
2036 arm7_9_execute_sys_speed(): timeout waiting for SYSCOMP
2037
2038 TODO.
2039
2040 @end enumerate
2041
2042 @include fdl.texi
2043
2044 @node Index
2045 @unnumbered Index
2046
2047 @printindex cp
2048
2049 @bye

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)