You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2112 lines
76 KiB

  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. @include version.texi
  11. @copying
  12. Copyright @copyright{} 2007-2008 Spen @email{spen@@spen-soft.co.uk}@*
  13. Copyright @copyright{} 2008 Oyvind Harboe @email{oyvind.harboe@@zylin.com}
  14. @quotation
  15. Permission is granted to copy, distribute and/or modify this document
  16. under the terms of the GNU Free Documentation License, Version 1.2 or
  17. any later version published by the Free Software Foundation; with no
  18. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  19. Texts. A copy of the license is included in the section entitled ``GNU
  20. Free Documentation License''.
  21. @end quotation
  22. @end copying
  23. @titlepage
  24. @title Open On-Chip Debugger (OpenOCD)
  25. @subtitle Edition @value{EDITION} for OpenOCD version @value{VERSION}
  26. @subtitle @value{UPDATED}
  27. @page
  28. @vskip 0pt plus 1filll
  29. @insertcopying
  30. @end titlepage
  31. @contents
  32. @node Top, About, , (dir)
  33. @top OpenOCD
  34. This manual documents edition @value{EDITION} of the Open On-Chip Debugger
  35. (OpenOCD) version @value{VERSION}, @value{UPDATED}.
  36. @insertcopying
  37. @menu
  38. * About:: About OpenOCD.
  39. * Developers:: OpenOCD developers
  40. * Building:: Building OpenOCD
  41. * Running:: Running OpenOCD
  42. * Configuration:: OpenOCD Configuration.
  43. * Target library:: Target library
  44. * Commands:: OpenOCD Commands
  45. * Sample Scripts:: Sample Target Scripts
  46. * GDB and OpenOCD:: Using GDB and OpenOCD
  47. * TCL and OpenOCD:: Using TCL and OpenOCD
  48. * TCL scripting API:: Tcl scripting API
  49. * Upgrading:: Deprecated/Removed Commands
  50. * FAQ:: Frequently Asked Questions
  51. * License:: GNU Free Documentation License
  52. * Index:: Main index.
  53. @end menu
  54. @node About
  55. @unnumbered About
  56. @cindex about
  57. The Open On-Chip Debugger (OpenOCD) aims to provide debugging, in-system programming
  58. and boundary-scan testing for embedded target devices. The targets are interfaced
  59. using JTAG (IEEE 1149.1) compliant hardware, but this may be extended to other
  60. connection types in the future.
  61. OpenOCD currently supports Wiggler (clones), FTDI FT2232 based JTAG interfaces, the
  62. Amontec JTAG Accelerator, and the Gateworks GW1602. It allows ARM7 (ARM7TDMI and ARM720t),
  63. ARM9 (ARM920t, ARM922t, ARM926ej--s, ARM966e--s), XScale (PXA25x, IXP42x) and
  64. Cortex-M3 (Luminary Stellaris LM3 and ST STM32) based cores to be debugged.
  65. Flash writing is supported for external CFI compatible flashes (Intel and AMD/Spansion
  66. command set) and several internal flashes (LPC2000, AT91SAM7, STR7x, STR9x, LM3
  67. and STM32x). Preliminary support for using the LPC3180's NAND flash controller is included.
  68. @node Developers
  69. @chapter Developers
  70. @cindex developers
  71. OpenOCD was created by Dominic Rath as part of a diploma thesis written at the
  72. University of Applied Sciences Augsburg (@uref{http://www.fh-augsburg.de}).
  73. Others interested in improving the state of free and open debug and testing technology
  74. are welcome to participate.
  75. Other developers have contributed support for additional targets and flashes as well
  76. as numerous bugfixes and enhancements. See the AUTHORS file for regular contributors.
  77. The main OpenOCD web site is available at @uref{http://openocd.berlios.de/web/}
  78. @node Building
  79. @chapter Building
  80. @cindex building OpenOCD
  81. If you are interested in getting actual work done rather than building
  82. OpenOCD, then check if your interface supplier provides binaries for
  83. you. Chances are that that binary is from some SVN version that is more
  84. stable than SVN trunk where bleeding edge development takes place.
  85. You can download the current SVN version with SVN client of your choice from the
  86. following repositories:
  87. (@uref{svn://svn.berlios.de/openocd/trunk})
  88. or
  89. (@uref{http://svn.berlios.de/svnroot/repos/openocd/trunk})
  90. Using the SVN command line client, you can use the following command to fetch the
  91. latest version (make sure there is no (non-svn) directory called "openocd" in the
  92. current directory):
  93. @smallexample
  94. svn checkout svn://svn.berlios.de/openocd/trunk openocd
  95. @end smallexample
  96. Building OpenOCD requires a recent version of the GNU autotools.
  97. On my build system, I'm using autoconf 2.13 and automake 1.9. For building on Windows,
  98. you have to use Cygwin. Make sure that your @env{PATH} environment variable contains no
  99. other locations with Unix utils (like UnxUtils) - these can't handle the Cygwin
  100. paths, resulting in obscure dependency errors (This is an observation I've gathered
  101. from the logs of one user - correct me if I'm wrong).
  102. You further need the appropriate driver files, if you want to build support for
  103. a FTDI FT2232 based interface:
  104. @itemize @bullet
  105. @item @b{ftdi2232} libftdi (@uref{http://www.intra2net.com/opensource/ftdi/})
  106. @item @b{ftd2xx} libftd2xx (@uref{http://www.ftdichip.com/Drivers/D2XX.htm})
  107. @item When using the Amontec JTAGkey, you have to get the drivers from the Amontec
  108. homepage (@uref{www.amontec.com}), as the JTAGkey uses a non-standard VID/PID.
  109. @end itemize
  110. libftdi is supported under windows. Versions earlier than 0.13 will require patching.
  111. see contrib/libftdi for more details.
  112. In general, the D2XX driver provides superior performance (several times as fast),
  113. but has the draw-back of being binary-only - though that isn't that bad, as it isn't
  114. a kernel module, only a user space library.
  115. To build OpenOCD (on both Linux and Cygwin), use the following commands:
  116. @smallexample
  117. ./bootstrap
  118. @end smallexample
  119. Bootstrap generates the configure script, and prepares building on your system.
  120. @smallexample
  121. ./configure
  122. @end smallexample
  123. Configure generates the Makefiles used to build OpenOCD.
  124. @smallexample
  125. make
  126. @end smallexample
  127. Make builds OpenOCD, and places the final executable in ./src/.
  128. The configure script takes several options, specifying which JTAG interfaces
  129. should be included:
  130. @itemize @bullet
  131. @item
  132. @option{--enable-parport}
  133. @item
  134. @option{--enable-parport_ppdev}
  135. @item
  136. @option{--enable-parport_giveio}
  137. @item
  138. @option{--enable-amtjtagaccel}
  139. @item
  140. @option{--enable-ft2232_ftd2xx}
  141. @footnote{Using the latest D2XX drivers from FTDI and following their installation
  142. instructions, I had to use @option{--enable-ft2232_libftd2xx} for OpenOCD to
  143. build properly.}
  144. @item
  145. @option{--enable-ft2232_libftdi}
  146. @item
  147. @option{--with-ftd2xx=/path/to/d2xx/}
  148. @item
  149. @option{--enable-gw16012}
  150. @item
  151. @option{--enable-usbprog}
  152. @item
  153. @option{--enable-presto_libftdi}
  154. @item
  155. @option{--enable-presto_ftd2xx}
  156. @item
  157. @option{--enable-jlink}
  158. @end itemize
  159. If you want to access the parallel port using the PPDEV interface you have to specify
  160. both the @option{--enable-parport} AND the @option{--enable-parport_ppdev} option since
  161. the @option{--enable-parport_ppdev} option actually is an option to the parport driver
  162. (see @uref{http://forum.sparkfun.com/viewtopic.php?t=3795} for more info).
  163. Cygwin users have to specify the location of the FTDI D2XX package. This should be an
  164. absolute path containing no spaces.
  165. Linux users should copy the various parts of the D2XX package to the appropriate
  166. locations, i.e. /usr/include, /usr/lib.
  167. Miscellaneous configure options
  168. @itemize @bullet
  169. @item
  170. @option{--enable-gccwarnings} - enable extra gcc warnings during build
  171. @end itemize
  172. @node Running
  173. @chapter Running
  174. @cindex running OpenOCD
  175. @cindex --configfile
  176. @cindex --debug_level
  177. @cindex --logfile
  178. @cindex --search
  179. OpenOCD runs as a daemon, waiting for connections from clients (Telnet, GDB, Other).
  180. Run with @option{--help} or @option{-h} to view the available command line switches.
  181. It reads its configuration by default from the file openocd.cfg located in the current
  182. working directory. This may be overwritten with the @option{-f <configfile>} command line
  183. switch. The @option{-f} command line switch can be specified multiple times, in which case the config files
  184. are executed in order.
  185. Also it is possible to interleave commands w/config scripts using the @option{-c} command line switch.
  186. To enable debug output (when reporting problems or working on OpenOCD itself), use
  187. the @option{-d} command line switch. This sets the @option{debug_level} to "3", outputting
  188. the most information, including debug messages. The default setting is "2", outputting
  189. only informational messages, warnings and errors. You can also change this setting
  190. from within a telnet or gdb session using @option{debug_level <n>} @xref{debug_level}.
  191. You can redirect all output from the daemon to a file using the @option{-l <logfile>} switch.
  192. Search paths for config/script files can be added to OpenOCD by using
  193. the @option{-s <search>} switch. The current directory and the OpenOCD target library
  194. is in the search path by default.
  195. Note! OpenOCD will launch the GDB & telnet server even if it can not establish a connection
  196. with the target. In general, it is possible for the JTAG controller to be unresponsive until
  197. the target is set up correctly via e.g. GDB monitor commands in a GDB init script.
  198. @node Configuration
  199. @chapter Configuration
  200. @cindex configuration
  201. OpenOCD runs as a daemon, and reads it current configuration
  202. by default from the file openocd.cfg in the current directory. A different configuration
  203. file can be specified with the @option{-f <conf.file>} command line switch specified when starting OpenOCD.
  204. The configuration file is used to specify on which ports the daemon listens for new
  205. connections, the JTAG interface used to connect to the target, the layout of the JTAG
  206. chain, the targets that should be debugged, and connected flashes.
  207. @section Daemon configuration
  208. @itemize @bullet
  209. @item @b{init}
  210. @*This command terminates the configuration stage and enters the normal
  211. command mode. This can be useful to add commands to the startup scripts and commands
  212. such as resetting the target, programming flash, etc. To reset the CPU upon startup,
  213. add "init" and "reset" at the end of the config script or at the end of the
  214. OpenOCD command line using the @option{-c} command line switch.
  215. @cindex init
  216. @item @b{telnet_port} <@var{number}>
  217. @cindex telnet_port
  218. @*Port on which to listen for incoming telnet connections
  219. @item @b{tcl_port} <@var{number}>
  220. @cindex tcl_port
  221. @*Port on which to listen for incoming TCL syntax. This port is intended as
  222. a simplified RPC connection that can be used by clients to issue commands
  223. and get the output from the TCL engine.
  224. @item @b{gdb_port} <@var{number}>
  225. @cindex gdb_port
  226. @*First port on which to listen for incoming GDB connections. The GDB port for the
  227. first target will be gdb_port, the second target will listen on gdb_port + 1, and so on.
  228. @item @b{gdb_breakpoint_override} <@var{hard|soft|disabled}>
  229. @cindex gdb_breakpoint_override
  230. @anchor{gdb_breakpoint_override}
  231. @*Force breakpoint type for gdb 'break' commands.
  232. The raison d'etre for this option is to support GDB GUI's without
  233. a hard/soft breakpoint concept where the default OpenOCD and
  234. GDB behaviour is not sufficient. Note that GDB will use hardware
  235. breakpoints if the memory map has been set up for flash regions.
  236. This option replaces older arm7_9 target commands that addressed
  237. the same issue.
  238. @item @b{gdb_detach} <@var{resume|reset|halt|nothing}>
  239. @cindex gdb_detach
  240. @*Configures what OpenOCD will do when gdb detaches from the daeman.
  241. Default behaviour is <@var{resume}>
  242. @item @b{gdb_memory_map} <@var{enable|disable}>
  243. @cindex gdb_memory_map
  244. @*Set to <@var{enable}> to cause OpenOCD to send the memory configuration to gdb when
  245. requested. gdb will then know when to set hardware breakpoints, and program flash
  246. using the gdb load command. @option{gdb_flash_program enable} will also need enabling
  247. for flash programming to work.
  248. Default behaviour is <@var{enable}>
  249. @xref{gdb_flash_program}.
  250. @item @b{gdb_flash_program} <@var{enable|disable}>
  251. @cindex gdb_flash_program
  252. @anchor{gdb_flash_program}
  253. @*Set to <@var{enable}> to cause OpenOCD to program the flash memory when a
  254. vFlash packet is received.
  255. Default behaviour is <@var{enable}>
  256. @end itemize
  257. @section JTAG interface configuration
  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. @itemize @minus
  296. @item @b{jlink}
  297. Segger jlink usb adapter
  298. @end itemize
  299. @end itemize
  300. @itemize @bullet
  301. @item @b{jtag_speed} <@var{reset speed}>
  302. @cindex jtag_speed
  303. @*Limit the maximum speed of the JTAG interface. Usually, a value of zero means maximum
  304. speed. The actual effect of this option depends on the JTAG interface used.
  305. The speed used during reset can be adjusted using setting jtag_speed during
  306. pre_reset and post_reset events.
  307. @itemize @minus
  308. @item wiggler: maximum speed / @var{number}
  309. @item ft2232: 6MHz / (@var{number}+1)
  310. @item amt jtagaccel: 8 / 2**@var{number}
  311. @item jlink: maximum speed in kHz (0-12000), 0 will use RTCK
  312. @end itemize
  313. Note: Make sure the jtag clock is no more than @math{1/6th × CPU-Clock}. This is
  314. especially true for synthesized cores (-S).
  315. @item @b{jtag_khz} <@var{reset speed kHz}>
  316. @cindex jtag_khz
  317. @*Same as jtag_speed, except that the speed is specified in maximum kHz. If
  318. the device can not support the rate asked for, or can not translate from
  319. kHz to jtag_speed, then an error is returned. 0 means RTCK. If RTCK
  320. is not supported, then an error is reported.
  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. [@var{combination}] is an optional value specifying broken reset signal implementations.
  328. @option{srst_pulls_trst} states that the testlogic is reset together with the reset of
  329. the system (e.g. Philips LPC2000, "broken" board layout), @option{trst_pulls_srst} says
  330. that the system is reset together with the test logic (only hypothetical, I haven't
  331. seen hardware with such a bug, and can be worked around).
  332. @option{combined} imples both @option{srst_pulls_trst} and @option{trst_pulls_srst}.
  333. The default behaviour if no option given is @option{separate}.
  334. The [@var{trst_type}] and [@var{srst_type}] parameters allow the driver type of the
  335. reset lines to be specified. Possible values are @option{trst_push_pull} (default)
  336. and @option{trst_open_drain} for the test reset signal, and @option{srst_open_drain}
  337. (default) and @option{srst_push_pull} for the system reset. These values only affect
  338. JTAG interfaces with support for different drivers, like the Amontec JTAGkey and JTAGAccelerator.
  339. @item @b{jtag_device} <@var{IR length}> <@var{IR capture}> <@var{IR mask}> <@var{IDCODE instruction}>
  340. @cindex jtag_device
  341. @*Describes the devices that form the JTAG daisy chain, with the first device being
  342. the one closest to TDO. The parameters are the length of the instruction register
  343. (4 for all ARM7/9s), the value captured during Capture-IR (0x1 for ARM7/9), and a mask
  344. of bits that should be validated when doing IR scans (all four bits (0xf) for ARM7/9).
  345. The IDCODE instruction will in future be used to query devices for their JTAG
  346. identification code. This line is the same for all ARM7 and ARM9 devices.
  347. Other devices, like CPLDs, require different parameters. An example configuration
  348. line for a Xilinx XC9500 CPLD would look like this:
  349. @smallexample
  350. jtag_device 8 0x01 0x0e3 0xfe
  351. @end smallexample
  352. The instruction register (IR) is 8 bits long, during Capture-IR 0x01 is loaded into
  353. the IR, but only bits 0-1 and 5-7 should be checked, the others (2-4) might vary.
  354. The IDCODE instruction is 0xfe.
  355. @item @b{jtag_nsrst_delay} <@var{ms}>
  356. @cindex jtag_nsrst_delay
  357. @*How long (in milliseconds) OpenOCD should wait after deasserting nSRST before
  358. starting new JTAG operations.
  359. @item @b{jtag_ntrst_delay} <@var{ms}>
  360. @cindex jtag_ntrst_delay
  361. @*Same @b{jtag_nsrst_delay}, but for nTRST
  362. The jtag_n[st]rst_delay options are useful if reset circuitry (like a reset supervisor,
  363. or on-chip features) keep a reset line asserted for some time after the external reset
  364. got deasserted.
  365. @end itemize
  366. @section parport options
  367. @itemize @bullet
  368. @item @b{parport_port} <@var{number}>
  369. @cindex parport_port
  370. @*Either the address of the I/O port (default: 0x378 for LPT1) or the number of
  371. the @file{/dev/parport} device
  372. When using PPDEV to access the parallel port, use the number of the parallel port:
  373. @option{parport_port 0} (the default). If @option{parport_port 0x378} is specified
  374. you may encounter a problem.
  375. @item @b{parport_cable} <@var{name}>
  376. @cindex parport_cable
  377. @*The layout of the parallel port cable used to connect to the target.
  378. Currently supported cables are
  379. @itemize @minus
  380. @item @b{wiggler}
  381. @cindex wiggler
  382. The original Wiggler layout, also supported by several clones, such
  383. as the Olimex ARM-JTAG
  384. @item @b{wiggler2}
  385. @cindex wiggler2
  386. Same as original wiggler except an led is fitted on D5.
  387. @item @b{wiggler_ntrst_inverted}
  388. @cindex wiggler_ntrst_inverted
  389. Same as original wiggler except TRST is inverted.
  390. @item @b{old_amt_wiggler}
  391. @cindex old_amt_wiggler
  392. The Wiggler configuration that comes with Amontec's Chameleon Programmer. The new
  393. version available from the website uses the original Wiggler layout ('@var{wiggler}')
  394. @item @b{chameleon}
  395. @cindex chameleon
  396. The Amontec Chameleon's CPLD when operated in configuration mode. This is only used to
  397. program the Chameleon itself, not a connected target.
  398. @item @b{dlc5}
  399. @cindex dlc5
  400. The Xilinx Parallel cable III.
  401. @item @b{triton}
  402. @cindex triton
  403. The parallel port adapter found on the 'Karo Triton 1 Development Board'.
  404. This is also the layout used by the HollyGates design
  405. (see @uref{http://www.lartmaker.nl/projects/jtag/}).
  406. @item @b{flashlink}
  407. @cindex flashlink
  408. The ST Parallel cable.
  409. @item @b{arm-jtag}
  410. @cindex arm-jtag
  411. Same as original wiggler except SRST and TRST connections reversed and
  412. TRST is also inverted.
  413. @item @b{altium}
  414. @cindex altium
  415. Altium Universal JTAG cable.
  416. @end itemize
  417. @item @b{parport_write_on_exit} <@var{on|off}>
  418. @cindex parport_write_on_exit
  419. @*This will configure the parallel driver to write a known value to the parallel
  420. interface on exiting OpenOCD
  421. @end itemize
  422. @section amt_jtagaccel options
  423. @itemize @bullet
  424. @item @b{parport_port} <@var{number}>
  425. @cindex parport_port
  426. @*Either the address of the I/O port (default: 0x378 for LPT1) or the number of the
  427. @file{/dev/parport} device
  428. @end itemize
  429. @section ft2232 options
  430. @itemize @bullet
  431. @item @b{ft2232_device_desc} <@var{description}>
  432. @cindex ft2232_device_desc
  433. @*The USB device description of the FTDI FT2232 device. If not specified, the FTDI
  434. default value is used. This setting is only valid if compiled with FTD2XX support.
  435. @item @b{ft2232_layout} <@var{name}>
  436. @cindex ft2232_layout
  437. @*The layout of the FT2232 GPIO signals used to control output-enables and reset
  438. signals. Valid layouts are
  439. @itemize @minus
  440. @item @b{usbjtag}
  441. "USBJTAG-1" layout described in the original OpenOCD diploma thesis
  442. @item @b{jtagkey}
  443. Amontec JTAGkey and JTAGkey-tiny
  444. @item @b{signalyzer}
  445. Signalyzer
  446. @item @b{olimex-jtag}
  447. Olimex ARM-USB-OCD
  448. @item @b{m5960}
  449. American Microsystems M5960
  450. @item @b{evb_lm3s811}
  451. Luminary Micro EVB_LM3S811 as a JTAG interface (not onboard processor), no TRST or
  452. SRST signals on external connector
  453. @item @b{comstick}
  454. Hitex STR9 comstick
  455. @item @b{stm32stick}
  456. Hitex STM32 Performance Stick
  457. @item @b{flyswatter}
  458. Tin Can Tools Flyswatter
  459. @item @b{turtelizer2}
  460. egnite Software turtelizer2
  461. @item @b{oocdlink}
  462. OOCDLink
  463. @end itemize
  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. Multiple <@var{vid}>, <@var{pid}> pairs may be given, eg.
  467. @smallexample
  468. ft2232_vid_pid 0x0403 0xcff8 0x15ba 0x0003
  469. @end smallexample
  470. @item @b{ft2232_latency} <@var{ms}>
  471. @*On some systems using ft2232 based JTAG interfaces the FT_Read function call in
  472. ft2232_read() fails to return the expected number of bytes. This can be caused by
  473. USB communication delays and has proved hard to reproduce and debug. Setting the
  474. FT2232 latency timer to a larger value increases delays for short USB packages but it
  475. also reduces the risk of timeouts before receiving the expected number of bytes.
  476. The OpenOCD default value is 2 and for some systems a value of 10 has proved useful.
  477. @end itemize
  478. @section ep93xx options
  479. @cindex ep93xx options
  480. Currently, there are no options available for the ep93xx interface.
  481. @page
  482. @section Target configuration
  483. @itemize @bullet
  484. @item @b{target} <@var{type}> <@var{endianess}> <@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. @item @b{mips_m4k}
  500. @end itemize
  501. If you want to use a target board that is not on this list, see Adding a new
  502. target board
  503. Endianess may be @option{little} or @option{big}.
  504. @item @b{target_script} <@var{target#}> <@var{event}> <@var{script_file}>
  505. @cindex target_script
  506. @*Event is one of the following:
  507. @option{pre_reset}, @option{reset}, @option{post_reset}, @option{post_halt},
  508. @option{pre_resume} or @option{gdb_program_config}.
  509. @option{post_reset} and @option{reset} will produce the same results.
  510. @item @b{working_area} <@var{target#}> <@var{address}> <@var{size}>
  511. <@var{backup}|@var{nobackup}>
  512. @cindex working_area
  513. @*Specifies a working area for the debugger to use. This may be used to speed-up
  514. downloads to target memory and flash operations, or to perform otherwise unavailable
  515. operations (some coprocessor operations on ARM7/9 systems, for example). The last
  516. parameter decides whether the memory should be preserved (<@var{backup}>) or can simply be overwritten (<@var{nobackup}>). If possible, use
  517. a working_area that doesn't need to be backed up, as performing a backup slows down operation.
  518. @end itemize
  519. @subsection arm7tdmi options
  520. @cindex arm7tdmi options
  521. target arm7tdmi <@var{endianess}> <@var{jtag#}>
  522. @*The arm7tdmi target definition requires at least one additional argument, specifying
  523. the position of the target in the JTAG daisy-chain. The first JTAG device is number 0.
  524. The optional [@var{variant}] parameter has been removed in recent versions.
  525. The correct feature set is determined at runtime.
  526. @subsection arm720t options
  527. @cindex arm720t options
  528. ARM720t options are similar to ARM7TDMI options.
  529. @subsection arm9tdmi options
  530. @cindex arm9tdmi options
  531. ARM9TDMI options are similar to ARM7TDMI options. Supported variants are
  532. @option{arm920t}, @option{arm922t} and @option{arm940t}.
  533. This enables the hardware single-stepping support found on these cores.
  534. @subsection arm920t options
  535. @cindex arm920t options
  536. ARM920t options are similar to ARM9TDMI options.
  537. @subsection arm966e options
  538. @cindex arm966e options
  539. ARM966e options are similar to ARM9TDMI options.
  540. @subsection cortex_m3 options
  541. @cindex cortex_m3 options
  542. use variant <@var{variant}> @option{lm3s} when debugging luminary lm3s targets. This will cause
  543. openocd to use a software reset rather than asserting SRST to avoid a issue with clearing
  544. the debug registers. This is fixed in Fury Rev B, DustDevil Rev B, Tempest, these revisions will
  545. be detected and the normal reset behaviour used.
  546. @subsection xscale options
  547. @cindex xscale options
  548. Supported variants are @option{ixp42x}, @option{ixp45x}, @option{ixp46x},
  549. @option{pxa250}, @option{pxa255}, @option{pxa26x}.
  550. @section Flash configuration
  551. @cindex Flash configuration
  552. @itemize @bullet
  553. @item @b{flash bank} <@var{driver}> <@var{base}> <@var{size}> <@var{chip_width}>
  554. <@var{bus_width}> <@var{target#}> [@var{driver_options ...}]
  555. @cindex flash bank
  556. @*Configures a flash bank at <@var{base}> of <@var{size}> bytes and <@var{chip_width}>
  557. and <@var{bus_width}> bytes using the selected flash <driver>.
  558. @end itemize
  559. @subsection lpc2000 options
  560. @cindex lpc2000 options
  561. @b{flash bank lpc2000} <@var{base}> <@var{size}> 0 0 <@var{target#}> <@var{variant}>
  562. <@var{clock}> [@var{calc_checksum}]
  563. @*LPC flashes don't require the chip and bus width to be specified. Additional
  564. parameters are the <@var{variant}>, which may be @var{lpc2000_v1} (older LPC21xx and LPC22xx)
  565. or @var{lpc2000_v2} (LPC213x, LPC214x, LPC210[123], LPC23xx and LPC24xx), the number
  566. of the target this flash belongs to (first is 0), the frequency at which the core
  567. is currently running (in kHz - must be an integral number), and the optional keyword
  568. @var{calc_checksum}, telling the driver to calculate a valid checksum for the exception
  569. vector table.
  570. @subsection cfi options
  571. @cindex cfi options
  572. @b{flash bank cfi} <@var{base}> <@var{size}> <@var{chip_width}> <@var{bus_width}>
  573. <@var{target#}> [@var{jedec_probe}|@var{x16_as_x8}]
  574. @*CFI flashes require the number of the target they're connected to as an additional
  575. argument. The CFI driver makes use of a working area (specified for the target)
  576. to significantly speed up operation.
  577. @var{chip_width} and @var{bus_width} are specified in bytes.
  578. The @var{jedec_probe} option is used to detect certain non-CFI flash roms, like AM29LV010 and similar types.
  579. @var{x16_as_x8} ???
  580. @subsection at91sam7 options
  581. @cindex at91sam7 options
  582. @b{flash bank at91sam7} 0 0 0 0 <@var{target#}>
  583. @*AT91SAM7 flashes only require the @var{target#}, all other values are looked up after
  584. reading the chip-id and type.
  585. @subsection str7 options
  586. @cindex str7 options
  587. @b{flash bank str7x} <@var{base}> <@var{size}> 0 0 <@var{target#}> <@var{variant}>
  588. @*variant can be either STR71x, STR73x or STR75x.
  589. @subsection str9 options
  590. @cindex str9 options
  591. @b{flash bank str9x} <@var{base}> <@var{size}> 0 0 <@var{target#}>
  592. @*The str9 needs the flash controller to be configured prior to Flash programming, eg.
  593. @smallexample
  594. str9x flash_config 0 4 2 0 0x80000
  595. @end smallexample
  596. This will setup the BBSR, NBBSR, BBADR and NBBADR registers respectively.
  597. @subsection str9 options (str9xpec driver)
  598. @b{flash bank str9xpec} <@var{base}> <@var{size}> 0 0 <@var{target#}>
  599. @*Before using the flash commands the turbo mode will need enabling using str9xpec
  600. @option{enable_turbo} <@var{num>.}
  601. Only use this driver for locking/unlocking the device or configuring the option bytes.
  602. Use the standard str9 driver for programming.
  603. @subsection stellaris (LM3Sxxx) options
  604. @cindex stellaris (LM3Sxxx) options
  605. @b{flash bank stellaris} <@var{base}> <@var{size}> 0 0 <@var{target#}>
  606. @*stellaris flash plugin only require the @var{target#}.
  607. @subsection stm32x options
  608. @cindex stm32x options
  609. @b{flash bank stm32x} <@var{base}> <@var{size}> 0 0 <@var{target#}>
  610. @*stm32x flash plugin only require the @var{target#}.
  611. @subsection aduc702x options
  612. @cindex aduc702x options
  613. @b{flash bank aduc702x} <@var{base}> <@var{size}> 0 0 <@var{target#}>
  614. @*aduc702x flash plugin require the flash @var{base}, @var{size} and @var{target#}.
  615. @section mFlash configuration
  616. @cindex mFlash configuration
  617. @itemize @bullet
  618. @item @b{mflash bank} <@var{soc}> <@var{base}> <@var{chip_width}> <@var{bus_width}>
  619. <@var{RST pin}> <@var{WP pin}> <@var{DPD pin}> <@var{target #}>
  620. @cindex mflash bank
  621. @*Configures a mflash for <@var{soc}> host bank at <@var{base}>. <@var{chip_width}> and
  622. <@var{bus_width}> are bytes order. Pin number format is dependent on host GPIO calling convention.
  623. If WP or DPD pin was not used, write -1. Currently, mflash bank support s3c2440 and pxa270.
  624. @end itemize
  625. (ex. of s3c2440) mflash <@var{RST pin}> is GPIO B1, <@var{WP pin}> and <@var{DPD pin}> are not used.
  626. @smallexample
  627. mflash bank s3c2440 0x10000000 2 2 1b -1 -1 0
  628. @end smallexample
  629. (ex. of pxa270) mflash <@var{RST pin}> is GPIO 43, <@var{DPD pin}> is not used and <@var{DPD pin}> is GPIO 51.
  630. @smallexample
  631. mflash bank pxa270 0x08000000 2 2 43 -1 51 0
  632. @end smallexample
  633. @node Target library
  634. @chapter Target library
  635. @cindex Target library
  636. OpenOCD comes with a target configuration script library. These scripts can be
  637. used as-is or serve as a starting point.
  638. The target library is published together with the openocd executable and
  639. the path to the target library is in the OpenOCD script search path.
  640. Similarly there are example scripts for configuring the JTAG interface.
  641. The command line below uses the example parport configuration scripts
  642. that ship with OpenOCD, then configures the str710.cfg target and
  643. finally issues the init and reset command. The communication speed
  644. is set to 10kHz for reset and 8MHz for post reset.
  645. @smallexample
  646. openocd -f interface/parport.cfg -f target/str710.cfg -c "init" -c "reset"
  647. @end smallexample
  648. To list the target scripts available:
  649. @smallexample
  650. $ ls /usr/local/lib/openocd/target
  651. arm7_fast.cfg lm3s6965.cfg pxa255.cfg stm32.cfg xba_revA3.cfg
  652. at91eb40a.cfg lpc2148.cfg pxa255_sst.cfg str710.cfg zy1000.cfg
  653. at91r40008.cfg lpc2294.cfg sam7s256.cfg str912.cfg
  654. at91sam9260.cfg nslu2.cfg sam7x256.cfg wi-9c.cfg
  655. @end smallexample
  656. @node Commands
  657. @chapter Commands
  658. @cindex commands
  659. OpenOCD allows user interaction through a GDB server (default: port 3333),
  660. a telnet interface (default: port 4444), and a TCL interface (default: port 5555). The command line interpreter
  661. is available from both the telnet interface and a GDB session. To issue commands to the
  662. interpreter from within a GDB session, use the @option{monitor} command, e.g. use
  663. @option{monitor poll} to issue the @option{poll} command. All output is relayed through the
  664. GDB session.
  665. The TCL interface is used as a simplified RPC mechanism that feeds all the
  666. input into the TCL interpreter and returns the output from the evaluation of
  667. the commands.
  668. @section Daemon
  669. @itemize @bullet
  670. @item @b{sleep} <@var{msec}>
  671. @cindex sleep
  672. @*Wait for n milliseconds before resuming. Useful in connection with script files
  673. (@var{script} command and @var{target_script} configuration).
  674. @item @b{shutdown}
  675. @cindex shutdown
  676. @*Close the OpenOCD daemon, disconnecting all clients (GDB, Telnet, Other).
  677. @item @b{debug_level} [@var{n}]
  678. @cindex debug_level
  679. @anchor{debug_level}
  680. @*Display or adjust debug level to n<0-3>
  681. @item @b{fast} [@var{enable|disable}]
  682. @cindex fast
  683. @*Default disabled. Set default behaviour of OpenOCD to be "fast and dangerous". For instance ARM7/9 DCC memory
  684. downloads and fast memory access will work if the JTAG interface isn't too fast and
  685. the core doesn't run at a too low frequency. Note that this option only changes the default
  686. and that the indvidual options, like DCC memory downloads, can be enabled and disabled
  687. individually.
  688. The target specific "dangerous" optimisation tweaking options may come and go
  689. as more robust and user friendly ways are found to ensure maximum throughput
  690. and robustness with a minimum of configuration.
  691. Typically the "fast enable" is specified first on the command line:
  692. @smallexample
  693. openocd -c "fast enable" -c "interface dummy" -f target/str710.cfg
  694. @end smallexample
  695. @item @b{log_output} <@var{file}>
  696. @cindex log_output
  697. @*Redirect logging to <file> (default: stderr)
  698. @item @b{script} <@var{file}>
  699. @cindex script
  700. @*Execute commands from <file>
  701. @end itemize
  702. @subsection Target state handling
  703. @itemize @bullet
  704. @item @b{poll} [@option{on}|@option{off}]
  705. @cindex poll
  706. @*Poll the target for its current state. If the target is in debug mode, architecture
  707. specific information about the current state is printed. An optional parameter
  708. allows continuous polling to be enabled and disabled.
  709. @item @b{halt} [@option{ms}]
  710. @cindex halt
  711. @*Send a halt request to the target and wait for it to halt for up to [@option{ms}] milliseconds.
  712. Default [@option{ms}] is 5 seconds if no arg given.
  713. Optional arg @option{ms} is a timeout in milliseconds. Using 0 as the [@option{ms}]
  714. will stop OpenOCD from waiting.
  715. @item @b{wait_halt} [@option{ms}]
  716. @cindex wait_halt
  717. @*Wait for the target to enter debug mode. Optional [@option{ms}] is
  718. a timeout in milliseconds. Default [@option{ms}] is 5 seconds if no
  719. arg given.
  720. @item @b{resume} [@var{address}]
  721. @cindex resume
  722. @*Resume the target at its current code position, or at an optional address.
  723. OpenOCD will wait 5 seconds for the target to resume.
  724. @item @b{step} [@var{address}]
  725. @cindex step
  726. @*Single-step the target at its current code position, or at an optional address.
  727. @item @b{reset} [@option{run}|@option{halt}|@option{init}]
  728. @cindex reset
  729. @*Perform a hard-reset. The optional parameter specifies what should happen after the reset.
  730. With no arguments a "reset run" is executed
  731. @itemize @minus
  732. @item @b{run}
  733. @cindex reset run
  734. @*Let the target run.
  735. @item @b{halt}
  736. @cindex reset halt
  737. @*Immediately halt the target (works only with certain configurations).
  738. @item @b{init}
  739. @cindex reset init
  740. @*Immediately halt the target, and execute the reset script (works only with certain
  741. configurations)
  742. @end itemize
  743. @end itemize
  744. @subsection Memory access commands
  745. These commands allow accesses of a specific size to the memory system:
  746. @itemize @bullet
  747. @item @b{mdw} <@var{addr}> [@var{count}]
  748. @cindex mdw
  749. @*display memory words
  750. @item @b{mdh} <@var{addr}> [@var{count}]
  751. @cindex mdh
  752. @*display memory half-words
  753. @item @b{mdb} <@var{addr}> [@var{count}]
  754. @cindex mdb
  755. @*display memory bytes
  756. @item @b{mww} <@var{addr}> <@var{value}>
  757. @cindex mww
  758. @*write memory word
  759. @item @b{mwh} <@var{addr}> <@var{value}>
  760. @cindex mwh
  761. @*write memory half-word
  762. @item @b{mwb} <@var{addr}> <@var{value}>
  763. @cindex mwb
  764. @*write memory byte
  765. @item @b{load_image} <@var{file}> <@var{address}> [@option{bin}|@option{ihex}|@option{elf}]
  766. @cindex load_image
  767. @anchor{load_image}
  768. @*Load image <@var{file}> to target memory at <@var{address}>
  769. @item @b{dump_image} <@var{file}> <@var{address}> <@var{size}>
  770. @cindex dump_image
  771. @anchor{dump_image}
  772. @*Dump <@var{size}> bytes of target memory starting at <@var{address}> to a
  773. (binary) <@var{file}>.
  774. @item @b{verify_image} <@var{file}> <@var{address}> [@option{bin}|@option{ihex}|@option{elf}]
  775. @cindex verify_image
  776. @*Verify <@var{file}> against target memory starting at <@var{address}>.
  777. This will first attempt comparison using a crc checksum, if this fails it will try a binary compare.
  778. @end itemize
  779. @subsection Flash commands
  780. @cindex Flash commands
  781. @itemize @bullet
  782. @item @b{flash banks}
  783. @cindex flash banks
  784. @*List configured flash banks
  785. @item @b{flash info} <@var{num}>
  786. @cindex flash info
  787. @*Print info about flash bank <@option{num}>
  788. @item @b{flash probe} <@var{num}>
  789. @cindex flash probe
  790. @*Identify the flash, or validate the parameters of the configured flash. Operation
  791. depends on the flash type.
  792. @item @b{flash erase_check} <@var{num}>
  793. @cindex flash erase_check
  794. @*Check erase state of sectors in flash bank <@var{num}>. This is the only operation that
  795. updates the erase state information displayed by @option{flash info}. That means you have
  796. to issue an @option{erase_check} command after erasing or programming the device to get
  797. updated information.
  798. @item @b{flash protect_check} <@var{num}>
  799. @cindex flash protect_check
  800. @*Check protection state of sectors in flash bank <num>.
  801. @option{flash erase_sector} using the same syntax.
  802. @item @b{flash erase_sector} <@var{num}> <@var{first}> <@var{last}>
  803. @cindex flash erase_sector
  804. @anchor{flash erase_sector}
  805. @*Erase sectors at bank <@var{num}>, starting at sector <@var{first}> up to and including
  806. <@var{last}>. Sector numbering starts at 0. Depending on the flash type, erasing may
  807. require the protection to be disabled first (e.g. Intel Advanced Bootblock flash using
  808. the CFI driver).
  809. @item @b{flash erase_address} <@var{address}> <@var{length}>
  810. @cindex flash erase_address
  811. @*Erase sectors starting at <@var{address}> for <@var{length}> bytes
  812. @item @b{flash write_bank} <@var{num}> <@var{file}> <@var{offset}>
  813. @cindex flash write_bank
  814. @anchor{flash write_bank}
  815. @*Write the binary <@var{file}> to flash bank <@var{num}>, starting at
  816. <@option{offset}> bytes from the beginning of the bank.
  817. @item @b{flash write_image} [@var{erase}] <@var{file}> [@var{offset}] [@var{type}]
  818. @cindex flash write_image
  819. @anchor{flash write_image}
  820. @*Write the image <@var{file}> to the current target's flash bank(s). A relocation
  821. [@var{offset}] can be specified and the file [@var{type}] can be specified
  822. explicitly as @option{bin} (binary), @option{ihex} (Intel hex), @option{elf}
  823. (ELF file) or @option{s19} (Motorola s19). Flash memory will be erased prior to programming
  824. if the @option{erase} parameter is given.
  825. @item @b{flash protect} <@var{num}> <@var{first}> <@var{last}> <@option{on}|@option{off}>
  826. @cindex flash protect
  827. @*Enable (@var{on}) or disable (@var{off}) protection of flash sectors <@var{first}> to
  828. <@var{last}> of @option{flash bank} <@var{num}>.
  829. @end itemize
  830. @subsection mFlash commands
  831. @cindex mFlash commands
  832. @itemize @bullet
  833. @item @b{mflash probe}
  834. @cindex mflash probe
  835. Probe mflash.
  836. @item @b{mflash write} <@var{num}> <@var{file}> <@var{offset}>
  837. @cindex mflash write
  838. Write the binary <@var{file}> to mflash bank <@var{num}>, starting at
  839. <@var{offset}> bytes from the beginning of the bank.
  840. @item @b{mflash dump} <@var{num}> <@var{file}> <@var{offset}> <@var{size}>
  841. @cindex mflash dump
  842. Dump <size> bytes, starting at <@var{offset}> bytes from the beginning of the <@var{num}> bank
  843. to a <@var{file}>.
  844. @end itemize
  845. @page
  846. @section Target Commands
  847. @cindex Target Commands
  848. @subsection Overview
  849. @cindex Overview
  850. Pre "TCL" - many commands in OpenOCD where implemented as C functions. Post "TCL"
  851. (Jim-Tcl to be more exact, June 2008) TCL became a bigger part of OpenOCD.
  852. One of the biggest changes is the introduction of 'target specific'
  853. commands. When every time you create a target, a special command name is
  854. created specifically for that target.
  855. For example - in TCL/TK - if you create a button (or any other screen object) you
  856. can specify various "button configuration parameters". One of those parameters is
  857. the "object cmd/name" [ In TK - this is referred to as the object path ]. Later
  858. you can use that 'path' as a command to modify the button, for example to make it
  859. "grey", or change the color. In effect, the "path" function is an 'object
  860. oriented command'. The TCL change in OpenOCD follows the same principle, you create
  861. a target, and a specific "targetname" command is created.
  862. There are two methods of creating a target:
  863. @enumerate
  864. @item
  865. Using the old syntax (deprecated). Target names are autogenerated as:
  866. "target0", "target1", etc.;
  867. @cindex old syntax
  868. @item
  869. Using the new syntax, you can specify the name of the target.
  870. @cindex new syntax
  871. @end enumerate
  872. As most users will have a single JTAG target, and by default the command name will
  873. probably default to "target0", thus for reasons of simplicity the instructions below
  874. use the name "target0".
  875. @subsection Commands
  876. @cindex Commands
  877. OpenOCD has the following 'target' or 'target-like' commands:
  878. @enumerate
  879. @item
  880. @b{targets (plural)} - lists all known targets and a little bit of information about each
  881. target, most importantly the target *COMMAND*NAME* (it also lists the target number);
  882. @cindex targets
  883. @item
  884. @b{target (singular)} - used to create, configure list, etc the targets;
  885. @cindex target
  886. @item
  887. @b{target0} - the command object for the first target. Unless you specified another name.
  888. @cindex target0
  889. @end enumerate
  890. @subsubsection Targets Command
  891. @cindex Targets Command
  892. The "targets" command has 2 functions:
  893. @itemize
  894. @item
  895. With a parameter, you can change the current command line target.
  896. NOTE: "with a parameter" is really only useful with 'multiple JTAG targets' not something
  897. you normally encounter (ie: If you had 2 arm chips - sharing the same JTAG chain).
  898. @verbatim
  899. # using a target name.
  900. (gdb) mon targets target0
  901. # or a target by number.
  902. (gdb) mon targets 3
  903. @end verbatim
  904. @cindex with a parameter
  905. @item
  906. Plain, without any parameter lists targets, for example:
  907. @verbatim
  908. (gdb) mon targets
  909. CmdName Type Endian ChainPos State
  910. -- ---------- ---------- ---------- -------- ----------
  911. 0: target0 arm7tdmi little 0 halted
  912. @end verbatim
  913. This shows:
  914. @enumerate a
  915. @item
  916. in this example, a single target;
  917. @item
  918. target number 0 (1st column);
  919. @item
  920. the 'object name' is target0 (the default name);
  921. @item
  922. it is an arm7tdmi;
  923. @item
  924. little endian;
  925. @item
  926. the position in the JTAG chain;
  927. @item
  928. and is currently halted.
  929. @end enumerate
  930. @cindex without any parameter
  931. @end itemize
  932. @subsubsection Target Command
  933. @cindex Target Command
  934. The "target" command has the following options:
  935. @itemize
  936. @item
  937. target create
  938. @verbatim
  939. target create CMDNAME TYPE ... config options ...
  940. argv[0] = 'target'
  941. argv[1] = 'create'
  942. argv[2] = the 'object command'
  943. (normally, target0, see (3) above)
  944. argv[3] = the target type, ie: arm7tdmi
  945. argv[4..N] = configuration parameters
  946. @end verbatim
  947. @item
  948. target types
  949. Lists all supported target types; ie: arm7tdmi, xscale, fericon, cortex-m3.
  950. The result TCL list of all known target types (and is human readable).
  951. @item
  952. target names
  953. Returns a TCL list of all known target commands (and is human readable).
  954. Example:
  955. @verbatim
  956. foreach t [target names] {
  957. puts [format "Target: %s\n" $t]
  958. }
  959. @end verbatim
  960. @item
  961. target current
  962. Returns the TCL command name of the current target.
  963. Example:
  964. @verbatim
  965. set ct [target current]
  966. set t [$ct cget -type]
  967. puts "Current target name is: $ct, and is a: $t"
  968. @end verbatim
  969. @item
  970. target number <VALUE>
  971. Returns the TCL command name of the specified target.
  972. Example
  973. @verbatim
  974. set thename [target number $x]
  975. puts [format "Target %d is: %s\n" $x $thename]
  976. @end verbatim
  977. For instance, assuming the defaults
  978. @verbatim
  979. target number 0
  980. @end verbatim
  981. Would return 'target0' (or whatever you called it)
  982. @item
  983. target count
  984. Returns the larget+1 target number.
  985. Example:
  986. @verbatim
  987. set c [target count]
  988. for { set x 0 } { $x < $c } { incr x } {
  989. # Assuming you have this function..
  990. print_target_details $x
  991. }
  992. @end verbatim
  993. @end itemize
  994. @subsubsection Target0 Command
  995. @cindex Target0 Command
  996. The "target0" command (the "Target Object" command):
  997. Once a target is 'created' a command object by that targets name is created, for example
  998. @verbatim
  999. target create BiGRed arm7tdmi -endian little -chain-position 3
  1000. @end verbatim
  1001. Would create a [case sensitive] "command" BiGRed
  1002. If you use the old [deprecated] syntax, the name is automatically
  1003. generated and is in the form:
  1004. @verbatim
  1005. target0, target1, target2, target3, ... etc.
  1006. @end verbatim
  1007. @subsubsection Target CREATE, CONFIGURE and CGET Options Command
  1008. @cindex Target CREATE, CONFIGURE and CGET Options Command
  1009. The commands:
  1010. @verbatim
  1011. target create CMDNAME TYPE [configure-options]
  1012. CMDNAME configure [configure-options]
  1013. CMDNAME cget [configure-options]
  1014. @end verbatim
  1015. @itemize
  1016. @item
  1017. In the 'create' case, one is creating the target and can specify any
  1018. number of configuration parameters.
  1019. @item
  1020. In the 'CMDNAME configure' case, one can change the setting [Not all things can, or should be changed].
  1021. @item
  1022. In the 'CMDNAME cget' case, the goal is to query the target for a
  1023. specific configuration option.
  1024. @end itemize
  1025. In the above, the "default" name target0 is 'target0'.
  1026. Example:
  1027. From the (gdb) prompt, one can type this:
  1028. @verbatim
  1029. (gdb) mon target0 configure -endian big
  1030. @end verbatim
  1031. And change target0 to 'big-endian'. This is a contrived example,
  1032. specifically for this document - don't expect changing endian
  1033. 'mid-operation' to work you should set the endian at creation.
  1034. Known options [30/august/2008] are:
  1035. @itemize
  1036. @item
  1037. [Mandatory 'create' Options]
  1038. @itemize
  1039. @item
  1040. type arm7tdmi|arm720|etc ...
  1041. @item
  1042. chain-position NUMBER
  1043. @item
  1044. endian ENDIAN
  1045. @end itemize
  1046. @item
  1047. Optional
  1048. @itemize
  1049. @item
  1050. event EVENTNAME "tcl-action"
  1051. @item
  1052. reset RESETACTION
  1053. @item
  1054. work-area-virt ADDR
  1055. @item
  1056. work-area-phys ADDR
  1057. @item
  1058. work-area-size ADDR
  1059. @item
  1060. work-area-backup BOOLEAN
  1061. @end itemize
  1062. @end itemize
  1063. Hint: To get a list of available options, try this:
  1064. @verbatim
  1065. (gdb) mon target0 cget -BLAHBLAHBLAH
  1066. @end verbatim
  1067. the above causes an error - and a helpful list of valid options.
  1068. One can query any of the above options at run time, for example:
  1069. @verbatim
  1070. (gdb) mon target0 cget -OPTION [param]
  1071. @end verbatim
  1072. Example TCL script
  1073. @verbatim
  1074. # For all targets...
  1075. set c [target count]
  1076. for { set x 0 } { $x < $c } { incr x ] {
  1077. set n [target number $x]
  1078. set t [$n cget -type]
  1079. set e [$n cget -endian]
  1080. puts [format "%d: %s, %s, endian: %s\n" $x $n $t $n]
  1081. }
  1082. @end verbatim
  1083. Might produce:
  1084. @verbatim
  1085. 0: pic32chip, mips_m4k, endain: little
  1086. 1: arm7, arm7tdmi, endian: big
  1087. 2: blackfin, bf534, endian: little
  1088. @end verbatim
  1089. Notice the above example is not target0, target1, target2 Why? Because in this contrived multi-target example -
  1090. more human understandable target names might be helpful.
  1091. For example these two are the same:
  1092. @verbatim
  1093. (gdb) mon blackfin configure -event FOO {puts "Hi mom"}
  1094. @end verbatim
  1095. or:
  1096. @verbatim
  1097. (gdb) mon [target number 2] configure -event FOO {puts "Hi mom"}
  1098. @end verbatim
  1099. In the second case, we use [] to get the command name of target #2, in this contrived example - it is "blackfin".
  1100. Two important configuration options are:
  1101. "-event" and "-reset"
  1102. The "-reset" option specifies what should happen when the chip is reset, for example should it 'halt', 're-init',
  1103. or what.
  1104. The "-event" option less you specify a TCL command to occur when a specific event occurs.
  1105. @subsection Target Events
  1106. @cindex Target Events
  1107. @subsubsection Overview
  1108. @cindex Overview
  1109. At various points in time - certain 'target' events happen. You can create a custom event action to occur at that time.
  1110. For example - after reset, the PLLs and CLOCKs may need to be reconfigured, or perhaps the SDRAM needs to be re-initialized.
  1111. Often the easiest way to do that is to create a simple script file containing the series of (mww [poke memory]) commands
  1112. you would type by hand, to reconfigure the target clocks. You could specify the "event action" like this:
  1113. @verbatim
  1114. (gdb) mon target0 configure -event reset-init "script cfg.clocks"
  1115. @end verbatim
  1116. In the above example, when the event "reset-init" occurs, the "action-string" will be evaluated as if you typed it at the
  1117. console:
  1118. @itemize
  1119. @item @b{Option1} - The simple approach (above) is to create a script file with lots of "mww" (memory write word) commands
  1120. to configure your targets clocks and/or external memory;
  1121. @item @b{Option2} - You can instead create a fancy TCL procedure and invoke that procedure instead of sourcing a file [In fact,
  1122. "script" is a TCL procedure that loads a file].
  1123. @end itemize
  1124. @subsubsection Details
  1125. @cindex Details
  1126. There are many events one could use, to get a current list of events type the following invalid command, you'll get a helpful
  1127. "runtime error" message, see below [list valid as of 30/august/2008]:
  1128. @verbatim
  1129. (gdb) mon target0 cget -event FAFA
  1130. Runtime error, file "../../../openocd23/src/helper/command.c", line 433:
  1131. -event: Unknown: FAFA, try one of: old-pre_reset,
  1132. old-gdb_program_config, old-post_reset, halted,
  1133. resumed, resume-start, resume-end, reset-start,
  1134. reset-assert-pre, reset-assert-post,
  1135. reset-deassert-pre, reset-deassert-post,
  1136. reset-halt-pre, reset-halt-post, reset-wait-pre,
  1137. reset-wait-post, reset-init, reset-end,
  1138. examine-start, examine-end, debug-halted,
  1139. debug-resumed, gdb-attach, gdb-detach,
  1140. gdb-flash-write-start, gdb-flash-write-end,
  1141. gdb-flash-erase-start, gdb-flash-erase-end,
  1142. resume-start, resume-ok, or resume-end
  1143. @end verbatim
  1144. NOTE: The event-names "old-*" are deprecated and exist only to help old scripts continue to function, and the old "target_script"
  1145. command to work. Please do not rely on them.
  1146. These are some other important names:
  1147. @itemize
  1148. @item gdb-flash-erase-start
  1149. @item gdb-flash-erase-end
  1150. @item gdb-flash-write-start
  1151. @item gdb-flash-write-end
  1152. @end itemize
  1153. These occur when GDB/OpenOCD attempts to erase & program the FLASH chip via GDB. For example - some PCBs may have a simple GPIO
  1154. pin that acts like a "flash write protect" you might need to write a script that disables "write protect".
  1155. To get a list of current 'event actions', type the following command:
  1156. @verbatim
  1157. (gdb) mon target0 eventlist
  1158. Event actions for target (0) target0
  1159. Event | Body
  1160. ------------------------- | ----------------------------------------
  1161. old-post_reset | script event/sam7x256_reset.script
  1162. @end verbatim
  1163. Here is a simple example for all targets:
  1164. @verbatim
  1165. (gdb) mon foreach x [target names] { $x eventlist }
  1166. @end verbatim
  1167. The above uses some TCL tricks:
  1168. @enumerate a
  1169. @item foreach VARIABLE LIST BODY
  1170. @item to generate the list, we use [target names]
  1171. @item the BODY, contains $x - the loop variable and expands to the target specific name
  1172. @end enumerate
  1173. Recalling the earlier discussion - the "object command" there are other things you can
  1174. do besides "configure" the target.
  1175. Note: Many of these commands exist as "global" commands, and they also exist as target
  1176. specific commands. For example, the "mww" (memory write word) operates on the current
  1177. target if you have more then 1 target, you must switch. In contrast to the normal
  1178. commands, these commands operate on the specific target. For example, the command "mww"
  1179. writes data to the *current* command line target.
  1180. Often, you have only a single target - but if you have multiple targets (ie: a PIC32
  1181. and an at91sam7 - your reset-init scripts might get a bit more complicated, ie: you must
  1182. specify which of the two chips you want to write to. Writing 'pic32' clock configuration
  1183. to an at91sam7 does not work).
  1184. The commands are [as of 30/august/2008]:
  1185. @verbatim
  1186. TNAME mww ADDRESS VALUE
  1187. TNAME mwh ADDRESS VALUE
  1188. TNAME mwb ADDRESS VALUE
  1189. Write(poke): 32, 16, 8bit values to memory.
  1190. TNAME mdw ADDRESS VALUE
  1191. TNAME mdh ADDRESS VALUE
  1192. TNAME mdb ADDRESS VALUE
  1193. Human 'hexdump' with ascii 32, 16, 8bit values
  1194. TNAME mem2array [see mem2array command]
  1195. TNAME array2mem [see array2mem command]
  1196. TNAME curstate
  1197. Returns the current state of the target.
  1198. TNAME examine
  1199. See 'advanced target reset'
  1200. TNAME poll
  1201. See 'advanced target reset'
  1202. TNAME reset assert
  1203. See 'advanced target reset'
  1204. TNAME reset deassert
  1205. See 'advanced target reset'
  1206. TNAME halt
  1207. See 'advanced target reset'
  1208. TNAME waitstate STATENAME
  1209. See 'advanced target reset'
  1210. @end verbatim
  1211. @page
  1212. @section Target Specific Commands
  1213. @cindex Target Specific Commands
  1214. @subsection AT91SAM7 specific commands
  1215. @cindex AT91SAM7 specific commands
  1216. The flash configuration is deduced from the chip identification register. The flash
  1217. controller handles erases automatically on a page (128/265 byte) basis so erase is
  1218. not necessary for flash programming. AT91SAM7 processors with less than 512K flash
  1219. only have a single flash bank embedded on chip. AT91SAM7xx512 have two flash planes
  1220. that can be erased separatly. Only an EraseAll command is supported by the controller
  1221. for each flash plane and this is called with
  1222. @itemize @bullet
  1223. @item @b{flash erase} <@var{num}> @var{first_plane} @var{last_plane}
  1224. @*bulk erase flash planes first_plane to last_plane.
  1225. @item @b{at91sam7 gpnvm} <@var{num}> <@var{bit}> <@option{set}|@option{clear}>
  1226. @cindex at91sam7 gpnvm
  1227. @*set or clear a gpnvm bit for the processor
  1228. @end itemize
  1229. @subsection STR9 specific commands
  1230. @cindex STR9 specific commands
  1231. These are flash specific commands when using the str9xpec driver.
  1232. @itemize @bullet
  1233. @item @b{str9xpec enable_turbo} <@var{num}>
  1234. @cindex str9xpec enable_turbo
  1235. @*enable turbo mode, simply this will remove the str9 from the chain and talk
  1236. directly to the embedded flash controller.
  1237. @item @b{str9xpec disable_turbo} <@var{num}>
  1238. @cindex str9xpec disable_turbo
  1239. @*restore the str9 into jtag chain.
  1240. @item @b{str9xpec lock} <@var{num}>
  1241. @cindex str9xpec lock
  1242. @*lock str9 device. The str9 will only respond to an unlock command that will
  1243. erase the device.
  1244. @item @b{str9xpec unlock} <@var{num}>
  1245. @cindex str9xpec unlock
  1246. @*unlock str9 device.
  1247. @item @b{str9xpec options_read} <@var{num}>
  1248. @cindex str9xpec options_read
  1249. @*read str9 option bytes.
  1250. @item @b{str9xpec options_write} <@var{num}>
  1251. @cindex str9xpec options_write
  1252. @*write str9 option bytes.
  1253. @end itemize
  1254. @subsection STR9 configuration
  1255. @cindex STR9 configuration
  1256. @itemize @bullet
  1257. @item @b{str9x flash_config} <@var{bank}> <@var{BBSR}> <@var{NBBSR}>
  1258. <@var{BBADR}> <@var{NBBADR}>
  1259. @cindex str9x flash_config
  1260. @*Configure str9 flash controller.
  1261. @smallexample
  1262. eg. str9x flash_config 0 4 2 0 0x80000
  1263. This will setup
  1264. BBSR - Boot Bank Size register
  1265. NBBSR - Non Boot Bank Size register
  1266. BBADR - Boot Bank Start Address register
  1267. NBBADR - Boot Bank Start Address register
  1268. @end smallexample
  1269. @end itemize
  1270. @subsection STR9 option byte configuration
  1271. @cindex STR9 option byte configuration
  1272. @itemize @bullet
  1273. @item @b{str9xpec options_cmap} <@var{num}> <@option{bank0}|@option{bank1}>
  1274. @cindex str9xpec options_cmap
  1275. @*configure str9 boot bank.
  1276. @item @b{str9xpec options_lvdthd} <@var{num}> <@option{2.4v}|@option{2.7v}>
  1277. @cindex str9xpec options_lvdthd
  1278. @*configure str9 lvd threshold.
  1279. @item @b{str9xpec options_lvdsel} <@var{num}> <@option{vdd}|@option{vdd_vddq}>
  1280. @cindex str9xpec options_lvdsel
  1281. @*configure str9 lvd source.
  1282. @item @b{str9xpec options_lvdwarn} <@var{bank}> <@option{vdd}|@option{vdd_vddq}>
  1283. @cindex str9xpec options_lvdwarn
  1284. @*configure str9 lvd reset warning source.
  1285. @end itemize
  1286. @subsection STM32x specific commands
  1287. @cindex STM32x specific commands
  1288. These are flash specific commands when using the stm32x driver.
  1289. @itemize @bullet
  1290. @item @b{stm32x lock} <@var{num}>
  1291. @cindex stm32x lock
  1292. @*lock stm32 device.
  1293. @item @b{stm32x unlock} <@var{num}>
  1294. @cindex stm32x unlock
  1295. @*unlock stm32 device.
  1296. @item @b{stm32x options_read} <@var{num}>
  1297. @cindex stm32x options_read
  1298. @*read stm32 option bytes.
  1299. @item @b{stm32x options_write} <@var{num}> <@option{SWWDG}|@option{HWWDG}>
  1300. <@option{RSTSTNDBY}|@option{NORSTSTNDBY}> <@option{RSTSTOP}|@option{NORSTSTOP}>
  1301. @cindex stm32x options_write
  1302. @*write stm32 option bytes.
  1303. @item @b{stm32x mass_erase} <@var{num}>
  1304. @cindex stm32x mass_erase
  1305. @*mass erase flash memory.
  1306. @end itemize
  1307. @subsection Stellaris specific commands
  1308. @cindex Stellaris specific commands
  1309. These are flash specific commands when using the Stellaris driver.
  1310. @itemize @bullet
  1311. @item @b{stellaris mass_erase} <@var{num}>
  1312. @cindex stellaris mass_erase
  1313. @*mass erase flash memory.
  1314. @end itemize
  1315. @page
  1316. @section Architecture Specific Commands
  1317. @cindex Architecture Specific Commands
  1318. @subsection ARMV4/5 specific commands
  1319. @cindex ARMV4/5 specific commands
  1320. These commands are specific to ARM architecture v4 and v5, like all ARM7/9 systems
  1321. or Intel XScale (XScale isn't supported yet).
  1322. @itemize @bullet
  1323. @item @b{armv4_5 reg}
  1324. @cindex armv4_5 reg
  1325. @*Display a list of all banked core registers, fetching the current value from every
  1326. core mode if necessary. OpenOCD versions before rev. 60 didn't fetch the current
  1327. register value.
  1328. @item @b{armv4_5 core_mode} [@var{arm}|@var{thumb}]
  1329. @cindex armv4_5 core_mode
  1330. @*Displays the core_mode, optionally changing it to either ARM or Thumb mode.
  1331. The target is resumed in the currently set @option{core_mode}.
  1332. @end itemize
  1333. @subsection ARM7/9 specific commands
  1334. @cindex ARM7/9 specific commands
  1335. These commands are specific to ARM7 and ARM9 targets, like ARM7TDMI, ARM720t,
  1336. ARM920t or ARM926EJ-S.
  1337. @itemize @bullet
  1338. @item @b{arm7_9 dbgrq} <@var{enable}|@var{disable}>
  1339. @cindex arm7_9 dbgrq
  1340. @*Enable use of the DBGRQ bit to force entry into debug mode. This should be
  1341. safe for all but ARM7TDMI--S cores (like Philips LPC).
  1342. @item @b{arm7_9 fast_memory_access} <@var{enable}|@var{disable}>
  1343. @cindex arm7_9 fast_memory_access
  1344. @anchor{arm7_9 fast_memory_access}
  1345. @*Allow OpenOCD to read and write memory without checking completion of
  1346. the operation. This provides a huge speed increase, especially with USB JTAG
  1347. cables (FT2232), but might be unsafe if used with targets running at a very low
  1348. speed, like the 32kHz startup clock of an AT91RM9200.
  1349. @item @b{arm7_9 dcc_downloads} <@var{enable}|@var{disable}>
  1350. @cindex arm7_9 dcc_downloads
  1351. @*Enable the use of the debug communications channel (DCC) to write larger (>128 byte)
  1352. amounts of memory. DCC downloads offer a huge speed increase, but might be potentially
  1353. unsafe, especially with targets running at a very low speed. This command was introduced
  1354. with OpenOCD rev. 60.
  1355. @end itemize
  1356. @subsection ARM720T specific commands
  1357. @cindex ARM720T specific commands
  1358. @itemize @bullet
  1359. @item @b{arm720t cp15} <@var{num}> [@var{value}]
  1360. @cindex arm720t cp15
  1361. @*display/modify cp15 register <@option{num}> [@option{value}].
  1362. @item @b{arm720t md<bhw>_phys} <@var{addr}> [@var{count}]
  1363. @cindex arm720t md<bhw>_phys
  1364. @*Display memory at physical address addr.
  1365. @item @b{arm720t mw<bhw>_phys} <@var{addr}> <@var{value}>
  1366. @cindex arm720t mw<bhw>_phys
  1367. @*Write memory at physical address addr.
  1368. @item @b{arm720t virt2phys} <@var{va}>
  1369. @cindex arm720t virt2phys
  1370. @*Translate a virtual address to a physical address.
  1371. @end itemize
  1372. @subsection ARM9TDMI specific commands
  1373. @cindex ARM9TDMI specific commands
  1374. @itemize @bullet
  1375. @item @b{arm9tdmi vector_catch} <@var{all}|@var{none}>
  1376. @cindex arm9tdmi vector_catch
  1377. @*Catch arm9 interrupt vectors, can be @option{all} @option{none} or any of the following:
  1378. @option{reset} @option{undef} @option{swi} @option{pabt} @option{dabt} @option{reserved}
  1379. @option{irq} @option{fiq}.
  1380. Can also be used on other arm9 based cores, arm966, arm920t and arm926ejs.
  1381. @end itemize
  1382. @subsection ARM966E specific commands
  1383. @cindex ARM966E specific commands
  1384. @itemize @bullet
  1385. @item @b{arm966e cp15} <@var{num}> [@var{value}]
  1386. @cindex arm966e cp15
  1387. @*display/modify cp15 register <@option{num}> [@option{value}].
  1388. @end itemize
  1389. @subsection ARM920T specific commands
  1390. @cindex ARM920T specific commands
  1391. @itemize @bullet
  1392. @item @b{arm920t cp15} <@var{num}> [@var{value}]
  1393. @cindex arm920t cp15
  1394. @*display/modify cp15 register <@option{num}> [@option{value}].
  1395. @item @b{arm920t cp15i} <@var{num}> [@var{value}] [@var{address}]
  1396. @cindex arm920t cp15i
  1397. @*display/modify cp15 (interpreted access) <@option{opcode}> [@option{value}] [@option{address}]
  1398. @item @b{arm920t cache_info}
  1399. @cindex arm920t cache_info
  1400. @*Print information about the caches found. This allows you to see if your target
  1401. is a ARM920T (2x16kByte cache) or ARM922T (2x8kByte cache).
  1402. @item @b{arm920t md<bhw>_phys} <@var{addr}> [@var{count}]
  1403. @cindex arm920t md<bhw>_phys
  1404. @*Display memory at physical address addr.
  1405. @item @b{arm920t mw<bhw>_phys} <@var{addr}> <@var{value}>
  1406. @cindex arm920t mw<bhw>_phys
  1407. @*Write memory at physical address addr.
  1408. @item @b{arm920t read_cache} <@var{filename}>
  1409. @cindex arm920t read_cache
  1410. @*Dump the content of ICache and DCache to a file.
  1411. @item @b{arm920t read_mmu} <@var{filename}>
  1412. @cindex arm920t read_mmu
  1413. @*Dump the content of the ITLB and DTLB to a file.
  1414. @item @b{arm920t virt2phys} <@var{va}>
  1415. @cindex arm920t virt2phys
  1416. @*Translate a virtual address to a physical address.
  1417. @end itemize
  1418. @subsection ARM926EJS specific commands
  1419. @cindex ARM926EJS specific commands
  1420. @itemize @bullet
  1421. @item @b{arm926ejs cp15} <@var{num}> [@var{value}]
  1422. @cindex arm926ejs cp15
  1423. @*display/modify cp15 register <@option{num}> [@option{value}].
  1424. @item @b{arm926ejs cache_info}
  1425. @cindex arm926ejs cache_info
  1426. @*Print information about the caches found.
  1427. @item @b{arm926ejs md<bhw>_phys} <@var{addr}> [@var{count}]
  1428. @cindex arm926ejs md<bhw>_phys
  1429. @*Display memory at physical address addr.
  1430. @item @b{arm926ejs mw<bhw>_phys} <@var{addr}> <@var{value}>
  1431. @cindex arm926ejs mw<bhw>_phys
  1432. @*Write memory at physical address addr.
  1433. @item @b{arm926ejs virt2phys} <@var{va}>
  1434. @cindex arm926ejs virt2phys
  1435. @*Translate a virtual address to a physical address.
  1436. @end itemize
  1437. @page
  1438. @section Debug commands
  1439. @cindex Debug commands
  1440. The following commands give direct access to the core, and are most likely
  1441. only useful while debugging OpenOCD.
  1442. @itemize @bullet
  1443. @item @b{arm7_9 write_xpsr} <@var{32-bit value}> <@option{0=cpsr}, @option{1=spsr}>
  1444. @cindex arm7_9 write_xpsr
  1445. @*Immediately write either the current program status register (CPSR) or the saved
  1446. program status register (SPSR), without changing the register cache (as displayed
  1447. by the @option{reg} and @option{armv4_5 reg} commands).
  1448. @item @b{arm7_9 write_xpsr_im8} <@var{8-bit value}> <@var{rotate 4-bit}>
  1449. <@var{0=cpsr},@var{1=spsr}>
  1450. @cindex arm7_9 write_xpsr_im8
  1451. @*Write the 8-bit value rotated right by 2*rotate bits, using an immediate write
  1452. operation (similar to @option{write_xpsr}).
  1453. @item @b{arm7_9 write_core_reg} <@var{num}> <@var{mode}> <@var{value}>
  1454. @cindex arm7_9 write_core_reg
  1455. @*Write a core register, without changing the register cache (as displayed by the
  1456. @option{reg} and @option{armv4_5 reg} commands). The <@var{mode}> argument takes the
  1457. encoding of the [M4:M0] bits of the PSR.
  1458. @end itemize
  1459. @page
  1460. @section JTAG commands
  1461. @cindex JTAG commands
  1462. @itemize @bullet
  1463. @item @b{scan_chain}
  1464. @cindex scan_chain
  1465. @*Print current scan chain configuration.
  1466. @item @b{jtag_reset} <@var{trst}> <@var{srst}>
  1467. @cindex jtag_reset
  1468. @*Toggle reset lines.
  1469. @item @b{endstate} <@var{tap_state}>
  1470. @cindex endstate
  1471. @*Finish JTAG operations in <@var{tap_state}>.
  1472. @item @b{runtest} <@var{num_cycles}>
  1473. @cindex runtest
  1474. @*Move to Run-Test/Idle, and execute <@var{num_cycles}>
  1475. @item @b{statemove} [@var{tap_state}]
  1476. @cindex statemove
  1477. @*Move to current endstate or [@var{tap_state}]
  1478. @item @b{irscan} <@var{device}> <@var{instr}> [@var{dev2}] [@var{instr2}] ...
  1479. @cindex irscan
  1480. @*Execute IR scan <@var{device}> <@var{instr}> [@var{dev2}] [@var{instr2}] ...
  1481. @item @b{drscan} <@var{device}> [@var{dev2}] [@var{var2}] ...
  1482. @cindex drscan
  1483. @*Execute DR scan <@var{device}> [@var{dev2}] [@var{var2}] ...
  1484. @item @b{verify_ircapture} <@option{enable}|@option{disable}>
  1485. @cindex verify_ircapture
  1486. @*Verify value captured during Capture-IR. Default is enabled.
  1487. @item @b{var} <@var{name}> [@var{num_fields}|@var{del}] [@var{size1}] ...
  1488. @cindex var
  1489. @*Allocate, display or delete variable <@var{name}> [@var{num_fields}|@var{del}] [@var{size1}] ...
  1490. @item @b{field} <@var{var}> <@var{field}> [@var{value}|@var{flip}]
  1491. @cindex field
  1492. Display/modify variable field <@var{var}> <@var{field}> [@var{value}|@var{flip}].
  1493. @end itemize
  1494. @page
  1495. @section Target Requests
  1496. @cindex Target Requests
  1497. OpenOCD can handle certain target requests, currently debugmsg are only supported for arm7_9 and cortex_m3.
  1498. See libdcc in the contrib dir for more details.
  1499. @itemize @bullet
  1500. @item @b{target_request debugmsgs} <@var{enable}|@var{disable}>
  1501. @cindex target_request debugmsgs
  1502. @*Enable/disable target debugmsgs requests. debugmsgs enable messages to be sent to the debugger while the target is running.
  1503. @end itemize
  1504. @node Sample Scripts
  1505. @chapter Sample Scripts
  1506. @cindex scripts
  1507. This page shows how to use the target library.
  1508. The configuration script can be divided in the following section:
  1509. @itemize @bullet
  1510. @item daemon configuration
  1511. @item interface
  1512. @item jtag scan chain
  1513. @item target configuration
  1514. @item flash configuration
  1515. @end itemize
  1516. Detailed information about each section can be found at OpenOCD configuration.
  1517. @section AT91R40008 example
  1518. @cindex AT91R40008 example
  1519. To start OpenOCD with a target script for the AT91R40008 CPU and reset
  1520. the CPU upon startup of the OpenOCD daemon.
  1521. @smallexample
  1522. openocd -f interface/parport.cfg -f target/at91r40008.cfg -c init -c reset
  1523. @end smallexample
  1524. @node GDB and OpenOCD
  1525. @chapter GDB and OpenOCD
  1526. @cindex GDB and OpenOCD
  1527. OpenOCD complies with the remote gdbserver protocol, and as such can be used
  1528. to debug remote targets.
  1529. @section Connecting to gdb
  1530. @cindex Connecting to gdb
  1531. Use GDB 6.7 or newer with OpenOCD if you run into trouble. For instance 6.3 has a
  1532. known bug where it produces bogus memory access errors, which has since
  1533. been fixed: look up 1836 in http://sourceware.org/cgi-bin/gnatsweb.pl?database=gdb
  1534. A connection is typically started as follows:
  1535. @smallexample
  1536. target remote localhost:3333
  1537. @end smallexample
  1538. This would cause gdb to connect to the gdbserver on the local pc using port 3333.
  1539. To see a list of available OpenOCD commands type @option{monitor help} on the
  1540. gdb commandline.
  1541. OpenOCD supports the gdb @option{qSupported} packet, this enables information
  1542. to be sent by the gdb server (openocd) to gdb. Typical information includes
  1543. packet size and device memory map.
  1544. Previous versions of OpenOCD required the following gdb options to increase
  1545. the packet size and speed up gdb communication.
  1546. @smallexample
  1547. set remote memory-write-packet-size 1024
  1548. set remote memory-write-packet-size fixed
  1549. set remote memory-read-packet-size 1024
  1550. set remote memory-read-packet-size fixed
  1551. @end smallexample
  1552. This is now handled in the @option{qSupported} PacketSize.
  1553. @section Programming using gdb
  1554. @cindex Programming using gdb
  1555. By default the target memory map is sent to gdb, this can be disabled by
  1556. the following OpenOCD config option:
  1557. @smallexample
  1558. gdb_memory_map disable
  1559. @end smallexample
  1560. For this to function correctly a valid flash config must also be configured
  1561. in OpenOCD. For faster performance you should also configure a valid
  1562. working area.
  1563. Informing gdb of the memory map of the target will enable gdb to protect any
  1564. flash area of the target and use hardware breakpoints by default. This means
  1565. that the OpenOCD option @option{gdb_breakpoint_override} is not required when
  1566. using a memory map. @xref{gdb_breakpoint_override}.
  1567. To view the configured memory map in gdb, use the gdb command @option{info mem}
  1568. All other unasigned addresses within gdb are treated as RAM.
  1569. GDB 6.8 and higher set any memory area not in the memory map as inaccessible,
  1570. this can be changed to the old behaviour by using the following gdb command.
  1571. @smallexample
  1572. set mem inaccessible-by-default off
  1573. @end smallexample
  1574. If @option{gdb_flash_program enable} is also used, gdb will be able to
  1575. program any flash memory using the vFlash interface.
  1576. gdb will look at the target memory map when a load command is given, if any
  1577. areas to be programmed lie within the target flash area the vFlash packets
  1578. will be used.
  1579. If the target needs configuring before gdb programming, a script can be executed.
  1580. @smallexample
  1581. target_script 0 gdb_program_config config.script
  1582. @end smallexample
  1583. To verify any flash programming the gdb command @option{compare-sections}
  1584. can be used.
  1585. @node TCL and OpenOCD
  1586. @chapter TCL and OpenOCD
  1587. @cindex TCL and OpenOCD
  1588. OpenOCD embeds a TCL interpreter (see JIM) for command parsing and scripting
  1589. support.
  1590. The TCL interpreter can be invoked from the interactive command line, files, and a network port.
  1591. The command and file interfaces are fairly straightforward, while the network
  1592. port is geared toward intergration with external clients. A small example
  1593. of an external TCL script that can connect to openocd is shown below.
  1594. @verbatim
  1595. # Simple tcl client to connect to openocd
  1596. puts "Use empty line to exit"
  1597. set fo [socket 127.0.0.1 6666]
  1598. puts -nonewline stdout "> "
  1599. flush stdout
  1600. while {[gets stdin line] >= 0} {
  1601. if {$line eq {}} break
  1602. puts $fo $line
  1603. flush $fo
  1604. gets $fo line
  1605. puts $line
  1606. puts -nonewline stdout "> "
  1607. flush stdout
  1608. }
  1609. close $fo
  1610. @end verbatim
  1611. This script can easily be modified to front various GUIs or be a sub
  1612. component of a larger framework for control and interaction.
  1613. @node TCL scripting API
  1614. @chapter TCL scripting API
  1615. @cindex TCL scripting API
  1616. API rules
  1617. The commands are stateless. E.g. the telnet command line has a concept
  1618. of currently active target, the Tcl API proc's take this sort of state
  1619. information as an argument to each proc.
  1620. There are three main types of return values: single value, name value
  1621. pair list and lists.
  1622. Name value pair. The proc 'foo' below returns a name/value pair
  1623. list.
  1624. @verbatim
  1625. > set foo(me) Duane
  1626. > set foo(you) Oyvind
  1627. > set foo(mouse) Micky
  1628. > set foo(duck) Donald
  1629. If one does this:
  1630. > set foo
  1631. The result is:
  1632. me Duane you Oyvind mouse Micky duck Donald
  1633. Thus, to get the names of the associative array is easy:
  1634. foreach { name value } [set foo] {
  1635. puts "Name: $name, Value: $value"
  1636. }
  1637. @end verbatim
  1638. Lists returned must be relatively small. Otherwise a range
  1639. should be passed in to the proc in question.
  1640. Low level commands are prefixed with "openocd_", e.g. openocd_flash_banks
  1641. is the low level API upon which "flash banks" is implemented.
  1642. OpenOCD commands can consist of two words, e.g. "flash banks". The
  1643. startup.tcl "unknown" proc will translate this into a tcl proc
  1644. called "flash_banks".
  1645. @node Upgrading
  1646. @chapter Deprecated/Removed Commands
  1647. @cindex Deprecated/Removed Commands
  1648. Certain OpenOCD commands have been deprecated/removed during the various revisions.
  1649. @itemize @bullet
  1650. @item @b{load_binary}
  1651. @cindex load_binary
  1652. @*use @option{load_image} command with same args. @xref{load_image}.
  1653. @item @b{target}
  1654. @cindex target
  1655. @*@option{target} no longer take the reset_init, reset_run, run_and_halt, run_and_init. The @option{reset} command
  1656. always does a @option{reset run} when passed no arguments.
  1657. @item @b{dump_binary}
  1658. @cindex dump_binary
  1659. @*use @option{dump_image} command with same args. @xref{dump_image}.
  1660. @item @b{flash erase}
  1661. @cindex flash erase
  1662. @*use @option{flash erase_sector} command with same args. @xref{flash erase_sector}.
  1663. @item @b{flash write}
  1664. @cindex flash write
  1665. @*use @option{flash write_bank} command with same args. @xref{flash write_bank}.
  1666. @item @b{flash write_binary}
  1667. @cindex flash write_binary
  1668. @*use @option{flash write_bank} command with same args
  1669. @item @b{arm7_9 fast_writes}
  1670. @cindex arm7_9 fast_writes
  1671. @*use @option{arm7_9 fast_memory_access} command with same args. @xref{arm7_9 fast_memory_access}.
  1672. @item @b{flash auto_erase}
  1673. @cindex flash auto_erase
  1674. @*use @option{flash write_image} command passing @option{erase} as the first parameter. @xref{flash write_image}.
  1675. @item @b{daemon_startup}
  1676. @cindex daemon_startup
  1677. @*this config option has been removed, simply adding @option{init} and @option{reset halt} to
  1678. the end of your config script will give the same behaviour as using @option{daemon_startup reset}
  1679. and @option{target cortex_m3 little reset_halt 0}.
  1680. @item @b{arm7_9 sw_bkpts}
  1681. @cindex arm7_9 sw_bkpts
  1682. @*On by default. See also @option{gdb_breakpoint_override}. @xref{gdb_breakpoint_override}.
  1683. @item @b{arm7_9 force_hw_bkpts}
  1684. @cindex arm7_9 force_hw_bkpts
  1685. @*Use @option{gdb_breakpoint_override} instead. Note that GDB will use hardware breakpoints
  1686. for flash if the gdb memory map has been set up(default when flash is declared in
  1687. target configuration). @xref{gdb_breakpoint_override}.
  1688. @item @b{run_and_halt_time}
  1689. @cindex run_and_halt_time
  1690. @*This command has been removed for simpler reset behaviour, it can be simulated with the
  1691. following commands:
  1692. @smallexample
  1693. reset run
  1694. sleep 100
  1695. halt
  1696. @end smallexample
  1697. @end itemize
  1698. @node FAQ
  1699. @chapter FAQ
  1700. @cindex faq
  1701. @enumerate
  1702. @item OpenOCD complains about a missing cygwin1.dll.
  1703. Make sure you have Cygwin installed, or at least a version of OpenOCD that
  1704. claims to come with all the necessary dlls. When using Cygwin, try launching
  1705. OpenOCD from the Cygwin shell.
  1706. @item I'm trying to set a breakpoint using GDB (or a frontend like Insight or
  1707. Eclipse), but OpenOCD complains that "Info: arm7_9_common.c:213
  1708. arm7_9_add_breakpoint(): sw breakpoint requested, but software breakpoints not enabled".
  1709. GDB issues software breakpoints when a normal breakpoint is requested, or to implement
  1710. source-line single-stepping. On ARMv4T systems, like ARM7TDMI, ARM720t or ARM920t,
  1711. software breakpoints consume one of the two available hardware breakpoints.
  1712. @item When erasing or writing LPC2000 on-chip flash, the operation fails sometimes
  1713. and works sometimes fine.
  1714. Make sure the core frequency specified in the @option{flash lpc2000} line matches the
  1715. clock at the time you're programming the flash. If you've specified the crystal's
  1716. frequency, make sure the PLL is disabled, if you've specified the full core speed
  1717. (e.g. 60MHz), make sure the PLL is enabled.
  1718. @item When debugging using an Amontec Chameleon in its JTAG Accelerator configuration,
  1719. I keep getting "Error: amt_jtagaccel.c:184 amt_wait_scan_busy(): amt_jtagaccel timed
  1720. out while waiting for end of scan, rtck was disabled".
  1721. Make sure your PC's parallel port operates in EPP mode. You might have to try several
  1722. settings in your PC BIOS (ECP, EPP, and different versions of those).
  1723. @item When debugging with OpenOCD and GDB (plain GDB, Insight, or Eclipse),
  1724. I get lots of "Error: arm7_9_common.c:1771 arm7_9_read_memory():
  1725. memory read caused data abort".
  1726. The errors are non-fatal, and are the result of GDB trying to trace stack frames
  1727. beyond the last valid frame. It might be possible to prevent this by setting up
  1728. a proper "initial" stack frame, if you happen to know what exactly has to
  1729. be done, feel free to add this here.
  1730. @item I get the following message in the OpenOCD console (or log file):
  1731. "Warning: arm7_9_common.c:679 arm7_9_assert_reset(): srst resets test logic, too".
  1732. This warning doesn't indicate any serious problem, as long as you don't want to
  1733. debug your core right out of reset. Your .cfg file specified @option{jtag_reset
  1734. trst_and_srst srst_pulls_trst} to tell OpenOCD that either your board,
  1735. your debugger or your target uC (e.g. LPC2000) can't assert the two reset signals
  1736. independently. With this setup, it's not possible to halt the core right out of
  1737. reset, everything else should work fine.
  1738. @item When using OpenOCD in conjunction with Amontec JTAGkey and the Yagarto
  1739. Toolchain (Eclipse, arm-elf-gcc, arm-elf-gdb), the debugging seems to be
  1740. unstable. When single-stepping over large blocks of code, GDB and OpenOCD
  1741. quit with an error message. Is there a stability issue with OpenOCD?
  1742. No, this is not a stability issue concerning OpenOCD. Most users have solved
  1743. this issue by simply using a self-powered USB hub, which they connect their
  1744. Amontec JTAGkey to. Apparently, some computers do not provide a USB power
  1745. supply stable enough for the Amontec JTAGkey to be operated.
  1746. @item When using the Amontec JTAGkey, sometimes OpenOCD crashes with the
  1747. following error messages: "Error: ft2232.c:201 ft2232_read(): FT_Read returned:
  1748. 4" and "Error: ft2232.c:365 ft2232_send_and_recv(): couldn't read from FT2232".
  1749. What does that mean and what might be the reason for this?
  1750. First of all, the reason might be the USB power supply. Try using a self-powered
  1751. hub instead of a direct connection to your computer. Secondly, the error code 4
  1752. corresponds to an FT_IO_ERROR, which means that the driver for the FTDI USB
  1753. chip ran into some sort of error - this points us to a USB problem.
  1754. @item When using the Amontec JTAGkey, sometimes OpenOCD crashes with the following
  1755. error message: "Error: gdb_server.c:101 gdb_get_char(): read: 10054".
  1756. What does that mean and what might be the reason for this?
  1757. Error code 10054 corresponds to WSAECONNRESET, which means that the debugger (GDB)
  1758. has closed the connection to OpenOCD. This might be a GDB issue.
  1759. @item In the configuration file in the section where flash device configurations
  1760. are described, there is a parameter for specifying the clock frequency for
  1761. LPC2000 internal flash devices (e.g.
  1762. @option{flash bank lpc2000 0x0 0x40000 0 0 0 lpc2000_v1 14746 calc_checksum}),
  1763. which must be specified in kilohertz. However, I do have a quartz crystal of a
  1764. frequency that contains fractions of kilohertz (e.g. 14,745,600 Hz, i.e. 14,745.600 kHz).
  1765. Is it possible to specify real numbers for the clock frequency?
  1766. No. The clock frequency specified here must be given as an integral number.
  1767. However, this clock frequency is used by the In-Application-Programming (IAP)
  1768. routines of the LPC2000 family only, which seems to be very tolerant concerning
  1769. the given clock frequency, so a slight difference between the specified clock
  1770. frequency and the actual clock frequency will not cause any trouble.
  1771. @item Do I have to keep a specific order for the commands in the configuration file?
  1772. Well, yes and no. Commands can be given in arbitrary order, yet the devices
  1773. listed for the JTAG scan chain must be given in the right order (jtag_device),
  1774. with the device closest to the TDO-Pin being listed first. In general,
  1775. whenever objects of the same type exist which require an index number, then
  1776. these objects must be given in the right order (jtag_devices, targets and flash
  1777. banks - a target references a jtag_device and a flash bank references a target).
  1778. @item Sometimes my debugging session terminates with an error. When I look into the
  1779. log file, I can see these error messages: Error: arm7_9_common.c:561
  1780. arm7_9_execute_sys_speed(): timeout waiting for SYSCOMP
  1781. TODO.
  1782. @end enumerate
  1783. @include fdl.texi
  1784. @node Index
  1785. @unnumbered Index
  1786. @printindex cp
  1787. @bye