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.
 
 
 
 
 
 

3839 lines
134 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. @paragraphindent 0
  8. * OpenOCD: (openocd). Open On-Chip Debugger.
  9. @end direntry
  10. @c %**end of header
  11. @include version.texi
  12. @copying
  13. @itemize @bullet
  14. @item Copyright @copyright{} 2008 The OpenOCD Project
  15. @item Copyright @copyright{} 2007-2008 Spencer Oliver @email{spen@@spen-soft.co.uk}
  16. @item Copyright @copyright{} 2008 Oyvind Harboe @email{oyvind.harboe@@zylin.com}
  17. @item Copyright @copyright{} 2008 Duane Ellis @email{openocd@@duaneellis.com}
  18. @end itemize
  19. @quotation
  20. Permission is granted to copy, distribute and/or modify this document
  21. under the terms of the GNU Free Documentation License, Version 1.2 or
  22. any later version published by the Free Software Foundation; with no
  23. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  24. Texts. A copy of the license is included in the section entitled ``GNU
  25. Free Documentation License''.
  26. @end quotation
  27. @end copying
  28. @titlepage
  29. @title Open On-Chip Debugger (OpenOCD)
  30. @subtitle Edition @value{EDITION} for OpenOCD version @value{VERSION}
  31. @subtitle @value{UPDATED}
  32. @page
  33. @vskip 0pt plus 1filll
  34. @insertcopying
  35. @end titlepage
  36. @summarycontents
  37. @contents
  38. @node Top, About, , (dir)
  39. @top OpenOCD
  40. This manual documents edition @value{EDITION} of the Open On-Chip Debugger
  41. (OpenOCD) version @value{VERSION}, @value{UPDATED}.
  42. @insertcopying
  43. @menu
  44. * About:: About OpenOCD.
  45. * Developers:: OpenOCD developers
  46. * Building:: Building OpenOCD
  47. * JTAG Hardware Dongles:: JTAG Hardware Dongles
  48. * Running:: Running OpenOCD
  49. * Simple Configuration Files:: Simple Configuration Files
  50. * Config File Guidelines:: Config File Guidelines
  51. * About JIM-Tcl:: About JIM-Tcl
  52. * Daemon Configuration:: Daemon Configuration
  53. * Interface - Dongle Configuration:: Interface - Dongle Configuration
  54. * Reset Configuration:: Reset Configuration
  55. * Tap Creation:: Tap Creation
  56. * Target Configuration:: Target Configuration
  57. * Flash Configuration:: Flash Configuration
  58. * General Commands:: General Commands
  59. * JTAG Commands:: JTAG Commands
  60. * Sample Scripts:: Sample Target Scripts
  61. * TFTP:: TFTP
  62. * GDB and OpenOCD:: Using GDB and OpenOCD
  63. * TCL scripting API:: Tcl scripting API
  64. * Upgrading:: Deprecated/Removed Commands
  65. * Target library:: Target library
  66. * FAQ:: Frequently Asked Questions
  67. * TCL Crash Course:: TCL Crash Course
  68. * License:: GNU Free Documentation License
  69. @comment DO NOT use the plain word ``Index'', reason: CYGWIN filename
  70. @comment case issue with ``Index.html'' and ``index.html''
  71. @comment Occurs when creating ``--html --no-split'' output
  72. @comment This fix is based on: http://sourceware.org/ml/binutils/2006-05/msg00215.html
  73. * OpenOCD Index:: Main index.
  74. @end menu
  75. @node About
  76. @unnumbered About
  77. @cindex about
  78. The Open On-Chip Debugger (OpenOCD) aims to provide debugging,
  79. in-system programming and boundary-scan testing for embedded target
  80. devices.
  81. @b{JTAG:} OpenOCD uses a ``hardware interface dongle'' to communicate
  82. with the JTAG (IEEE 1149.1) complient taps on your target board.
  83. @b{Dongles:} OpenOCD currently many types of hardware dongles: USB
  84. Based, Parallel Port Based, and other standalone boxes that run
  85. OpenOCD internally. See the section titled: @xref{JTAG Hardware Dongles}.
  86. @b{GDB Debug:} It allows ARM7 (ARM7TDMI and ARM720t), ARM9 (ARM920t,
  87. ARM922t, ARM926ej--s, ARM966e--s), XScale (PXA25x, IXP42x) and
  88. Cortex-M3 (Luminary Stellaris LM3 and ST STM32) based cores to be
  89. debugged via the GDB Protocol.
  90. @b{Flash Programing:} Flash writing is supported for external CFI
  91. compatible flashes (Intel and AMD/Spansion command set) and several
  92. internal flashes (LPC2000, AT91SAM7, STR7x, STR9x, LM3 and
  93. STM32x). Preliminary support for using the LPC3180's NAND flash
  94. controller is included.
  95. @node Developers
  96. @chapter Developers
  97. @cindex developers
  98. OpenOCD was created by Dominic Rath as part of a diploma thesis written at the
  99. University of Applied Sciences Augsburg (@uref{http://www.fh-augsburg.de}).
  100. Others interested in improving the state of free and open debug and testing technology
  101. are welcome to participate.
  102. Other developers have contributed support for additional targets and flashes as well
  103. as numerous bugfixes and enhancements. See the AUTHORS file for regular contributors.
  104. The main OpenOCD web site is available at @uref{http://openocd.berlios.de/web/}
  105. @node Building
  106. @chapter Building
  107. @cindex building OpenOCD
  108. @section Pre-Built Tools
  109. If you are interested in getting actual work done rather than building
  110. OpenOCD, then check if your interface supplier provides binaries for
  111. you. Chances are that that binary is from some SVN version that is more
  112. stable than SVN trunk where bleeding edge development takes place.
  113. @section Packagers Please Read!
  114. If you are a @b{PACKAGER} of OpenOCD if you
  115. @enumerate
  116. @item @b{Sell dongles} and include pre-built binaries
  117. @item @b{Supply tools} ie: A complete development solution
  118. @item @b{Supply IDEs} like Eclipse, or RHIDE, etc.
  119. @item @b{Build packages} ie: RPM files, or DEB files for a Linux Distro
  120. @end enumerate
  121. As a @b{PACKAGER} - you are at the top of the food chain. You solve
  122. problems for downstream users. What you fix or solve - solves hundreds
  123. if not thousands of user questions. If something does not work for you
  124. please let us know. That said, would also like you to follow a few
  125. suggestions:
  126. @enumerate
  127. @item @b{Always build with Printer Ports Enabled}
  128. @item @b{Try where possible to use LIBFTDI + LIBUSB} You cover more bases
  129. @end enumerate
  130. It is your decision..
  131. @itemize @bullet
  132. @item @b{Why YES to LIBFTDI + LIBUSB}
  133. @itemize @bullet
  134. @item @b{LESS} work - libusb perhaps already there
  135. @item @b{LESS} work - identical code multiple platforms
  136. @item @b{MORE} dongles are supported
  137. @item @b{MORE} platforms are supported
  138. @item @b{MORE} complete solution
  139. @end itemize
  140. @item @b{Why not LIBFTDI + LIBUSB} (ie: ftd2xx instead)
  141. @itemize @bullet
  142. @item @b{LESS} Some say it is slower.
  143. @item @b{LESS} complex to distribute (external dependencies)
  144. @end itemize
  145. @end itemize
  146. @section Building From Source
  147. You can download the current SVN version with SVN client of your choice from the
  148. following repositories:
  149. (@uref{svn://svn.berlios.de/openocd/trunk})
  150. or
  151. (@uref{http://svn.berlios.de/svnroot/repos/openocd/trunk})
  152. Using the SVN command line client, you can use the following command to fetch the
  153. latest version (make sure there is no (non-svn) directory called "openocd" in the
  154. current directory):
  155. @example
  156. svn checkout svn://svn.berlios.de/openocd/trunk openocd
  157. @end example
  158. Building OpenOCD requires a recent version of the GNU autotools.
  159. On my build system, I'm using autoconf 2.13 and automake 1.9. For building on Windows,
  160. you have to use Cygwin. Make sure that your @env{PATH} environment variable contains no
  161. other locations with Unix utils (like UnxUtils) - these can't handle the Cygwin
  162. paths, resulting in obscure dependency errors (This is an observation I've gathered
  163. from the logs of one user - correct me if I'm wrong).
  164. You further need the appropriate driver files, if you want to build support for
  165. a FTDI FT2232 based interface:
  166. @itemize @bullet
  167. @item @b{ftdi2232} libftdi (@uref{http://www.intra2net.com/opensource/ftdi/})
  168. @item @b{ftd2xx} libftd2xx (@uref{http://www.ftdichip.com/Drivers/D2XX.htm})
  169. @item When using the Amontec JTAGkey, you have to get the drivers from the Amontec
  170. homepage (@uref{www.amontec.com}), as the JTAGkey uses a non-standard VID/PID.
  171. @end itemize
  172. libftdi is supported under windows. Do not use versions earlier then 0.14.
  173. In general, the D2XX driver provides superior performance (several times as fast),
  174. but has the draw-back of being binary-only - though that isn't that bad, as it isn't
  175. a kernel module, only a user space library.
  176. To build OpenOCD (on both Linux and Cygwin), use the following commands:
  177. @example
  178. ./bootstrap
  179. @end example
  180. Bootstrap generates the configure script, and prepares building on your system.
  181. @example
  182. ./configure [options, see below]
  183. @end example
  184. Configure generates the Makefiles used to build OpenOCD.
  185. @example
  186. make
  187. make install
  188. @end example
  189. Make builds OpenOCD, and places the final executable in ./src/, the last step, ``make install'' is optional.
  190. The configure script takes several options, specifying which JTAG interfaces
  191. should be included:
  192. @itemize @bullet
  193. @item
  194. @option{--enable-parport} - Bit bang pc printer ports.
  195. @item
  196. @option{--enable-parport_ppdev} - Parallel Port [see below]
  197. @item
  198. @option{--enable-parport_giveio} - Parallel Port [see below]
  199. @item
  200. @option{--enable-amtjtagaccel} - Parallel Port [Amontec, see below]
  201. @item
  202. @option{--enable-ft2232_ftd2xx} - Numerous USB Type ARM JTAG dongles use the FT2232C chip from this FTDICHIP.COM chip (closed source).
  203. @item
  204. @option{--enable-ft2232_libftdi} - An open source (free) alternate to FTDICHIP.COM ftd2xx solution (Linux, MacOS, Cygwin)
  205. @item
  206. @option{--with-ftd2xx-win32-zipdir=PATH} - If using FTDICHIP.COM ft2232c, point at the directory where the Win32 FTDICHIP.COM 'CDM' driver zip file was unpacked.
  207. @item
  208. @option{--with-ftd2xx-linux-tardir=PATH} - Linux only equal of @option{--with-ftd2xx-win32-zipdir}, where you unpacked the TAR.GZ file.
  209. @item
  210. @option{--with-ftd2xx-lib=shared|static} - Linux only. Default: static, specifies how the FTDICHIP.COM libftd2xx driver should be linked. Note 'static' only works in conjunction with @option{--with-ftd2xx-linux-tardir}. Shared is supported (12/26/2008), however you must manually install the required header files and shared libraries in an appropriate place. This uses ``libusb'' internally.
  211. @item
  212. @option{--enable-gw16012}
  213. @item
  214. @option{--enable-usbprog}
  215. @item
  216. @option{--enable-presto_libftdi}
  217. @item
  218. @option{--enable-presto_ftd2xx}
  219. @item
  220. @option{--enable-jlink} - From SEGGER
  221. @item
  222. @option{--enable-vsllink}
  223. @item
  224. @option{--enable-rlink} - Raisonance.com dongle.
  225. @end itemize
  226. @section Parallel Port Dongles
  227. If you want to access the parallel port using the PPDEV interface you have to specify
  228. both the @option{--enable-parport} AND the @option{--enable-parport_ppdev} option since
  229. the @option{--enable-parport_ppdev} option actually is an option to the parport driver
  230. (see @uref{http://forum.sparkfun.com/viewtopic.php?t=3795} for more info).
  231. @section FT2232C Based USB Dongles
  232. There are 2 methods of using the FTD2232, either (1) using the
  233. FTDICHIP.COM closed source driver, or (2) the open (and free) driver
  234. libftdi. Some claim the (closed) FTDICHIP.COM solution is faster.
  235. The FTDICHIP drivers come as either a (win32) ZIP file, or a (linux)
  236. TAR.GZ file. You must unpack them ``some where'' convient. As of this
  237. writing (12/26/2008) FTDICHIP does not supply means to install these
  238. files ``in an appropriate place'' As a result, there are two
  239. ``./configure'' options that help.
  240. Below is an example build process:
  241. 1) Check out the latest version of ``openocd'' from SVN.
  242. 2) Download & Unpack either the Windows or Linux FTD2xx Drivers
  243. (@uref{http://www.ftdichip.com/Drivers/D2XX.htm})
  244. @example
  245. /home/duane/ftd2xx.win32 => the Cygwin/Win32 ZIP file contents.
  246. /home/duane/libftd2xx0.4.16 => the Linux TAR file contents.
  247. @end example
  248. 3) Configure with these options:
  249. @example
  250. Cygwin FTCICHIP solution
  251. ./configure --prefix=/home/duane/mytools \
  252. --enable-ft2232_ftd2xx \
  253. --with-ftd2xx-win32-zipdir=/home/duane/ftd2xx.win32
  254. Linux FTDICHIP solution
  255. ./configure --prefix=/home/duane/mytools \
  256. --enable-ft2232_ftd2xx \
  257. --with-ft2xx-linux-tardir=/home/duane/libftd2xx0.4.16
  258. Cygwin/Linux LIBFTDI solution
  259. Assumes:
  260. 1a) For Windows: The windows port of LIBUSB is in place.
  261. 1b) For Linux: libusb has been built and is inplace.
  262. 2) And libftdi has been built and installed
  263. Note: libftdi - relies upon libusb.
  264. ./configure --prefix=/home/duane/mytools \
  265. --enable-ft2232_libftdi
  266. @end example
  267. 4) Then just type ``make'', and perhaps ``make install''.
  268. @section Miscellaneous configure options
  269. @itemize @bullet
  270. @item
  271. @option{--enable-gccwarnings} - enable extra gcc warnings during build.
  272. Default is enabled.
  273. @item
  274. @option{--enable-release} - enable building of a openocd release, generally
  275. this is for developers. It simply omits the svn version string when the
  276. openocd @option{-v} is executed.
  277. @end itemize
  278. @node JTAG Hardware Dongles
  279. @chapter JTAG Hardware Dongles
  280. @cindex dongles
  281. @cindex ftdi
  282. @cindex wiggler
  283. @cindex zy1000
  284. @cindex printer port
  285. @cindex usb adapter
  286. @cindex rtck
  287. Defined: @b{dongle}: A small device that plugins into a computer and serves as
  288. an adapter .... [snip]
  289. In the OpenOCD case, this generally refers to @b{a small adapater} one
  290. attaches to your computer via USB or the Parallel Printer Port. The
  291. execption being the Zylin ZY1000 which is a small box you attach via
  292. an ethernet cable.
  293. @section Choosing a Dongle
  294. There are three things you should keep in mind when choosing a dongle.
  295. @enumerate
  296. @item @b{Voltage} What voltage is your target? 1.8, 2.8, 3.3, or 5V? Does your dongle support it?
  297. @item @b{Connection} Printer Ports - Does your computer have one?
  298. @item @b{Connection} Is that long printer bit-bang cable practical?
  299. @item @b{RTCK} Do you require RTCK? Also known as ``adaptive clocking''
  300. @end enumerate
  301. @section Stand alone Systems
  302. @b{ZY1000} See: @url{http://www.zylin.com/zy1000.html} Technically, not a
  303. dongle, but a standalone box.
  304. @section USB FT2232 Based
  305. There are many USB jtag dongles on the market, many of them are based
  306. on a chip from ``Future Technology Devices International'' (FTDI)
  307. known as the FTDI FT2232.
  308. See: @url{http://www.ftdichip.com} or @url{http://www.ftdichip.com/Products/FT2232H.htm}
  309. As of 28/Nov/2008, the following are supported:
  310. @itemize @bullet
  311. @item @b{usbjtag}
  312. @* Link @url{http://www.hs-augsburg.de/~hhoegl/proj/usbjtag/usbjtag.html}
  313. @item @b{jtagkey}
  314. @* See: @url{http://www.amontec.com/jtagkey.shtml}
  315. @item @b{oocdlink}
  316. @* See: @url{http://www.oocdlink.com} By Joern Kaipf
  317. @item @b{signalyzer}
  318. @* See: @url{http://www.signalyzer.com}
  319. @item @b{evb_lm3s811}
  320. @* See: @url{http://www.luminarymicro.com} - The Luminary Micro Stellaris LM3S811 eval board has an FTD2232C chip built in.
  321. @item @b{olimex-jtag}
  322. @* See: @url{http://www.olimex.com}
  323. @item @b{flyswatter}
  324. @* See: @url{http://www.tincantools.com}
  325. @item @b{turtelizer2}
  326. @* See: @url{http://www.ethernut.de}, or @url{http://www.ethernut.de/en/hardware/turtelizer/index.html}
  327. @item @b{comstick}
  328. @* Link: @url{http://www.hitex.com/index.php?id=383}
  329. @item @b{stm32stick}
  330. @* Link @url{http://www.hitex.com/stm32-stick}
  331. @item @b{axm0432_jtag}
  332. @* Axiom AXM-0432 Link @url{http://www.axman.com}
  333. @end itemize
  334. @section USB JLINK based
  335. There are several OEM versions of the Segger @b{JLINK} adapter. It is
  336. an example of a micro controller based JTAG adapter, it uses an
  337. AT91SAM764 internally.
  338. @itemize @bullet
  339. @item @b{ATMEL SAMICE} Only works with ATMEL chips!
  340. @* Link: @url{http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3892}
  341. @item @b{SEGGER JLINK}
  342. @* Link: @url{http://www.segger.com/jlink.html}
  343. @item @b{IAR J-Link}
  344. @* Link: @url{http://www.iar.com/website1/1.0.1.0/369/1/index.php}
  345. @end itemize
  346. @section USB RLINK based
  347. Raisonance has an adapter called @b{RLink}. It exists in a stripped-down form on the STM32 Primer, permanently attached to the JTAG lines. It also exists on the STM32 Primer2, but that is wired for SWD and not JTAG, thus not supported.
  348. @itemize @bullet
  349. @item @b{Raisonance RLink}
  350. @* Link: @url{http://www.raisonance.com/products/RLink.php}
  351. @item @b{STM32 Primer}
  352. @* Link: @url{http://www.stm32circle.com/resources/stm32primer.php}
  353. @item @b{STM32 Primer2}
  354. @* Link: @url{http://www.stm32circle.com/resources/stm32primer2.php}
  355. @end itemize
  356. @section USB Other
  357. @itemize @bullet
  358. @item @b{USBprog}
  359. @* Link: @url{http://www.embedded-projects.net/usbprog} - which uses an Atmel MEGA32 and a UBN9604
  360. @item @b{USB - Presto}
  361. @* Link: @url{http://tools.asix.net/prg_presto.htm}
  362. @item @b{Versaloon-Link}
  363. @* Link: @url{http://www.simonqian.com/en/Versaloon}
  364. @end itemize
  365. @section IBM PC Parallel Printer Port Based
  366. The two well known ``JTAG Parallel Ports'' cables are the Xilnx DLC5
  367. and the MacGraigor Wiggler. There are many clones and variations of
  368. these on the market.
  369. @itemize @bullet
  370. @item @b{Wiggler} - There are many clones of this.
  371. @* Link: @url{http://www.macraigor.com/wiggler.htm}
  372. @item @b{DLC5} - From XILINX - There are many clones of this
  373. @* Link: Search the web for: ``XILINX DLC5'' - it is no longer
  374. produced, PDF schematics are easily found and it is easy to make.
  375. @item @b{Amontec - JTAG Accelerator}
  376. @* Link: @url{http://www.amontec.com/jtag_accelerator.shtml}
  377. @item @b{GW16402}
  378. @* Link: @url{http://www.gateworks.com/products/avila_accessories/gw16042.php}
  379. @item @b{Wiggler2}
  380. @* Link: @url{http://www.ccac.rwth-aachen.de/~michaels/index.php/hardware/armjtag}
  381. @item @b{Wiggler_ntrst_inverted}
  382. @* Yet another variation - See the source code, src/jtag/parport.c
  383. @item @b{old_amt_wiggler}
  384. @* Unknown - probably not on the market today
  385. @item @b{arm-jtag}
  386. @* Link: Most likely @url{http://www.olimex.com/dev/arm-jtag.html} [another wiggler clone]
  387. @item @b{chameleon}
  388. @* Link: @url{http://www.amontec.com/chameleon.shtml}
  389. @item @b{Triton}
  390. @* Unknown.
  391. @item @b{Lattice}
  392. @* ispDownload from Lattice Semiconductor @url{http://www.latticesemi.com/lit/docs/devtools/dlcable.pdf}
  393. @item @b{flashlink}
  394. @* From ST Microsystems, link:
  395. @url{http://www.st.com/stonline/products/literature/um/7889.pdf}
  396. Title: FlashLINK JTAG programing cable for PSD and uPSD
  397. @end itemize
  398. @section Other...
  399. @itemize @bullet
  400. @item @b{ep93xx}
  401. @* An EP93xx based linux machine using the GPIO pins directly.
  402. @item @b{at91rm9200}
  403. @* Like the EP93xx - but an ATMEL AT91RM9200 based solution using the GPIO pins on the chip.
  404. @end itemize
  405. @node Running
  406. @chapter Running
  407. @cindex running OpenOCD
  408. @cindex --configfile
  409. @cindex --debug_level
  410. @cindex --logfile
  411. @cindex --search
  412. The @option{--help} option shows:
  413. @verbatim
  414. bash$ openocd --help
  415. --help | -h display this help
  416. --version | -v display OpenOCD version
  417. --file | -f use configuration file <name>
  418. --search | -s dir to search for config files and scripts
  419. --debug | -d set debug level <0-3>
  420. --log_output | -l redirect log output to file <name>
  421. --command | -c run <command>
  422. --pipe | -p use pipes when talking to gdb
  423. @end verbatim
  424. By default OpenOCD reads the file configuration file ``openocd.cfg''
  425. in the current directory. To specify a different (or multiple)
  426. configuration file, you can use the ``-f'' option. For example:
  427. @example
  428. openocd -f config1.cfg -f config2.cfg -f config3.cfg
  429. @end example
  430. Once started, OpenOCD runs as a daemon, waiting for connections from
  431. clients (Telnet, GDB, Other).
  432. If you are having problems, you can enable internal debug messages via
  433. the ``-d'' option.
  434. Also it is possible to interleave commands w/config scripts using the
  435. @option{-c} command line switch.
  436. To enable debug output (when reporting problems or working on OpenOCD
  437. itself), use the @option{-d} command line switch. This sets the
  438. @option{debug_level} to "3", outputting the most information,
  439. including debug messages. The default setting is "2", outputting only
  440. informational messages, warnings and errors. You can also change this
  441. setting from within a telnet or gdb session using @option{debug_level
  442. <n>} @xref{debug_level}.
  443. You can redirect all output from the daemon to a file using the
  444. @option{-l <logfile>} switch.
  445. Search paths for config/script files can be added to OpenOCD by using
  446. the @option{-s <search>} switch. The current directory and the OpenOCD
  447. target library is in the search path by default.
  448. For details on the @option{-p} option. @xref{Connecting to GDB}.
  449. Note! OpenOCD will launch the GDB & telnet server even if it can not
  450. establish a connection with the target. In general, it is possible for
  451. the JTAG controller to be unresponsive until the target is set up
  452. correctly via e.g. GDB monitor commands in a GDB init script.
  453. @node Simple Configuration Files
  454. @chapter Simple Configuration Files
  455. @cindex configuration
  456. @section Outline
  457. There are 4 basic ways of ``configurating'' OpenOCD to run, they are:
  458. @enumerate
  459. @item A small openocd.cfg file which ``sources'' other configuration files
  460. @item A monolithic openocd.cfg file
  461. @item Many -f filename options on the command line
  462. @item Your Mixed Solution
  463. @end enumerate
  464. @section Small configuration file method
  465. This is the prefered method, it is simple and is works well for many
  466. people. The developers of OpenOCD would encourage you to use this
  467. method. If you create a new configuration please email new
  468. configurations to the development list.
  469. Here is an example of an openocd.cfg file for an ATMEL at91sam7x256
  470. @example
  471. source [find interface/signalyzer.cfg]
  472. # Change the default telnet port...
  473. telnet_port 4444
  474. # GDB connects here
  475. gdb_port 3333
  476. # GDB can also flash my flash!
  477. gdb_memory_map enable
  478. gdb_flash_program enable
  479. source [find target/sam7x256.cfg]
  480. @end example
  481. There are many example configuration scripts you can work with. You
  482. should look in the directory: @t{$(INSTALLDIR)/lib/openocd}. You
  483. should find:
  484. @enumerate
  485. @item @b{board} - eval board level configurations
  486. @item @b{interface} - specific dongle configurations
  487. @item @b{target} - the target chips
  488. @item @b{tcl} - helper scripts
  489. @item @b{xscale} - things specific to the xscale.
  490. @end enumerate
  491. Look first in the ``boards'' area, then the ``targets'' area. Often a board
  492. configuration is a good example to work from.
  493. @section Many -f filename options
  494. Some believe this is a wonderful solution, others find it painful.
  495. You can use a series of ``-f filename'' options on the command line,
  496. OpenOCD will read each filename in sequence, for example:
  497. @example
  498. openocd -f file1.cfg -f file2.cfg -f file2.cfg
  499. @end example
  500. You can also intermix various commands with the ``-c'' command line
  501. option.
  502. @section Monolithic file
  503. The ``Monolithic File'' dispenses with all ``source'' statements and
  504. puts everything in one self contained (monolithic) file. This is not
  505. encouraged.
  506. Please try to ``source'' various files or use the multiple -f
  507. technique.
  508. @section Advice for you
  509. Often, one uses a ``mixed approach''. Where possible, please try to
  510. ``source'' common things, and if needed cut/paste parts of the
  511. standard distribution configuration files as needed.
  512. @b{REMEMBER:} The ``important parts'' of your configuration file are:
  513. @enumerate
  514. @item @b{Interface} - Defines the dongle
  515. @item @b{Taps} - Defines the JTAG Taps
  516. @item @b{GDB Targets} - What GDB talks to
  517. @item @b{Flash Programing} - Very Helpful
  518. @end enumerate
  519. Some key things you should look at and understand are:
  520. @enumerate
  521. @item The RESET configuration of your debug environment as a hole
  522. @item Is there a ``work area'' that OpenOCD can use?
  523. @* For ARM - work areas mean up to 10x faster downloads.
  524. @item For MMU/MPU based ARM chips (ie: ARM9 and later) will that work area still be available?
  525. @item For complex targets (multiple chips) the JTAG SPEED becomes an issue.
  526. @end enumerate
  527. @node Config File Guidelines
  528. @chapter Config File Guidelines
  529. This section/chapter is aimed at developers and integrators of
  530. OpenOCD. These are guidelines for creating new boards and new target
  531. configurations as of 28/Nov/2008.
  532. However, you the user of OpenOCD should be some what familiar with
  533. this section as it should help explain some of the internals of what
  534. you might be looking at.
  535. The user should find under @t{$(INSTALLDIR)/lib/openocd} the
  536. following directories:
  537. @itemize @bullet
  538. @item @b{interface}
  539. @*Think JTAG Dongle. Files that configure the jtag dongle go here.
  540. @item @b{board}
  541. @* Thing Circuit Board, PWA, PCB, they go by many names. Board files
  542. contain initialization items that are specific to a board - for
  543. example: The SDRAM initialization sequence for the board, or the type
  544. of external flash and what address it is found at. Any initialization
  545. sequence to enable that external flash or sdram should be found in the
  546. board file. Boards may also contain multiple targets, ie: Two cpus, or
  547. a CPU and an FPGA or CPLD.
  548. @item @b{target}
  549. @* Think CHIP. The ``target'' directory represents a jtag tap (or
  550. chip) OpenOCD should control, not a board. Two common types of targets
  551. are ARM chips and FPGA or CPLD chips.
  552. @end itemize
  553. @b{If needed...} The user in their ``openocd.cfg'' file or the board
  554. file might override a specific feature in any of the above files by
  555. setting a variable or two before sourcing the target file. Or adding
  556. various commands specific to their situation.
  557. @section Interface Config Files
  558. The user should be able to source one of these files via a command like this:
  559. @example
  560. source [find interface/FOOBAR.cfg]
  561. Or:
  562. openocd -f interface/FOOBAR.cfg
  563. @end example
  564. A preconfigured interface file should exist for every interface in use
  565. today, that said, perhaps some interfaces have only been used by the
  566. sole developer who created it.
  567. @b{FIXME/NOTE:} We need to add support for a variable like TCL variable
  568. tcl_platform(platform), it should be called jim_platform (because it
  569. is jim, not real tcl) and it should contain 1 of 3 words: ``linux'',
  570. ``cygwin'' or ``mingw''
  571. Interface files should be found in @t{$(INSTALLDIR)/lib/openocd/interface}
  572. @section Board Config Files
  573. @b{Note: BOARD directory NEW as of 28/nov/2008}
  574. The user should be able to source one of these files via a command like this:
  575. @example
  576. source [find board/FOOBAR.cfg]
  577. Or:
  578. openocd -f board/FOOBAR.cfg
  579. @end example
  580. The board file should contain one or more @t{source [find
  581. target/FOO.cfg]} statements along with any board specific things.
  582. In summery the board files should contain (if present)
  583. @enumerate
  584. @item External flash configuration (ie: the flash on CS0)
  585. @item SDRAM configuration (size, speed, etc)
  586. @item Board specific IO configuration (ie: GPIO pins might disable a 2nd flash)
  587. @item Multiple TARGET source statements
  588. @item All things that are not ``inside a chip''
  589. @item Things inside a chip go in a 'target' file
  590. @end enumerate
  591. @section Target Config Files
  592. The user should be able to source one of these files via a command like this:
  593. @example
  594. source [find target/FOOBAR.cfg]
  595. Or:
  596. openocd -f target/FOOBAR.cfg
  597. @end example
  598. In summery the target files should contain
  599. @enumerate
  600. @item Set Defaults
  601. @item Create Taps
  602. @item Reset Configuration
  603. @item Work Areas
  604. @item CPU/Chip/CPU-Core Specific features
  605. @item OnChip Flash
  606. @end enumerate
  607. @subsection Important variable names
  608. By default, the end user should never need to set these
  609. variables. However, if the user needs to override a setting they only
  610. need to set the variable in a simple way.
  611. @itemize @bullet
  612. @item @b{CHIPNAME}
  613. @* This gives a name to the overall chip, and is used as part of the
  614. tap identifier dotted name.
  615. @item @b{ENDIAN}
  616. @* By default little - unless the chip or board is not normally used that way.
  617. @item @b{CPUTAPID}
  618. @* When OpenOCD examines the JTAG chain, it will attempt to identify
  619. every chip. If the @t{-expected-id} is nonzero, OpenOCD attempts
  620. to verify the tap id number verses configuration file and may issue an
  621. error or warning like this. The hope is this will help pin point
  622. problem OpenOCD configurations.
  623. @example
  624. Info: JTAG tap: sam7x256.cpu tap/device found: 0x3f0f0f0f (Manufacturer: 0x787, Part: 0xf0f0, Version: 0x3)
  625. Error: ERROR: Tap: sam7x256.cpu - Expected id: 0x12345678, Got: 0x3f0f0f0f
  626. Error: ERROR: expected: mfg: 0x33c, part: 0x2345, ver: 0x1
  627. Error: ERROR: got: mfg: 0x787, part: 0xf0f0, ver: 0x3
  628. @end example
  629. @item @b{_TARGETNAME}
  630. @* By convention, this variable is created by the target configuration
  631. script. The board configuration file may make use of this variable to
  632. configure things like a ``reset init'' script, or other things
  633. specific to that board and that target.
  634. If the chip has 2 targets, use the names @b{_TARGETNAME0},
  635. @b{_TARGETNAME1}, ... etc.
  636. @b{Remember:} The ``board file'' may include multiple targets.
  637. At no time should the name ``target0'' (the default target name if
  638. none was specified) be used. The name ``target0'' is a hard coded name
  639. - the next target on the board will be some other number.
  640. The user (or board file) should reasonably be able to:
  641. @example
  642. source [find target/FOO.cfg]
  643. $_TARGETNAME configure ... FOO specific parameters
  644. source [find target/BAR.cfg]
  645. $_TARGETNAME configure ... BAR specific parameters
  646. @end example
  647. @end itemize
  648. @subsection TCL Variables Guide Line
  649. The Full Tcl/Tk language supports ``namespaces'' - JIM-Tcl does not.
  650. Thus the rule we follow in OpenOCD is this: Variables that begin with
  651. a leading underscore are temporal in nature, and can be modified and
  652. used at will within a ?TARGET? configuration file
  653. @b{EXAMPLE:} The user should be able to do this:
  654. @example
  655. # Board has 3 chips,
  656. # PXA270 #1 network side, big endian
  657. # PXA270 #2 video side, little endian
  658. # Xilinx Glue logic
  659. set CHIPNAME network
  660. set ENDIAN big
  661. source [find target/pxa270.cfg]
  662. # variable: _TARGETNAME = network.cpu
  663. # other commands can refer to the "network.cpu" tap.
  664. $_TARGETNAME configure .... params for this cpu..
  665. set ENDIAN little
  666. set CHIPNAME video
  667. source [find target/pxa270.cfg]
  668. # variable: _TARGETNAME = video.cpu
  669. # other commands can refer to the "video.cpu" tap.
  670. $_TARGETNAME configure .... params for this cpu..
  671. unset ENDIAN
  672. set CHIPNAME xilinx
  673. source [find target/spartan3.cfg]
  674. # Since $_TARGETNAME is temporal..
  675. # these names still work!
  676. network.cpu configure ... params
  677. video.cpu configure ... params
  678. @end example
  679. @subsection Default Value Boiler Plate Code
  680. All target configuration files should start with this (or a modified form)
  681. @example
  682. # SIMPLE example
  683. if @{ [info exists CHIPNAME] @} @{
  684. set _CHIPNAME $CHIPNAME
  685. @} else @{
  686. set _CHIPNAME sam7x256
  687. @}
  688. if @{ [info exists ENDIAN] @} @{
  689. set _ENDIAN $ENDIAN
  690. @} else @{
  691. set _ENDIAN little
  692. @}
  693. if @{ [info exists CPUTAPID ] @} @{
  694. set _CPUTAPID $CPUTAPID
  695. @} else @{
  696. set _CPUTAPID 0x3f0f0f0f
  697. @}
  698. @end example
  699. @subsection Creating Taps
  700. After the ``defaults'' are choosen, [see above], the taps are created.
  701. @b{SIMPLE example:} such as an Atmel AT91SAM7X256
  702. @example
  703. # for an ARM7TDMI.
  704. set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
  705. jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  706. @end example
  707. @b{COMPLEX example:}
  708. This is an SNIP/example for an STR912 - which has 3 internal taps. Key features shown:
  709. @enumerate
  710. @item @b{Unform tap names} - See: Tap Naming Convention
  711. @item @b{_TARGETNAME} is created at the end where used.
  712. @end enumerate
  713. @example
  714. if @{ [info exists FLASHTAPID ] @} @{
  715. set _FLASHTAPID $FLASHTAPID
  716. @} else @{
  717. set _FLASHTAPID 0x25966041
  718. @}
  719. jtag newtap $_CHIPNAME flash -irlen 8 -ircapture 0x1 -irmask 0x1 -expected-id $_FLASHTAPID
  720. if @{ [info exists CPUTAPID ] @} @{
  721. set _CPUTAPID $CPUTAPID
  722. @} else @{
  723. set _CPUTAPID 0x25966041
  724. @}
  725. jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0xf -irmask 0xe -expected-id $_CPUTAPID
  726. if @{ [info exists BSTAPID ] @} @{
  727. set _BSTAPID $BSTAPID
  728. @} else @{
  729. set _BSTAPID 0x1457f041
  730. @}
  731. jtag newtap $_CHIPNAME bs -irlen 5 -ircapture 0x1 -irmask 0x1 -expected-id $_BSTAPID
  732. set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
  733. @end example
  734. @b{Tap Naming Convention}
  735. See the command ``jtag newtap'' for detail, but in breif the names you should use are:
  736. @itemize @bullet
  737. @item @b{tap}
  738. @item @b{cpu}
  739. @item @b{flash}
  740. @item @b{bs}
  741. @item @b{jrc}
  742. @item @b{unknownN} - it happens :-(
  743. @end itemize
  744. @subsection Reset Configuration
  745. Some chips have specific ways the TRST and SRST signals are
  746. managed. If these are @b{CHIP SPECIFIC} they go here, if they are
  747. @b{BOARD SPECIFIC} they go in the board file.
  748. @subsection Work Areas
  749. Work areas are small RAM areas used by OpenOCD to speed up downloads,
  750. and to download small snippits of code to program flash chips.
  751. If the chip includes an form of ``on-chip-ram'' - and many do - define
  752. a reasonable work area and use the ``backup'' option.
  753. @b{PROBLEMS:} On more complex chips, this ``work area'' may become
  754. inaccessable if/when the application code enables or disables the MMU.
  755. @subsection ARM Core Specific Hacks
  756. If the chip has a DCC, enable it. If the chip is an arm9 with some
  757. special high speed download - enable it.
  758. If the chip has an ARM ``vector catch'' feature - by defeault enable
  759. it for Undefined Instructions, Data Abort, and Prefetch Abort, if the
  760. user is really writing a handler for those situations - they can
  761. easily disable it. Experiance has shown the ``vector catch'' is
  762. helpful - for common programing errors.
  763. If present, the MMU, the MPU and the CACHE should be disabled.
  764. @subsection Internal Flash Configuration
  765. This applies @b{ONLY TO MICROCONTROLLERS} that have flash built in.
  766. @b{Never ever} in the ``target configuration file'' define any type of
  767. flash that is external to the chip. (For example the BOOT flash on
  768. Chip Select 0). The BOOT flash information goes in a board file - not
  769. the TARGET (chip) file.
  770. Examples:
  771. @itemize @bullet
  772. @item at91sam7x256 - has 256K flash YES enable it.
  773. @item str912 - has flash internal YES enable it.
  774. @item imx27 - uses boot flash on CS0 - it goes in the board file.
  775. @item pxa270 - again - CS0 flash - it goes in the board file.
  776. @end itemize
  777. @node About JIM-Tcl
  778. @chapter About JIM-Tcl
  779. @cindex JIM Tcl
  780. @cindex tcl
  781. OpenOCD includes a small ``TCL Interpreter'' known as JIM-TCL. You can
  782. learn more about JIM here: @url{http://jim.berlios.de}
  783. @itemize @bullet
  784. @item @b{JIM vrs TCL}
  785. @* JIM-TCL is a stripped down version of the well known Tcl language,
  786. which can be found here: @url{http://www.tcl.tk}. JIM-Tcl has far
  787. fewer features. JIM-Tcl is a single .C file and a single .H file and
  788. impliments the basic TCL command set along. In contrast: Tcl 8.6 is a
  789. 4.2MEG zip file containing 1540 files.
  790. @item @b{Missing Features}
  791. @* Our practice has been: Add/clone the Real TCL feature if/when
  792. needed. We welcome JIM Tcl improvements, not bloat.
  793. @item @b{Scripts}
  794. @* OpenOCD configuration scripts are JIM Tcl Scripts. OpenOCD's
  795. command interpretor today (28/nov/2008) is a mixture of (newer)
  796. JIM-Tcl commands, and (older) the orginal command interpretor.
  797. @item @b{Commands}
  798. @* At the OpenOCD telnet command line (or via the GDB mon command) one
  799. can type a Tcl for() loop, set variables, etc.
  800. @item @b{Historical Note}
  801. @* JIM-Tcl was introduced to OpenOCD in Spring 2008.
  802. @item @b{Need a Crash Course In TCL?}
  803. @* See: @xref{TCL Crash Course}.
  804. @end itemize
  805. @node Daemon Configuration
  806. @chapter Daemon Configuration
  807. The commands here are commonly found in the openocd.cfg file and are
  808. used to specify what TCP/IP ports are used, and how GDB should be
  809. supported.
  810. @section init
  811. @cindex init
  812. This command terminates the configuration stage and
  813. enters the normal command mode. This can be useful to add commands to
  814. the startup scripts and commands such as resetting the target,
  815. programming flash, etc. To reset the CPU upon startup, add "init" and
  816. "reset" at the end of the config script or at the end of the OpenOCD
  817. command line using the @option{-c} command line switch.
  818. If this command does not appear in any startup/configuration file
  819. OpenOCD executes the command for you after processing all
  820. configuration files and/or command line options.
  821. @b{NOTE:} This command normally occurs at or near the end of your
  822. openocd.cfg file to force OpenOCD to ``initialize'' and make the
  823. targets ready. For example: If your openocd.cfg file needs to
  824. read/write memory on your target - the init command must occur before
  825. the memory read/write commands.
  826. @section TCP/IP Ports
  827. @itemize @bullet
  828. @item @b{telnet_port} <@var{number}>
  829. @cindex telnet_port
  830. @*Intended for a human. Port on which to listen for incoming telnet connections.
  831. @item @b{tcl_port} <@var{number}>
  832. @cindex tcl_port
  833. @*Intended as a machine interface. Port on which to listen for
  834. incoming TCL syntax. This port is intended as a simplified RPC
  835. connection that can be used by clients to issue commands and get the
  836. output from the TCL engine.
  837. @item @b{gdb_port} <@var{number}>
  838. @cindex gdb_port
  839. @*First port on which to listen for incoming GDB connections. The GDB port for the
  840. first target will be gdb_port, the second target will listen on gdb_port + 1, and so on.
  841. @end itemize
  842. @section GDB Items
  843. @itemize @bullet
  844. @item @b{gdb_breakpoint_override} <@var{hard|soft|disabled}>
  845. @cindex gdb_breakpoint_override
  846. @anchor{gdb_breakpoint_override}
  847. @*Force breakpoint type for gdb 'break' commands.
  848. The raison d'etre for this option is to support GDB GUI's without
  849. a hard/soft breakpoint concept where the default OpenOCD and
  850. GDB behaviour is not sufficient. Note that GDB will use hardware
  851. breakpoints if the memory map has been set up for flash regions.
  852. This option replaces older arm7_9 target commands that addressed
  853. the same issue.
  854. @item @b{gdb_detach} <@var{resume|reset|halt|nothing}>
  855. @cindex gdb_detach
  856. @*Configures what OpenOCD will do when gdb detaches from the daeman.
  857. Default behaviour is <@var{resume}>
  858. @item @b{gdb_memory_map} <@var{enable|disable}>
  859. @cindex gdb_memory_map
  860. @*Set to <@var{enable}> to cause OpenOCD to send the memory configuration to gdb when
  861. requested. gdb will then know when to set hardware breakpoints, and program flash
  862. using the gdb load command. @option{gdb_flash_program enable} will also need enabling
  863. for flash programming to work.
  864. Default behaviour is <@var{enable}>
  865. @xref{gdb_flash_program}.
  866. @item @b{gdb_flash_program} <@var{enable|disable}>
  867. @cindex gdb_flash_program
  868. @anchor{gdb_flash_program}
  869. @*Set to <@var{enable}> to cause OpenOCD to program the flash memory when a
  870. vFlash packet is received.
  871. Default behaviour is <@var{enable}>
  872. @comment END GDB Items
  873. @end itemize
  874. @node Interface - Dongle Configuration
  875. @chapter Interface - Dongle Configuration
  876. Interface commands are normally found in an interface configuration
  877. file which is sourced by your openocd.cfg file. These commands tell
  878. OpenOCD what type of JTAG dongle you have and how to talk to it.
  879. @section Simple Complete Interface Examples
  880. @b{A Turtelizer FT2232 Based JTAG Dongle}
  881. @verbatim
  882. #interface
  883. interface ft2232
  884. ft2232_device_desc "Turtelizer JTAG/RS232 Adapter A"
  885. ft2232_layout turtelizer2
  886. ft2232_vid_pid 0x0403 0xbdc8
  887. @end verbatim
  888. @b{A SEGGER Jlink}
  889. @verbatim
  890. # jlink interface
  891. interface jlink
  892. @end verbatim
  893. @b{A Raisonance RLink}
  894. @verbatim
  895. # rlink interface
  896. interface rlink
  897. @end verbatim
  898. @b{Parallel Port}
  899. @verbatim
  900. interface parport
  901. parport_port 0xc8b8
  902. parport_cable wiggler
  903. jtag_speed 0
  904. @end verbatim
  905. @section Interface Conmmand
  906. The interface command tells OpenOCD what type of jtag dongle you are
  907. using. Depending upon the type of dongle, you may need to have one or
  908. more additional commands.
  909. @itemize @bullet
  910. @item @b{interface} <@var{name}>
  911. @cindex interface
  912. @*Use the interface driver <@var{name}> to connect to the
  913. target. Currently supported interfaces are
  914. @itemize @minus
  915. @item @b{parport}
  916. @* PC parallel port bit-banging (Wigglers, PLD download cable, ...)
  917. @item @b{amt_jtagaccel}
  918. @* Amontec Chameleon in its JTAG Accelerator configuration connected to a PC's EPP
  919. mode parallel port
  920. @item @b{ft2232}
  921. @* FTDI FT2232 (USB) based devices using either the open-source libftdi or the binary only
  922. FTD2XX driver. The FTD2XX is superior in performance, but not available on every
  923. platform. The libftdi uses libusb, and should be portable to all systems that provide
  924. libusb.
  925. @item @b{ep93xx}
  926. @*Cirrus Logic EP93xx based single-board computer bit-banging (in development)
  927. @item @b{presto}
  928. @* ASIX PRESTO USB JTAG programmer.
  929. @item @b{usbprog}
  930. @* usbprog is a freely programmable USB adapter.
  931. @item @b{gw16012}
  932. @* Gateworks GW16012 JTAG programmer.
  933. @item @b{jlink}
  934. @* Segger jlink usb adapter
  935. @item @b{rlink}
  936. @* Raisonance RLink usb adapter
  937. @item @b{vsllink}
  938. @* vsllink is part of Versaloon which is a versatile USB programmer.
  939. @comment - End parameters
  940. @end itemize
  941. @comment - End Interface
  942. @end itemize
  943. @subsection parport options
  944. @itemize @bullet
  945. @item @b{parport_port} <@var{number}>
  946. @cindex parport_port
  947. @*Either the address of the I/O port (default: 0x378 for LPT1) or the number of
  948. the @file{/dev/parport} device
  949. When using PPDEV to access the parallel port, use the number of the parallel port:
  950. @option{parport_port 0} (the default). If @option{parport_port 0x378} is specified
  951. you may encounter a problem.
  952. @item @b{parport_cable} <@var{name}>
  953. @cindex parport_cable
  954. @*The layout of the parallel port cable used to connect to the target.
  955. Currently supported cables are
  956. @itemize @minus
  957. @item @b{wiggler}
  958. @cindex wiggler
  959. The original Wiggler layout, also supported by several clones, such
  960. as the Olimex ARM-JTAG
  961. @item @b{wiggler2}
  962. @cindex wiggler2
  963. Same as original wiggler except an led is fitted on D5.
  964. @item @b{wiggler_ntrst_inverted}
  965. @cindex wiggler_ntrst_inverted
  966. Same as original wiggler except TRST is inverted.
  967. @item @b{old_amt_wiggler}
  968. @cindex old_amt_wiggler
  969. The Wiggler configuration that comes with Amontec's Chameleon Programmer. The new
  970. version available from the website uses the original Wiggler layout ('@var{wiggler}')
  971. @item @b{chameleon}
  972. @cindex chameleon
  973. The Amontec Chameleon's CPLD when operated in configuration mode. This is only used to
  974. program the Chameleon itself, not a connected target.
  975. @item @b{dlc5}
  976. @cindex dlc5
  977. The Xilinx Parallel cable III.
  978. @item @b{triton}
  979. @cindex triton
  980. The parallel port adapter found on the 'Karo Triton 1 Development Board'.
  981. This is also the layout used by the HollyGates design
  982. (see @uref{http://www.lartmaker.nl/projects/jtag/}).
  983. @item @b{flashlink}
  984. @cindex flashlink
  985. The ST Parallel cable.
  986. @item @b{arm-jtag}
  987. @cindex arm-jtag
  988. Same as original wiggler except SRST and TRST connections reversed and
  989. TRST is also inverted.
  990. @item @b{altium}
  991. @cindex altium
  992. Altium Universal JTAG cable.
  993. @end itemize
  994. @item @b{parport_write_on_exit} <@var{on}|@var{off}>
  995. @cindex parport_write_on_exit
  996. @*This will configure the parallel driver to write a known value to the parallel
  997. interface on exiting OpenOCD
  998. @end itemize
  999. @subsection amt_jtagaccel options
  1000. @itemize @bullet
  1001. @item @b{parport_port} <@var{number}>
  1002. @cindex parport_port
  1003. @*Either the address of the I/O port (default: 0x378 for LPT1) or the number of the
  1004. @file{/dev/parport} device
  1005. @end itemize
  1006. @subsection ft2232 options
  1007. @itemize @bullet
  1008. @item @b{ft2232_device_desc} <@var{description}>
  1009. @cindex ft2232_device_desc
  1010. @*The USB device description of the FTDI FT2232 device. If not
  1011. specified, the FTDI default value is used. This setting is only valid
  1012. if compiled with FTD2XX support.
  1013. @b{TODO:} Confirm the following: On windows the name needs to end with
  1014. a ``space A''? Or not? It has to do with the FTD2xx driver. When must
  1015. this be added and when must it not be added? Why can't the code in the
  1016. interface or in OpenOCD automatically add this if needed? -- Duane.
  1017. @item @b{ft2232_serial} <@var{serial-number}>
  1018. @cindex ft2232_serial
  1019. @*The serial number of the FTDI FT2232 device. If not specified, the FTDI default
  1020. values are used.
  1021. @item @b{ft2232_layout} <@var{name}>
  1022. @cindex ft2232_layout
  1023. @*The layout of the FT2232 GPIO signals used to control output-enables and reset
  1024. signals. Valid layouts are
  1025. @itemize @minus
  1026. @item @b{usbjtag}
  1027. "USBJTAG-1" layout described in the original OpenOCD diploma thesis
  1028. @item @b{jtagkey}
  1029. Amontec JTAGkey and JTAGkey-tiny
  1030. @item @b{signalyzer}
  1031. Signalyzer
  1032. @item @b{olimex-jtag}
  1033. Olimex ARM-USB-OCD
  1034. @item @b{m5960}
  1035. American Microsystems M5960
  1036. @item @b{evb_lm3s811}
  1037. Luminary Micro EVB_LM3S811 as a JTAG interface (not onboard processor), no TRST or
  1038. SRST signals on external connector
  1039. @item @b{comstick}
  1040. Hitex STR9 comstick
  1041. @item @b{stm32stick}
  1042. Hitex STM32 Performance Stick
  1043. @item @b{flyswatter}
  1044. Tin Can Tools Flyswatter
  1045. @item @b{turtelizer2}
  1046. egnite Software turtelizer2
  1047. @item @b{oocdlink}
  1048. OOCDLink
  1049. @item @b{axm0432_jtag}
  1050. Axiom AXM-0432
  1051. @end itemize
  1052. @item @b{ft2232_vid_pid} <@var{vid}> <@var{pid}>
  1053. @*The vendor ID and product ID of the FTDI FT2232 device. If not specified, the FTDI
  1054. default values are used. Multiple <@var{vid}>, <@var{pid}> pairs may be given, eg.
  1055. @example
  1056. ft2232_vid_pid 0x0403 0xcff8 0x15ba 0x0003
  1057. @end example
  1058. @item @b{ft2232_latency} <@var{ms}>
  1059. @*On some systems using ft2232 based JTAG interfaces the FT_Read function call in
  1060. ft2232_read() fails to return the expected number of bytes. This can be caused by
  1061. USB communication delays and has proved hard to reproduce and debug. Setting the
  1062. FT2232 latency timer to a larger value increases delays for short USB packages but it
  1063. also reduces the risk of timeouts before receiving the expected number of bytes.
  1064. The OpenOCD default value is 2 and for some systems a value of 10 has proved useful.
  1065. @end itemize
  1066. @subsection ep93xx options
  1067. @cindex ep93xx options
  1068. Currently, there are no options available for the ep93xx interface.
  1069. @section JTAG Speed
  1070. @itemize @bullet
  1071. @item @b{jtag_khz} <@var{reset speed kHz}>
  1072. @cindex jtag_khz
  1073. It is debatable if this command belongs here - or in a board
  1074. configuration file. In fact, in some situations the jtag speed is
  1075. changed during the target initialization process (ie: (1) slow at
  1076. reset, (2) program the cpu clocks, (3) run fast)
  1077. Speed 0 (khz) selects RTCK method. A non-zero speed is in KHZ. Hence: 3000 is 3mhz.
  1078. Not all interfaces support ``rtck''. If the interface device can not
  1079. support the rate asked for, or can not translate from kHz to
  1080. jtag_speed, then an error is returned.
  1081. Make sure the jtag clock is no more than @math{1/6th × CPU-Clock}. This is
  1082. especially true for synthesized cores (-S). Also see RTCK.
  1083. @b{NOTE: Script writers} If the target chip requires/uses RTCK -
  1084. please use the command: 'jtag_rclk FREQ'. This TCL proc (in
  1085. startup.tcl) attempts to enable RTCK, if that fails it falls back to
  1086. the specified frequency.
  1087. @example
  1088. # Fall back to 3mhz if RCLK is not supported
  1089. jtag_rclk 3000
  1090. @end example
  1091. @item @b{DEPRICATED} @b{jtag_speed} - please use jtag_khz above.
  1092. @cindex jtag_speed
  1093. @*Limit the maximum speed of the JTAG interface. Usually, a value of zero means maximum
  1094. speed. The actual effect of this option depends on the JTAG interface used.
  1095. The speed used during reset can be adjusted using setting jtag_speed during
  1096. pre_reset and post_reset events.
  1097. @itemize @minus
  1098. @item wiggler: maximum speed / @var{number}
  1099. @item ft2232: 6MHz / (@var{number}+1)
  1100. @item amt jtagaccel: 8 / 2**@var{number}
  1101. @item jlink: maximum speed in kHz (0-12000), 0 will use RTCK
  1102. @item rlink: 24MHz / @var{number}, but only for certain values of @var{number}
  1103. @comment end speed list.
  1104. @end itemize
  1105. @comment END command list
  1106. @end itemize
  1107. @node Reset Configuration
  1108. @chapter Reset Configuration
  1109. @cindex reset configuration
  1110. Every system configuration may require a different reset
  1111. configuration. This can also be quite confusing. Please see the
  1112. various board files for example.
  1113. @section jtag_nsrst_delay <@var{ms}>
  1114. @cindex jtag_nsrst_delay
  1115. @*How long (in milliseconds) OpenOCD should wait after deasserting
  1116. nSRST before starting new JTAG operations.
  1117. @section jtag_ntrst_delay <@var{ms}>
  1118. @cindex jtag_ntrst_delay
  1119. @*Same @b{jtag_nsrst_delay}, but for nTRST
  1120. The jtag_n[st]rst_delay options are useful if reset circuitry (like a
  1121. big resistor/capacitor, reset supervisor, or on-chip features). This
  1122. keeps the signal asserted for some time after the external reset got
  1123. deasserted.
  1124. @section reset_config
  1125. @b{Note:} To maintainer types and integrators. Where exactly the
  1126. ``reset configuration'' goes is a good question. It touches several
  1127. things at once. In the end, if you have a board file - the board file
  1128. should define it and assume 100% that the DONGLE supports
  1129. anything. However, that does not mean the target should not also make
  1130. not of something the silicon vendor has done inside the
  1131. chip. @i{Grr.... nothing is every pretty.}
  1132. @* @b{Problems:}
  1133. @enumerate
  1134. @item Every JTAG Dongle is slightly different, some dongles impliment reset differently.
  1135. @item Every board is also slightly different; some boards tie TRST and SRST together.
  1136. @item Every chip is slightly different; some chips internally tie the two signals together.
  1137. @item Some may not impliment all of the signals the same way.
  1138. @item Some signals might be push-pull, others open-drain/collector.
  1139. @end enumerate
  1140. @b{Best Case:} OpenOCD can hold the SRST (push-button-reset), then
  1141. reset the TAP via TRST and send commands through the JTAG tap to halt
  1142. the CPU at the reset vector before the 1st instruction is executed,
  1143. and finally release the SRST signal.
  1144. @*Depending upon your board vendor, your chip vendor, etc, these
  1145. signals may have slightly different names.
  1146. OpenOCD defines these signals in these terms:
  1147. @itemize @bullet
  1148. @item @b{TRST} - is Tap Reset - and should reset only the TAP.
  1149. @item @b{SRST} - is System Reset - typically equal to a reset push button.
  1150. @end itemize
  1151. The Command:
  1152. @itemize @bullet
  1153. @item @b{reset_config} <@var{signals}> [@var{combination}] [@var{trst_type}] [@var{srst_type}]
  1154. @cindex reset_config
  1155. @* The @t{reset_config} command tells OpenOCD the reset configuration
  1156. of your combination of Dongle, Board, and Chips.
  1157. If the JTAG interface provides SRST, but the target doesn't connect
  1158. that signal properly, then OpenOCD can't use it. <@var{signals}> can
  1159. be @option{none}, @option{trst_only}, @option{srst_only} or
  1160. @option{trst_and_srst}.
  1161. [@var{combination}] is an optional value specifying broken reset
  1162. signal implementations. @option{srst_pulls_trst} states that the
  1163. testlogic is reset together with the reset of the system (e.g. Philips
  1164. LPC2000, "broken" board layout), @option{trst_pulls_srst} says that
  1165. the system is reset together with the test logic (only hypothetical, I
  1166. haven't seen hardware with such a bug, and can be worked around).
  1167. @option{combined} imples both @option{srst_pulls_trst} and
  1168. @option{trst_pulls_srst}. The default behaviour if no option given is
  1169. @option{separate}.
  1170. The [@var{trst_type}] and [@var{srst_type}] parameters allow the
  1171. driver type of the reset lines to be specified. Possible values are
  1172. @option{trst_push_pull} (default) and @option{trst_open_drain} for the
  1173. test reset signal, and @option{srst_open_drain} (default) and
  1174. @option{srst_push_pull} for the system reset. These values only affect
  1175. JTAG interfaces with support for different drivers, like the Amontec
  1176. JTAGkey and JTAGAccelerator.
  1177. @comment - end command
  1178. @end itemize
  1179. @node Tap Creation
  1180. @chapter Tap Creation
  1181. @cindex tap creation
  1182. @cindex tap configuration
  1183. In order for OpenOCD to control a target, a JTAG tap must be
  1184. defined/created.
  1185. Commands to create taps are normally found in a configuration file and
  1186. are not normally typed by a human.
  1187. When a tap is created a @b{dotted.name} is created for the tap. Other
  1188. commands use that dotted.name to manipulate or refer to the tap.
  1189. Tap Uses:
  1190. @itemize @bullet
  1191. @item @b{Debug Target} A tap can be used by a GDB debug target
  1192. @item @b{Flash Programing} Some chips program the flash via JTAG
  1193. @item @b{Boundry Scan} Some chips support boundry scan.
  1194. @end itemize
  1195. @section jtag newtap
  1196. @b{@t{jtag newtap CHIPNAME TAPNAME configparams ....}}
  1197. @cindex jtag_device
  1198. @cindex jtag newtap
  1199. @cindex tap
  1200. @cindex tap order
  1201. @cindex tap geometry
  1202. @comment START options
  1203. @itemize @bullet
  1204. @item @b{CHIPNAME}
  1205. @* is a symbolic name of the chip.
  1206. @item @b{TAPNAME}
  1207. @* is a symbol name of a tap present on the chip.
  1208. @item @b{Required configparams}
  1209. @* Every tap has 3 required configparams, and several ``optional
  1210. parameters'', the required parameters are:
  1211. @comment START REQUIRED
  1212. @itemize @bullet
  1213. @item @b{-irlen NUMBER} - the length in bits of the instruction register
  1214. @item @b{-ircapture NUMBER} - the ID code capture command.
  1215. @item @b{-irmask NUMBER} - the corresponding mask for the ir register.
  1216. @comment END REQUIRED
  1217. @end itemize
  1218. An example of a FOOBAR Tap
  1219. @example
  1220. jtag newtap foobar tap -irlen 7 -ircapture 0x42 -irmask 0x55
  1221. @end example
  1222. Creates the tap ``foobar.tap'' with the instruction register (IR) is 7
  1223. bits long, during Capture-IR 0x42 is loaded into the IR, and bits
  1224. [6,4,2,0] are checked.
  1225. @item @b{Optional configparams}
  1226. @comment START Optional
  1227. @itemize @bullet
  1228. @item @b{-expected-id NUMBER}
  1229. @* By default it is zero. If non-zero represents the
  1230. expected tap ID used when the Jtag Chain is examined. See below.
  1231. @item @b{-disable}
  1232. @item @b{-enable}
  1233. @* By default not specified the tap is enabled. Some chips have a
  1234. jtag route controller (JRC) that is used to enable and/or disable
  1235. specific jtag taps. You can later enable or disable any JTAG tap via
  1236. the command @b{jtag tapenable DOTTED.NAME} or @b{jtag tapdisable
  1237. DOTTED.NAME}
  1238. @comment END Optional
  1239. @end itemize
  1240. @comment END OPTIONS
  1241. @end itemize
  1242. @b{Notes:}
  1243. @comment START NOTES
  1244. @itemize @bullet
  1245. @item @b{Technically}
  1246. @* newtap is a sub command of the ``jtag'' command
  1247. @item @b{Big Picture Background}
  1248. @*GDB Talks to OpenOCD using the GDB protocol via
  1249. tcpip. OpenOCD then uses the JTAG interface (the dongle) to
  1250. control the JTAG chain on your board. Your board has one or more chips
  1251. in a @i{daisy chain configuration}. Each chip may have one or more
  1252. jtag taps. GDB ends up talking via OpenOCD to one of the taps.
  1253. @item @b{NAME Rules}
  1254. @*Names follow ``C'' symbol name rules (start with alpha ...)
  1255. @item @b{TAPNAME - Conventions}
  1256. @itemize @bullet
  1257. @item @b{tap} - should be used only FPGA or CPLD like devices with a single tap.
  1258. @item @b{cpu} - the main cpu of the chip, alternatively @b{foo.arm} and @b{foo.dsp}
  1259. @item @b{flash} - if the chip has a flash tap, example: str912.flash
  1260. @item @b{bs} - for boundary scan if this is a seperate tap.
  1261. @item @b{jrc} - for jtag route controller (example: OMAP3530 found on Beagleboards)
  1262. @item @b{unknownN} - where N is a number if you have no idea what the tap is for
  1263. @item @b{Other names} - Freescale IMX31 has a SDMA (smart dma) with a JTAG tap, that tap should be called the ``sdma'' tap.
  1264. @item @b{When in doubt} - use the chip makers name in their data sheet.
  1265. @end itemize
  1266. @item @b{DOTTED.NAME}
  1267. @* @b{CHIPNAME}.@b{TAPNAME} creates the tap name, aka: the
  1268. @b{Dotted.Name} is the @b{CHIPNAME} and @b{TAPNAME} combined with a
  1269. dot (period); for example: @b{xilinx.tap}, @b{str912.flash},
  1270. @b{omap3530.jrc}, or @b{stm32.cpu} The @b{dotted.name} is used in
  1271. numerous other places to refer to various taps.
  1272. @item @b{ORDER}
  1273. @* The order this command appears via the config files is
  1274. important.
  1275. @item @b{Multi Tap Example}
  1276. @* This example is based on the ST Microsystems STR912. See the ST
  1277. document titled: @b{STR91xFAxxx, Section 3.15 Jtag Interface, Page:
  1278. 28/102, Figure 3: Jtag chaining inside the STR91xFA}.
  1279. @url{http://eu.st.com/stonline/products/literature/ds/13495.pdf}
  1280. @*@b{checked: 28/nov/2008}
  1281. The diagram shows the TDO pin connects to the flash tap, flash TDI
  1282. connects to the CPU debug tap, CPU TDI connects to the boundary scan
  1283. tap which then connects to the TDI pin.
  1284. @example
  1285. # The order is...
  1286. # create tap: 'str912.flash'
  1287. jtag newtap str912 flash ... params ...
  1288. # create tap: 'str912.cpu'
  1289. jtag newtap str912 cpu ... params ...
  1290. # create tap: 'str912.bs'
  1291. jtag newtap str912 bs ... params ...
  1292. @end example
  1293. @item @b{Note: Deprecated} - Index Numbers
  1294. @* Prior to 28/nov/2008, JTAG taps where numbered from 0..N this
  1295. feature is still present, however its use is highly discouraged and
  1296. should not be counted upon.
  1297. @item @b{Multiple chips}
  1298. @* If your board has multiple chips, you should be
  1299. able to @b{source} two configuration files, in the proper order, and
  1300. have the taps created in the proper order.
  1301. @comment END NOTES
  1302. @end itemize
  1303. @comment at command level
  1304. @comment DOCUMENT old command
  1305. @section jtag_device - REMOVED
  1306. @example
  1307. @b{jtag_device} <@var{IR length}> <@var{IR capture}> <@var{IR mask}> <@var{IDCODE instruction}>
  1308. @end example
  1309. @cindex jtag_device
  1310. @* @b{Removed: 28/nov/2008} This command has been removed and replaced
  1311. by the ``jtag newtap'' command. The documentation remains here so that
  1312. one can easily convert the old syntax to the new syntax. About the old
  1313. syntax: The old syntax is positional, ie: The 3rd parameter is the
  1314. ``irmask''. The new syntax requires named prefixes, and supports
  1315. additional options, for example ``-expected-id 0x3f0f0f0f''. Please refer to the
  1316. @b{jtag newtap} command for details.
  1317. @example
  1318. OLD: jtag_device 8 0x01 0xe3 0xfe
  1319. NEW: jtag newtap CHIPNAME TAPNAME -irlen 8 -ircapture 0x01 -irmask 0xe3
  1320. @end example
  1321. @section Enable/Disable Taps
  1322. @b{Note:} These commands are intended to be used as a machine/script
  1323. interface. Humans might find the ``scan_chain'' command more helpful
  1324. when querying the state of the JTAG taps.
  1325. @b{By default, all taps are enabled}
  1326. @itemize @bullet
  1327. @item @b{jtag tapenable} @var{DOTTED.NAME}
  1328. @item @b{jtag tapdisable} @var{DOTTED.NAME}
  1329. @item @b{jtag tapisenabled} @var{DOTTED.NAME}
  1330. @end itemize
  1331. @cindex tap enable
  1332. @cindex tap disable
  1333. @cindex JRC
  1334. @cindex route controller
  1335. These commands are used when your target has a JTAG Route controller
  1336. that effectively adds or removes a tap from the jtag chain in a
  1337. non-standard way.
  1338. The ``standard way'' to remove a tap would be to place the tap in
  1339. bypass mode. But with the advent of modern chips, this is not always a
  1340. good solution. Some taps operate slowly, others operate fast, and
  1341. there are other JTAG clock syncronization problems one must face. To
  1342. solve that problem, the JTAG Route controller was introduced. Rather
  1343. then ``bypass'' the tap, the tap is completely removed from the
  1344. circuit and skipped.
  1345. From OpenOCD's view point, a JTAG TAP is in one of 3 states:
  1346. @itemize @bullet
  1347. @item @b{Enabled - Not In ByPass} and has a variable bit length
  1348. @item @b{Enabled - In ByPass} and has a length of exactly 1 bit.
  1349. @item @b{Disabled} and has a length of ZERO and is removed from the circuit.
  1350. @end itemize
  1351. The IEEE JTAG definition has no concept of a ``disabled'' tap.
  1352. @b{Historical note:} this feature was added 28/nov/2008
  1353. @b{jtag tapisenabled DOTTED.NAME}
  1354. This command returns 1 if the named tap is currently enabled, 0 if not.
  1355. This command exists so that scripts that manipulate a JRC (like the
  1356. Omap3530 has) can determine if OpenOCD thinks a tap is presently
  1357. enabled, or disabled.
  1358. @page
  1359. @node Target Configuration
  1360. @chapter Target Configuration
  1361. This chapter discusses how to create a GDB Debug Target. Before
  1362. creating a ``target'' a JTAG Tap DOTTED.NAME must exist first.
  1363. @section targets [NAME]
  1364. @b{Note:} This command name is PLURAL - not singular.
  1365. With NO parameter, this plural @b{targets} command lists all known
  1366. targets in a human friendly form.
  1367. With a parameter, this pural @b{targets} command sets the current
  1368. target to the given name. (ie: If there are multiple debug targets)
  1369. Example:
  1370. @verbatim
  1371. (gdb) mon targets
  1372. CmdName Type Endian ChainPos State
  1373. -- ---------- ---------- ---------- -------- ----------
  1374. 0: target0 arm7tdmi little 0 halted
  1375. @end verbatim
  1376. @section target COMMANDS
  1377. @b{Note:} This command name is SINGULAR - not plural. It is used to
  1378. manipulate specific targets, to create targets and other things.
  1379. Once a target is created, a TARGETNAME (object) command is created;
  1380. see below for details.
  1381. The TARGET command accepts these sub-commands:
  1382. @itemize @bullet
  1383. @item @b{create} .. parameters ..
  1384. @* creates a new target, See below for details.
  1385. @item @b{types}
  1386. @* Lists all supported target types (perhaps some are not yet in this document).
  1387. @item @b{names}
  1388. @* Lists all current debug target names, for example: 'str912.cpu' or 'pxa27.cpu' example usage:
  1389. @verbatim
  1390. foreach t [target names] {
  1391. puts [format "Target: %s\n" $t]
  1392. }
  1393. @end verbatim
  1394. @item @b{current}
  1395. @* Returns the current target. OpenOCD always has, or refers to the ``current target'' in some way.
  1396. By default, commands like: ``mww'' (used to write memory) operate on the current target.
  1397. @item @b{number} @b{NUMBER}
  1398. @* Internally OpenOCD maintains a list of targets - in numerical index
  1399. (0..N-1) this command returns the name of the target at index N.
  1400. Example usage:
  1401. @verbatim
  1402. set thename [target number $x]
  1403. puts [format "Target %d is: %s\n" $x $thename]
  1404. @end verbatim
  1405. @item @b{count}
  1406. @* Returns the number of targets known to OpenOCD (see number above)
  1407. Example:
  1408. @verbatim
  1409. set c [target count]
  1410. for { set x 0 } { $x < $c } { incr x } {
  1411. # Assuming you have created this function
  1412. print_target_details $x
  1413. }
  1414. @end verbatim
  1415. @end itemize
  1416. @section TARGETNAME (object) commands
  1417. @b{Use:} Once a target is created, an ``object name'' that represents the
  1418. target is created. By convention, the target name is identical to the
  1419. tap name. In a multiple target system, one can preceed many common
  1420. commands with a specific target name and effect only that target.
  1421. @example
  1422. str912.cpu mww 0x1234 0x42
  1423. omap3530.cpu mww 0x5555 123
  1424. @end example
  1425. @b{Model:} The Tcl/Tk language has the concept of object commands. A
  1426. good example is a on screen button, once a button is created a button
  1427. has a name (a path in TK terms) and that name is useable as a 1st
  1428. class command. For example in TK, one can create a button and later
  1429. configure it like this:
  1430. @example
  1431. # Create
  1432. button .foobar -background red -command @{ foo @}
  1433. # Modify
  1434. .foobar configure -foreground blue
  1435. # Query
  1436. set x [.foobar cget -background]
  1437. # Report
  1438. puts [format "The button is %s" $x]
  1439. @end example
  1440. In OpenOCD's terms, the ``target'' is an object just like a Tcl/Tk
  1441. button. Commands avaialble as a ``target object'' are:
  1442. @comment START targetobj commands.
  1443. @itemize @bullet
  1444. @item @b{configure} - configure the target; see Target Config/Cget Options below
  1445. @item @b{cget} - query the target configuration; see Target Config/Cget Options below
  1446. @item @b{curstate} - current target state (running, halt, etc)
  1447. @item @b{eventlist}
  1448. @* Intended for a human to see/read the currently configure target events.
  1449. @item @b{Various Memory Commands} See the ``mww'' command elsewhere.
  1450. @comment start memory
  1451. @itemize @bullet
  1452. @item @b{mww} ...
  1453. @item @b{mwh} ...
  1454. @item @b{mwb} ...
  1455. @item @b{mdw} ...
  1456. @item @b{mdh} ...
  1457. @item @b{mdb} ...
  1458. @comment end memory
  1459. @end itemize
  1460. @item @b{Memory To Array, Array To Memory}
  1461. @* These are aimed at a machine interface to memory
  1462. @itemize @bullet
  1463. @item @b{mem2array ARRAYNAME WIDTH ADDRESS COUNT}
  1464. @item @b{array2mem ARRAYNAME WIDTH ADDRESS COUNT}
  1465. @* Where:
  1466. @* @b{ARRAYNAME} is the name of an array variable
  1467. @* @b{WIDTH} is 8/16/32 - indicating the memory access size
  1468. @* @b{ADDRESS} is the target memory address
  1469. @* @b{COUNT} is the number of elements to process
  1470. @end itemize
  1471. @item @b{Used during ``reset''}
  1472. @* These commands are used internally by the OpenOCD scripts to deal
  1473. with odd reset situations and are not documented here.
  1474. @itemize @bullet
  1475. @item @b{arp_examine}
  1476. @item @b{arp_poll}
  1477. @item @b{arp_reset}
  1478. @item @b{arp_halt}
  1479. @item @b{arp_waitstate}
  1480. @end itemize
  1481. @item @b{invoke-event} @b{EVENT-NAME}
  1482. @* Invokes the specific event manually for the target
  1483. @end itemize
  1484. @section Target Events
  1485. At various times, certain things can happen, or you want them to happen.
  1486. Examples:
  1487. @itemize @bullet
  1488. @item What should happen when GDB connects? Should your target reset?
  1489. @item When GDB tries to flash the target, do you need to enable the flash via a special command?
  1490. @item During reset, do you need to write to certain memory location to reconfigure the SDRAM?
  1491. @end itemize
  1492. All of the above items are handled by target events.
  1493. To specify an event action, either during target creation, or later
  1494. via ``$_TARGETNAME configure'' see this example.
  1495. Syntactially, the option is: ``-event NAME BODY'' where NAME is a
  1496. target event name, and BODY is a tcl procedure or string of commands
  1497. to execute.
  1498. The programmers model is the ``-command'' option used in Tcl/Tk
  1499. buttons and events. Below are two identical examples, the first
  1500. creates and invokes small procedure. The second inlines the procedure.
  1501. @example
  1502. proc my_attach_proc @{ @} @{
  1503. puts "RESET...."
  1504. reset halt
  1505. @}
  1506. mychip.cpu configure -event gdb-attach my_attach_proc
  1507. mychip.cpu configure -event gdb-attach @{ puts "Reset..." ; reset halt @}
  1508. @end example
  1509. @section Current Events
  1510. The following events are available:
  1511. @itemize @bullet
  1512. @item @b{debug-halted}
  1513. @* The target has halted for debug reasons (ie: breakpoint)
  1514. @item @b{debug-resumed}
  1515. @* The target has resumed (ie: gdb said run)
  1516. @item @b{early-halted}
  1517. @* Occurs early in the halt process
  1518. @item @b{examine-end}
  1519. @* Currently not used (goal: when JTAG examine completes)
  1520. @item @b{examine-start}
  1521. @* Currently not used (goal: when JTAG examine starts)
  1522. @item @b{gdb-attach}
  1523. @* When GDB connects
  1524. @item @b{gdb-detach}
  1525. @* When GDB disconnects
  1526. @item @b{gdb-end}
  1527. @* When the taret has halted and GDB is not doing anything (see early halt)
  1528. @item @b{gdb-flash-erase-start}
  1529. @* Before the GDB flash process tries to erase the flash
  1530. @item @b{gdb-flash-erase-end}
  1531. @* After the GDB flash process has finished erasing the flash
  1532. @item @b{gdb-flash-write-start}
  1533. @* Before GDB writes to the flash
  1534. @item @b{gdb-flash-write-end}
  1535. @* After GDB writes to the flash
  1536. @item @b{gdb-start}
  1537. @* Before the taret steps, gdb is trying to start/resume the tarfget
  1538. @item @b{halted}
  1539. @* The target has halted
  1540. @item @b{old-gdb_program_config}
  1541. @* DO NOT USE THIS: Used internally
  1542. @item @b{old-pre_resume}
  1543. @* DO NOT USE THIS: Used internally
  1544. @item @b{reset-assert-pre}
  1545. @* Before reset is asserted on the tap.
  1546. @item @b{reset-assert-post}
  1547. @* Reset is now asserted on the tap.
  1548. @item @b{reset-deassert-pre}
  1549. @* Reset is about to be released on the tap
  1550. @item @b{reset-deassert-post}
  1551. @* Reset has been released on the tap
  1552. @item @b{reset-end}
  1553. @* Currently not used.
  1554. @item @b{reset-halt-post}
  1555. @* Currently not usd
  1556. @item @b{reset-halt-pre}
  1557. @* Currently not used
  1558. @item @b{reset-init}
  1559. @* Currently not used
  1560. @item @b{reset-start}
  1561. @* Currently not used
  1562. @item @b{reset-wait-pos}
  1563. @* Currently not used
  1564. @item @b{reset-wait-pre}
  1565. @* Currently not used
  1566. @item @b{resume-start}
  1567. @* Before any target is resumed
  1568. @item @b{resume-end}
  1569. @* After all targets have resumed
  1570. @item @b{resume-ok}
  1571. @* Success
  1572. @item @b{resumed}
  1573. @* Target has resumed
  1574. @item @b{tap-enable}
  1575. @* Executed by @b{jtag tapenable DOTTED.NAME} command. Example:
  1576. @example
  1577. jtag configure DOTTED.NAME -event tap-enable @{
  1578. puts "Enabling CPU"
  1579. ...
  1580. @}
  1581. @end example
  1582. @item @b{tap-disable}
  1583. @*Executed by @b{jtag tapdisable DOTTED.NAME} command. Example:
  1584. @example
  1585. jtag configure DOTTED.NAME -event tap-disable @{
  1586. puts "Disabling CPU"
  1587. ...
  1588. @}
  1589. @end example
  1590. @end itemize
  1591. @section target create
  1592. @cindex target
  1593. @cindex target creation
  1594. @example
  1595. @b{target} @b{create} <@var{NAME}> <@var{TYPE}> <@var{PARAMS ...}>
  1596. @end example
  1597. @*This command creates a GDB debug target that refers to a specific JTAG tap.
  1598. @comment START params
  1599. @itemize @bullet
  1600. @item @b{NAME}
  1601. @* Is the name of the debug target. By convention it should be the tap
  1602. DOTTED.NAME, this name is also used to create the target object
  1603. command.
  1604. @item @b{TYPE}
  1605. @* Specifies the target type, ie: arm7tdmi, or cortexM3. Currently supported targes are:
  1606. @comment START types
  1607. @itemize @minus
  1608. @item @b{arm7tdmi}
  1609. @item @b{arm720t}
  1610. @item @b{arm9tdmi}
  1611. @item @b{arm920t}
  1612. @item @b{arm922t}
  1613. @item @b{arm926ejs}
  1614. @item @b{arm966e}
  1615. @item @b{cortex_m3}
  1616. @item @b{feroceon}
  1617. @item @b{xscale}
  1618. @item @b{arm11}
  1619. @item @b{mips_m4k}
  1620. @comment end TYPES
  1621. @end itemize
  1622. @item @b{PARAMS}
  1623. @*PARAMs are various target configure parameters, the following are mandatory
  1624. at configuration:
  1625. @comment START mandatory
  1626. @itemize @bullet
  1627. @item @b{-endian big|little}
  1628. @item @b{-chain-position DOTTED.NAME}
  1629. @comment end MANDATORY
  1630. @end itemize
  1631. @comment END params
  1632. @end itemize
  1633. @section Target Config/Cget Options
  1634. These options can be specified when the target is created, or later
  1635. via the configure option or to query the target via cget.
  1636. @itemize @bullet
  1637. @item @b{-type} - returns the target type
  1638. @item @b{-event NAME BODY} see Target events
  1639. @item @b{-work-area-virt [ADDRESS]} specify/set the work area
  1640. @item @b{-work-area-phys [ADDRESS]} specify/set the work area
  1641. @item @b{-work-area-size [ADDRESS]} specify/set the work area
  1642. @item @b{-work-area-backup [0|1]} does the work area get backed up
  1643. @item @b{-endian [big|little]}
  1644. @item @b{-variant [NAME]} some chips have varients OpenOCD needs to know about
  1645. @item @b{-chain-position DOTTED.NAME} the tap name this target refers to.
  1646. @end itemize
  1647. Example:
  1648. @example
  1649. for @{ set x 0 @} @{ $x < [target count] @} @{ incr x @} @{
  1650. set name [target number $x]
  1651. set y [$name cget -endian]
  1652. set z [$name cget -type]
  1653. puts [format "Chip %d is %s, Endian: %s, type: %s" $x $y $z]
  1654. @}
  1655. @end example
  1656. @section Target Varients
  1657. @itemize @bullet
  1658. @item @b{arm7tdmi}
  1659. @* Unknown (please write me)
  1660. @item @b{arm720t}
  1661. @* Unknown (please write me) (simular to arm7tdmi)
  1662. @item @b{arm9tdmi}
  1663. @* Varients: @option{arm920t}, @option{arm922t} and @option{arm940t}
  1664. This enables the hardware single-stepping support found on these
  1665. cores.
  1666. @item @b{arm920t}
  1667. @* None.
  1668. @item @b{arm966e}
  1669. @* None (this is also used as the ARM946)
  1670. @item @b{cortex_m3}
  1671. @* use variant <@var{-variant lm3s}> when debugging luminary lm3s targets. This will cause
  1672. OpenOCD to use a software reset rather than asserting SRST to avoid a issue with clearing
  1673. the debug registers. This is fixed in Fury Rev B, DustDevil Rev B, Tempest, these revisions will
  1674. be detected and the normal reset behaviour used.
  1675. @item @b{xscale}
  1676. @* Supported variants are @option{ixp42x}, @option{ixp45x}, @option{ixp46x},@option{pxa250}, @option{pxa255}, @option{pxa26x}.
  1677. @item @b{arm11}
  1678. @* Supported variants are @option{arm1136}, @option{arm1156}, @option{arm1176}
  1679. @item @b{mips_m4k}
  1680. @* Use variant @option{ejtag_srst} when debugging targets that do not
  1681. provide a functional SRST line on the EJTAG connector. This causes
  1682. OpenOCD to instead use an EJTAG software reset command to reset the
  1683. processor. You still need to enable @option{srst} on the reset
  1684. configuration command to enable OpenOCD hardware reset functionality.
  1685. @comment END varients
  1686. @end itemize
  1687. @section working_area - Command Removed
  1688. @cindex working_area
  1689. @*@b{Please use the ``$_TARGETNAME configure -work-area-... parameters instead}
  1690. @* This documentation remains because there are existing scripts that
  1691. still use this that need to be converted.
  1692. @example
  1693. working_area target# address size backup| [virtualaddress]
  1694. @end example
  1695. @* The target# is a the 0 based target numerical index.
  1696. This command specifies a working area for the debugger to use. This
  1697. may be used to speed-up downloads to target memory and flash
  1698. operations, or to perform otherwise unavailable operations (some
  1699. coprocessor operations on ARM7/9 systems, for example). The last
  1700. parameter decides whether the memory should be preserved
  1701. (<@var{backup}>) or can simply be overwritten (<@var{nobackup}>). If
  1702. possible, use a working_area that doesn't need to be backed up, as
  1703. performing a backup slows down operation.
  1704. @node Flash Configuration
  1705. @chapter Flash Programing
  1706. @cindex Flash Configuration
  1707. @b{Note:} As of 28/nov/2008 OpenOCD does not know how to program a SPI
  1708. flash that a micro may boot from. Perhaps you the reader would like to
  1709. contribute support for this.
  1710. Flash Steps:
  1711. @enumerate
  1712. @item Configure via the command @b{flash bank}
  1713. @* Normally this is done in a configuration file.
  1714. @item Operate on the flash via @b{flash SOMECOMMAND}
  1715. @* Often commands to manipulate the flash are typed by a human, or run
  1716. via a script in some automated way. For example: To program the boot
  1717. flash on your board.
  1718. @item GDB Flashing
  1719. @* Flashing via GDB requires the flash be configured via ``flash
  1720. bank'', and the GDB flash features be enabled. See the Daemon
  1721. configuration section for more details.
  1722. @end enumerate
  1723. @section Flash commands
  1724. @cindex Flash commands
  1725. @subsection flash banks
  1726. @b{flash banks}
  1727. @cindex flash banks
  1728. @*List configured flash banks
  1729. @*@b{NOTE:} the singular form: 'flash bank' is used to configure the flash banks.
  1730. @subsection flash info
  1731. @b{flash info} <@var{num}>
  1732. @cindex flash info
  1733. @*Print info about flash bank <@option{num}>
  1734. @subsection flash probe
  1735. @b{flash probe} <@var{num}>
  1736. @cindex flash probe
  1737. @*Identify the flash, or validate the parameters of the configured flash. Operation
  1738. depends on the flash type.
  1739. @subsection flash erase_check
  1740. @b{flash erase_check} <@var{num}>
  1741. @cindex flash erase_check
  1742. @*Check erase state of sectors in flash bank <@var{num}>. This is the only operation that
  1743. updates the erase state information displayed by @option{flash info}. That means you have
  1744. to issue an @option{erase_check} command after erasing or programming the device to get
  1745. updated information.
  1746. @subsection flash protect_check
  1747. @b{flash protect_check} <@var{num}>
  1748. @cindex flash protect_check
  1749. @*Check protection state of sectors in flash bank <num>.
  1750. @option{flash erase_sector} using the same syntax.
  1751. @subsection flash erase_sector
  1752. @b{flash erase_sector} <@var{num}> <@var{first}> <@var{last}>
  1753. @cindex flash erase_sector
  1754. @anchor{flash erase_sector}
  1755. @*Erase sectors at bank <@var{num}>, starting at sector <@var{first}> up to and including
  1756. <@var{last}>. Sector numbering starts at 0. Depending on the flash type, erasing may
  1757. require the protection to be disabled first (e.g. Intel Advanced Bootblock flash using
  1758. the CFI driver).
  1759. @subsection flash erase_address
  1760. @b{flash erase_address} <@var{address}> <@var{length}>
  1761. @cindex flash erase_address
  1762. @*Erase sectors starting at <@var{address}> for <@var{length}> bytes
  1763. @subsection flash write_bank
  1764. @b{flash write_bank} <@var{num}> <@var{file}> <@var{offset}>
  1765. @cindex flash write_bank
  1766. @anchor{flash write_bank}
  1767. @*Write the binary <@var{file}> to flash bank <@var{num}>, starting at
  1768. <@option{offset}> bytes from the beginning of the bank.
  1769. @subsection flash write_image
  1770. @b{flash write_image} [@var{erase}] <@var{file}> [@var{offset}] [@var{type}]
  1771. @cindex flash write_image
  1772. @anchor{flash write_image}
  1773. @*Write the image <@var{file}> to the current target's flash bank(s). A relocation
  1774. [@var{offset}] can be specified and the file [@var{type}] can be specified
  1775. explicitly as @option{bin} (binary), @option{ihex} (Intel hex), @option{elf}
  1776. (ELF file) or @option{s19} (Motorola s19). Flash memory will be erased prior to programming
  1777. if the @option{erase} parameter is given.
  1778. @subsection flash protect
  1779. @b{flash protect} <@var{num}> <@var{first}> <@var{last}> <@option{on}|@option{off}>
  1780. @cindex flash protect
  1781. @*Enable (@var{on}) or disable (@var{off}) protection of flash sectors <@var{first}> to
  1782. <@var{last}> of @option{flash bank} <@var{num}>.
  1783. @subsection mFlash commands
  1784. @cindex mFlash commands
  1785. @itemize @bullet
  1786. @item @b{mflash probe}
  1787. @cindex mflash probe
  1788. Probe mflash.
  1789. @item @b{mflash write} <@var{num}> <@var{file}> <@var{offset}>
  1790. @cindex mflash write
  1791. Write the binary <@var{file}> to mflash bank <@var{num}>, starting at
  1792. <@var{offset}> bytes from the beginning of the bank.
  1793. @item @b{mflash dump} <@var{num}> <@var{file}> <@var{offset}> <@var{size}>
  1794. @cindex mflash dump
  1795. Dump <size> bytes, starting at <@var{offset}> bytes from the beginning of the <@var{num}> bank
  1796. to a <@var{file}>.
  1797. @end itemize
  1798. @section flash bank command
  1799. The @b{flash bank} command is used to configure one or more flash chips (or banks in OpenOCD terms)
  1800. @example
  1801. @b{flash bank} <@var{driver}> <@var{base}> <@var{size}> <@var{chip_width}>
  1802. <@var{bus_width}> <@var{target#}> [@var{driver_options ...}]
  1803. @end example
  1804. @cindex flash bank
  1805. @*Configures a flash bank at <@var{base}> of <@var{size}> bytes and <@var{chip_width}>
  1806. and <@var{bus_width}> bytes using the selected flash <driver>.
  1807. @subsection External Flash - cfi options
  1808. @cindex cfi options
  1809. CFI flash are external flash chips - often they are connected to a
  1810. specific chip select on the micro. By default at hard reset most
  1811. micros have the ablity to ``boot'' from some flash chip - typically
  1812. attached to the chips CS0 pin.
  1813. For other chip selects: OpenOCD does not know how to configure, or
  1814. access a specific chip select. Instead you the human might need to via
  1815. other commands (like: mww) configure additional chip selects, or
  1816. perhaps configure a GPIO pin that controls the ``write protect'' pin
  1817. on the FLASH chip.
  1818. @b{flash bank cfi} <@var{base}> <@var{size}> <@var{chip_width}> <@var{bus_width}>
  1819. <@var{target#}> [@var{jedec_probe}|@var{x16_as_x8}]
  1820. @*CFI flashes require the number of the target they're connected to as an additional
  1821. argument. The CFI driver makes use of a working area (specified for the target)
  1822. to significantly speed up operation.
  1823. @var{chip_width} and @var{bus_width} are specified in bytes.
  1824. The @var{jedec_probe} option is used to detect certain non-CFI flash roms, like AM29LV010 and similar types.
  1825. @var{x16_as_x8} ???
  1826. @subsection Internal Flash (Micro Controllers)
  1827. @subsubsection lpc2000 options
  1828. @cindex lpc2000 options
  1829. @b{flash bank lpc2000} <@var{base}> <@var{size}> 0 0 <@var{target#}> <@var{variant}>
  1830. <@var{clock}> [@var{calc_checksum}]
  1831. @*LPC flashes don't require the chip and bus width to be specified. Additional
  1832. parameters are the <@var{variant}>, which may be @var{lpc2000_v1} (older LPC21xx and LPC22xx)
  1833. or @var{lpc2000_v2} (LPC213x, LPC214x, LPC210[123], LPC23xx and LPC24xx), the number
  1834. of the target this flash belongs to (first is 0), the frequency at which the core
  1835. is currently running (in kHz - must be an integral number), and the optional keyword
  1836. @var{calc_checksum}, telling the driver to calculate a valid checksum for the exception
  1837. vector table.
  1838. @subsubsection at91sam7 options
  1839. @cindex at91sam7 options
  1840. @b{flash bank at91sam7} 0 0 0 0 <@var{target#}>
  1841. @*AT91SAM7 flashes only require the @var{target#}, all other values are looked up after
  1842. reading the chip-id and type.
  1843. @subsubsection str7 options
  1844. @cindex str7 options
  1845. @b{flash bank str7x} <@var{base}> <@var{size}> 0 0 <@var{target#}> <@var{variant}>
  1846. @*variant can be either STR71x, STR73x or STR75x.
  1847. @subsubsection str9 options
  1848. @cindex str9 options
  1849. @b{flash bank str9x} <@var{base}> <@var{size}> 0 0 <@var{target#}>
  1850. @*The str9 needs the flash controller to be configured prior to Flash programming, eg.
  1851. @example
  1852. str9x flash_config 0 4 2 0 0x80000
  1853. @end example
  1854. This will setup the BBSR, NBBSR, BBADR and NBBADR registers respectively.
  1855. @subsubsection str9 options (str9xpec driver)
  1856. @b{flash bank str9xpec} <@var{base}> <@var{size}> 0 0 <@var{target#}>
  1857. @*Before using the flash commands the turbo mode will need enabling using str9xpec
  1858. @option{enable_turbo} <@var{num>.}
  1859. Only use this driver for locking/unlocking the device or configuring the option bytes.
  1860. Use the standard str9 driver for programming. @xref{STR9 specific commands}.
  1861. @subsubsection stellaris (LM3Sxxx) options
  1862. @cindex stellaris (LM3Sxxx) options
  1863. @b{flash bank stellaris} <@var{base}> <@var{size}> 0 0 <@var{target#}>
  1864. @*stellaris flash plugin only require the @var{target#}.
  1865. @subsubsection stm32x options
  1866. @cindex stm32x options
  1867. @b{flash bank stm32x} <@var{base}> <@var{size}> 0 0 <@var{target#}>
  1868. @*stm32x flash plugin only require the @var{target#}.
  1869. @subsubsection aduc702x options
  1870. @cindex aduc702x options
  1871. @b{flash bank aduc702x} 0 0 0 0 <@var{target#}>
  1872. @*The aduc702x flash plugin works with Analog Devices model numbers ADUC7019 through ADUC7028. The setup command only requires the @var{target#} argument (all devices in this family have the same memory layout).
  1873. @subsection mFlash configuration
  1874. @cindex mFlash configuration
  1875. @b{mflash bank} <@var{soc}> <@var{base}> <@var{chip_width}> <@var{bus_width}>
  1876. <@var{RST pin}> <@var{WP pin}> <@var{DPD pin}> <@var{target #}>
  1877. @cindex mflash bank
  1878. @*Configures a mflash for <@var{soc}> host bank at
  1879. <@var{base}>. <@var{chip_width}> and <@var{bus_width}> are bytes
  1880. order. Pin number format is dependent on host GPIO calling convention.
  1881. If WP or DPD pin was not used, write -1. Currently, mflash bank
  1882. support s3c2440 and pxa270.
  1883. (ex. of s3c2440) mflash <@var{RST pin}> is GPIO B1, <@var{WP pin}> and <@var{DPD pin}> are not used.
  1884. @example
  1885. mflash bank s3c2440 0x10000000 2 2 1b -1 -1 0
  1886. @end example
  1887. (ex. of pxa270) mflash <@var{RST pin}> is GPIO 43, <@var{DPD pin}> is not used and <@var{DPD pin}> is GPIO 51.
  1888. @example
  1889. mflash bank pxa270 0x08000000 2 2 43 -1 51 0
  1890. @end example
  1891. @section Micro Controller Specific Flash Commands
  1892. @subsection AT91SAM7 specific commands
  1893. @cindex AT91SAM7 specific commands
  1894. The flash configuration is deduced from the chip identification register. The flash
  1895. controller handles erases automatically on a page (128/265 byte) basis so erase is
  1896. not necessary for flash programming. AT91SAM7 processors with less than 512K flash
  1897. only have a single flash bank embedded on chip. AT91SAM7xx512 have two flash planes
  1898. that can be erased separatly. Only an EraseAll command is supported by the controller
  1899. for each flash plane and this is called with
  1900. @itemize @bullet
  1901. @item @b{flash erase} <@var{num}> @var{first_plane} @var{last_plane}
  1902. @*bulk erase flash planes first_plane to last_plane.
  1903. @item @b{at91sam7 gpnvm} <@var{num}> <@var{bit}> <@option{set}|@option{clear}>
  1904. @cindex at91sam7 gpnvm
  1905. @*set or clear a gpnvm bit for the processor
  1906. @end itemize
  1907. @subsection STR9 specific commands
  1908. @cindex STR9 specific commands
  1909. @anchor{STR9 specific commands}
  1910. These are flash specific commands when using the str9xpec driver.
  1911. @itemize @bullet
  1912. @item @b{str9xpec enable_turbo} <@var{num}>
  1913. @cindex str9xpec enable_turbo
  1914. @*enable turbo mode, simply this will remove the str9 from the chain and talk
  1915. directly to the embedded flash controller.
  1916. @item @b{str9xpec disable_turbo} <@var{num}>
  1917. @cindex str9xpec disable_turbo
  1918. @*restore the str9 into jtag chain.
  1919. @item @b{str9xpec lock} <@var{num}>
  1920. @cindex str9xpec lock
  1921. @*lock str9 device. The str9 will only respond to an unlock command that will
  1922. erase the device.
  1923. @item @b{str9xpec unlock} <@var{num}>
  1924. @cindex str9xpec unlock
  1925. @*unlock str9 device.
  1926. @item @b{str9xpec options_read} <@var{num}>
  1927. @cindex str9xpec options_read
  1928. @*read str9 option bytes.
  1929. @item @b{str9xpec options_write} <@var{num}>
  1930. @cindex str9xpec options_write
  1931. @*write str9 option bytes.
  1932. @end itemize
  1933. Note: Before using the str9xpec driver here is some background info to help
  1934. you better understand how the drivers works. OpenOCD has two flash drivers for
  1935. the str9.
  1936. @enumerate
  1937. @item
  1938. Standard driver @option{str9x} programmed via the str9 core. Normally used for
  1939. flash programming as it is faster than the @option{str9xpec} driver.
  1940. @item
  1941. Direct programming @option{str9xpec} using the flash controller, this is
  1942. ISC compilant (IEEE 1532) tap connected in series with the str9 core. The str9
  1943. core does not need to be running to program using this flash driver. Typical use
  1944. for this driver is locking/unlocking the target and programming the option bytes.
  1945. @end enumerate
  1946. Before we run any cmds using the @option{str9xpec} driver we must first disable
  1947. the str9 core. This example assumes the @option{str9xpec} driver has been
  1948. configured for flash bank 0.
  1949. @example
  1950. # assert srst, we do not want core running
  1951. # while accessing str9xpec flash driver
  1952. jtag_reset 0 1
  1953. # turn off target polling
  1954. poll off
  1955. # disable str9 core
  1956. str9xpec enable_turbo 0
  1957. # read option bytes
  1958. str9xpec options_read 0
  1959. # re-enable str9 core
  1960. str9xpec disable_turbo 0
  1961. poll on
  1962. reset halt
  1963. @end example
  1964. The above example will read the str9 option bytes.
  1965. When performing a unlock remember that you will not be able to halt the str9 - it
  1966. has been locked. Halting the core is not required for the @option{str9xpec} driver
  1967. as mentioned above, just issue the cmds above manually or from a telnet prompt.
  1968. @subsection STR9 configuration
  1969. @cindex STR9 configuration
  1970. @itemize @bullet
  1971. @item @b{str9x flash_config} <@var{bank}> <@var{BBSR}> <@var{NBBSR}>
  1972. <@var{BBADR}> <@var{NBBADR}>
  1973. @cindex str9x flash_config
  1974. @*Configure str9 flash controller.
  1975. @example
  1976. eg. str9x flash_config 0 4 2 0 0x80000
  1977. This will setup
  1978. BBSR - Boot Bank Size register
  1979. NBBSR - Non Boot Bank Size register
  1980. BBADR - Boot Bank Start Address register
  1981. NBBADR - Boot Bank Start Address register
  1982. @end example
  1983. @end itemize
  1984. @subsection STR9 option byte configuration
  1985. @cindex STR9 option byte configuration
  1986. @itemize @bullet
  1987. @item @b{str9xpec options_cmap} <@var{num}> <@option{bank0}|@option{bank1}>
  1988. @cindex str9xpec options_cmap
  1989. @*configure str9 boot bank.
  1990. @item @b{str9xpec options_lvdthd} <@var{num}> <@option{2.4v}|@option{2.7v}>
  1991. @cindex str9xpec options_lvdthd
  1992. @*configure str9 lvd threshold.
  1993. @item @b{str9xpec options_lvdsel} <@var{num}> <@option{vdd}|@option{vdd_vddq}>
  1994. @cindex str9xpec options_lvdsel
  1995. @*configure str9 lvd source.
  1996. @item @b{str9xpec options_lvdwarn} <@var{bank}> <@option{vdd}|@option{vdd_vddq}>
  1997. @cindex str9xpec options_lvdwarn
  1998. @*configure str9 lvd reset warning source.
  1999. @end itemize
  2000. @subsection STM32x specific commands
  2001. @cindex STM32x specific commands
  2002. These are flash specific commands when using the stm32x driver.
  2003. @itemize @bullet
  2004. @item @b{stm32x lock} <@var{num}>
  2005. @cindex stm32x lock
  2006. @*lock stm32 device.
  2007. @item @b{stm32x unlock} <@var{num}>
  2008. @cindex stm32x unlock
  2009. @*unlock stm32 device.
  2010. @item @b{stm32x options_read} <@var{num}>
  2011. @cindex stm32x options_read
  2012. @*read stm32 option bytes.
  2013. @item @b{stm32x options_write} <@var{num}> <@option{SWWDG}|@option{HWWDG}>
  2014. <@option{RSTSTNDBY}|@option{NORSTSTNDBY}> <@option{RSTSTOP}|@option{NORSTSTOP}>
  2015. @cindex stm32x options_write
  2016. @*write stm32 option bytes.
  2017. @item @b{stm32x mass_erase} <@var{num}>
  2018. @cindex stm32x mass_erase
  2019. @*mass erase flash memory.
  2020. @end itemize
  2021. @subsection Stellaris specific commands
  2022. @cindex Stellaris specific commands
  2023. These are flash specific commands when using the Stellaris driver.
  2024. @itemize @bullet
  2025. @item @b{stellaris mass_erase} <@var{num}>
  2026. @cindex stellaris mass_erase
  2027. @*mass erase flash memory.
  2028. @end itemize
  2029. @node General Commands
  2030. @chapter General Commands
  2031. @cindex commands
  2032. The commands documented in this chapter here are common commands that
  2033. you a human may want to type and see the output of. Configuration type
  2034. commands are documented elsewhere.
  2035. Intent:
  2036. @itemize @bullet
  2037. @item @b{Source Of Commands}
  2038. @* OpenOCD commands can occur in a configuration script (discussed
  2039. elsewhere) or typed manually by a human or supplied programatically,
  2040. or via one of several Tcp/Ip Ports.
  2041. @item @b{From the human}
  2042. @* A human should interact with the Telnet interface (default port: 4444,
  2043. or via GDB, default port 3333)
  2044. To issue commands from within a GDB session, use the @option{monitor}
  2045. command, e.g. use @option{monitor poll} to issue the @option{poll}
  2046. command. All output is relayed through the GDB session.
  2047. @item @b{Machine Interface}
  2048. The TCL interface intent is to be a machine interface. The default TCL
  2049. port is 5555.
  2050. @end itemize
  2051. @section Daemon Commands
  2052. @subsection sleep [@var{msec}]
  2053. @cindex sleep
  2054. @*Wait for n milliseconds before resuming. Useful in connection with script files
  2055. (@var{script} command and @var{target_script} configuration).
  2056. @subsection shutdown
  2057. @cindex shutdown
  2058. @*Close the OpenOCD daemon, disconnecting all clients (GDB, Telnet, Other).
  2059. @subsection debug_level [@var{n}]
  2060. @cindex debug_level
  2061. @anchor{debug_level}
  2062. @*Display or adjust debug level to n<0-3>
  2063. @subsection fast [@var{enable|disable}]
  2064. @cindex fast
  2065. @*Default disabled. Set default behaviour of OpenOCD to be "fast and dangerous". For instance ARM7/9 DCC memory
  2066. downloads and fast memory access will work if the JTAG interface isn't too fast and
  2067. the core doesn't run at a too low frequency. Note that this option only changes the default
  2068. and that the indvidual options, like DCC memory downloads, can be enabled and disabled
  2069. individually.
  2070. The target specific "dangerous" optimisation tweaking options may come and go
  2071. as more robust and user friendly ways are found to ensure maximum throughput
  2072. and robustness with a minimum of configuration.
  2073. Typically the "fast enable" is specified first on the command line:
  2074. @example
  2075. openocd -c "fast enable" -c "interface dummy" -f target/str710.cfg
  2076. @end example
  2077. @subsection log_output <@var{file}>
  2078. @cindex log_output
  2079. @*Redirect logging to <file> (default: stderr)
  2080. @subsection script <@var{file}>
  2081. @cindex script
  2082. @*Execute commands from <file>
  2083. Also see: ``source [find FILENAME]''
  2084. @section Target state handling
  2085. @subsection power <@var{on}|@var{off}>
  2086. @cindex reg
  2087. @*Turn power switch to target on/off.
  2088. No arguments: print status.
  2089. Not all interfaces support this.
  2090. @subsection reg [@option{#}|@option{name}] [value]
  2091. @cindex reg
  2092. @*Access a single register by its number[@option{#}] or by its [@option{name}].
  2093. No arguments: list all available registers for the current target.
  2094. Number or name argument: display a register
  2095. Number or name and value arguments: set register value
  2096. @subsection poll [@option{on}|@option{off}]
  2097. @cindex poll
  2098. @*Poll the target for its current state. If the target is in debug mode, architecture
  2099. specific information about the current state is printed. An optional parameter
  2100. allows continuous polling to be enabled and disabled.
  2101. @subsection halt [@option{ms}]
  2102. @cindex halt
  2103. @*Send a halt request to the target and wait for it to halt for up to [@option{ms}] milliseconds.
  2104. Default [@option{ms}] is 5 seconds if no arg given.
  2105. Optional arg @option{ms} is a timeout in milliseconds. Using 0 as the [@option{ms}]
  2106. will stop OpenOCD from waiting.
  2107. @subsection wait_halt [@option{ms}]
  2108. @cindex wait_halt
  2109. @*Wait for the target to enter debug mode. Optional [@option{ms}] is
  2110. a timeout in milliseconds. Default [@option{ms}] is 5 seconds if no
  2111. arg given.
  2112. @subsection resume [@var{address}]
  2113. @cindex resume
  2114. @*Resume the target at its current code position, or at an optional address.
  2115. OpenOCD will wait 5 seconds for the target to resume.
  2116. @subsection step [@var{address}]
  2117. @cindex step
  2118. @*Single-step the target at its current code position, or at an optional address.
  2119. @subsection reset [@option{run}|@option{halt}|@option{init}]
  2120. @cindex reset
  2121. @*Perform a hard-reset. The optional parameter specifies what should happen after the reset.
  2122. With no arguments a "reset run" is executed
  2123. @itemize @minus
  2124. @item @b{run}
  2125. @cindex reset run
  2126. @*Let the target run.
  2127. @item @b{halt}
  2128. @cindex reset halt
  2129. @*Immediately halt the target (works only with certain configurations).
  2130. @item @b{init}
  2131. @cindex reset init
  2132. @*Immediately halt the target, and execute the reset script (works only with certain
  2133. configurations)
  2134. @end itemize
  2135. @subsection soft_reset_halt
  2136. @cindex reset
  2137. @*Requesting target halt and executing a soft reset. This often used
  2138. when a target cannot be reset and halted. The target, after reset is
  2139. released begins to execute code. OpenOCD attempts to stop the CPU and
  2140. then sets the Program counter back at the reset vector. Unfortunatlly
  2141. that code that was executed may have left hardware in an unknown
  2142. state.
  2143. @section Memory access commands
  2144. @subsection meminfo
  2145. display available ram memory.
  2146. @subsection Memory Peek/Poke type commands
  2147. These commands allow accesses of a specific size to the memory
  2148. system. Often these are used to configure the current target in some
  2149. special way. For example - one may need to write certian values to the
  2150. SDRAM controller to enable SDRAM.
  2151. @enumerate
  2152. @item To change the current target see the ``targets'' (plural) command
  2153. @item In system level scripts these commands are depricated, please use the TARGET object versions.
  2154. @end enumerate
  2155. @itemize @bullet
  2156. @item @b{mdw} <@var{addr}> [@var{count}]
  2157. @cindex mdw
  2158. @*display memory words (32bit)
  2159. @item @b{mdh} <@var{addr}> [@var{count}]
  2160. @cindex mdh
  2161. @*display memory half-words (16bit)
  2162. @item @b{mdb} <@var{addr}> [@var{count}]
  2163. @cindex mdb
  2164. @*display memory bytes (8bit)
  2165. @item @b{mww} <@var{addr}> <@var{value}>
  2166. @cindex mww
  2167. @*write memory word (32bit)
  2168. @item @b{mwh} <@var{addr}> <@var{value}>
  2169. @cindex mwh
  2170. @*write memory half-word (16bit)
  2171. @item @b{mwb} <@var{addr}> <@var{value}>
  2172. @cindex mwb
  2173. @*write memory byte (8bit)
  2174. @end itemize
  2175. @section Image Loading Commands
  2176. @subsection load_image
  2177. @b{load_image} <@var{file}> <@var{address}> [@option{bin}|@option{ihex}|@option{elf}]
  2178. @cindex load_image
  2179. @anchor{load_image}
  2180. @*Load image <@var{file}> to target memory at <@var{address}>
  2181. @subsection fast_load_image
  2182. @b{fast_load_image} <@var{file}> <@var{address}> [@option{bin}|@option{ihex}|@option{elf}]
  2183. @cindex fast_load_image
  2184. @anchor{fast_load_image}
  2185. @*Normally you should be using @b{load_image} or GDB load. However, for
  2186. testing purposes or when IO overhead is significant(OpenOCD running on embedded
  2187. host), then storing the image in memory and uploading the image to the target
  2188. can be a way to upload e.g. multiple debug sessions when the binary does not change.
  2189. Arguments as @b{load_image}, but image is stored in OpenOCD host
  2190. memory, i.e. does not affect target. This approach is also useful when profiling
  2191. target programming performance as IO and target programming can easily be profiled
  2192. seperately.
  2193. @subsection fast_load
  2194. @b{fast_load}
  2195. @cindex fast_image
  2196. @anchor{fast_image}
  2197. @*Loads image stored in memory by @b{fast_load_image} to current target. Must be preceeded by fast_load_image.
  2198. @subsection dump_image
  2199. @b{dump_image} <@var{file}> <@var{address}> <@var{size}>
  2200. @cindex dump_image
  2201. @anchor{dump_image}
  2202. @*Dump <@var{size}> bytes of target memory starting at <@var{address}> to a
  2203. (binary) <@var{file}>.
  2204. @subsection verify_image
  2205. @b{verify_image} <@var{file}> <@var{address}> [@option{bin}|@option{ihex}|@option{elf}]
  2206. @cindex verify_image
  2207. @*Verify <@var{file}> against target memory starting at <@var{address}>.
  2208. This will first attempt comparison using a crc checksum, if this fails it will try a binary compare.
  2209. @section Breakpoint commands
  2210. @cindex Breakpoint commands
  2211. @itemize @bullet
  2212. @item @b{bp} <@var{addr}> <@var{len}> [@var{hw}]
  2213. @cindex bp
  2214. @*set breakpoint <address> <length> [hw]
  2215. @item @b{rbp} <@var{addr}>
  2216. @cindex rbp
  2217. @*remove breakpoint <adress>
  2218. @item @b{wp} <@var{addr}> <@var{len}> <@var{r}|@var{w}|@var{a}> [@var{value}] [@var{mask}]
  2219. @cindex wp
  2220. @*set watchpoint <address> <length> <r/w/a> [value] [mask]
  2221. @item @b{rwp} <@var{addr}>
  2222. @cindex rwp
  2223. @*remove watchpoint <adress>
  2224. @end itemize
  2225. @section Misc Commands
  2226. @cindex Other Target Commands
  2227. @itemize
  2228. @item @b{profile} <@var{seconds}> <@var{gmon.out}>
  2229. Profiling samples the CPU PC as quickly as OpenOCD is able, which will be used as a random sampling of PC.
  2230. @end itemize
  2231. @section Target Specific Commands
  2232. @cindex Target Specific Commands
  2233. @page
  2234. @section Architecture Specific Commands
  2235. @cindex Architecture Specific Commands
  2236. @subsection ARMV4/5 specific commands
  2237. @cindex ARMV4/5 specific commands
  2238. These commands are specific to ARM architecture v4 and v5, like all ARM7/9 systems
  2239. or Intel XScale (XScale isn't supported yet).
  2240. @itemize @bullet
  2241. @item @b{armv4_5 reg}
  2242. @cindex armv4_5 reg
  2243. @*Display a list of all banked core registers, fetching the current value from every
  2244. core mode if necessary. OpenOCD versions before rev. 60 didn't fetch the current
  2245. register value.
  2246. @item @b{armv4_5 core_mode} [@var{arm}|@var{thumb}]
  2247. @cindex armv4_5 core_mode
  2248. @*Displays the core_mode, optionally changing it to either ARM or Thumb mode.
  2249. The target is resumed in the currently set @option{core_mode}.
  2250. @end itemize
  2251. @subsection ARM7/9 specific commands
  2252. @cindex ARM7/9 specific commands
  2253. These commands are specific to ARM7 and ARM9 targets, like ARM7TDMI, ARM720t,
  2254. ARM920t or ARM926EJ-S.
  2255. @itemize @bullet
  2256. @item @b{arm7_9 dbgrq} <@var{enable}|@var{disable}>
  2257. @cindex arm7_9 dbgrq
  2258. @*Enable use of the DBGRQ bit to force entry into debug mode. This should be
  2259. safe for all but ARM7TDMI--S cores (like Philips LPC).
  2260. @item @b{arm7_9 fast_memory_access} <@var{enable}|@var{disable}>
  2261. @cindex arm7_9 fast_memory_access
  2262. @anchor{arm7_9 fast_memory_access}
  2263. @*Allow OpenOCD to read and write memory without checking completion of
  2264. the operation. This provides a huge speed increase, especially with USB JTAG
  2265. cables (FT2232), but might be unsafe if used with targets running at a very low
  2266. speed, like the 32kHz startup clock of an AT91RM9200.
  2267. @item @b{arm7_9 dcc_downloads} <@var{enable}|@var{disable}>
  2268. @cindex arm7_9 dcc_downloads
  2269. @*Enable the use of the debug communications channel (DCC) to write larger (>128 byte)
  2270. amounts of memory. DCC downloads offer a huge speed increase, but might be potentially
  2271. unsafe, especially with targets running at a very low speed. This command was introduced
  2272. with OpenOCD rev. 60.
  2273. @end itemize
  2274. @subsection ARM720T specific commands
  2275. @cindex ARM720T specific commands
  2276. @itemize @bullet
  2277. @item @b{arm720t cp15} <@var{num}> [@var{value}]
  2278. @cindex arm720t cp15
  2279. @*display/modify cp15 register <@option{num}> [@option{value}].
  2280. @item @b{arm720t md<bhw>_phys} <@var{addr}> [@var{count}]
  2281. @cindex arm720t md<bhw>_phys
  2282. @*Display memory at physical address addr.
  2283. @item @b{arm720t mw<bhw>_phys} <@var{addr}> <@var{value}>
  2284. @cindex arm720t mw<bhw>_phys
  2285. @*Write memory at physical address addr.
  2286. @item @b{arm720t virt2phys} <@var{va}>
  2287. @cindex arm720t virt2phys
  2288. @*Translate a virtual address to a physical address.
  2289. @end itemize
  2290. @subsection ARM9TDMI specific commands
  2291. @cindex ARM9TDMI specific commands
  2292. @itemize @bullet
  2293. @item @b{arm9tdmi vector_catch} <@var{all}|@var{none}>
  2294. @cindex arm9tdmi vector_catch
  2295. @*Catch arm9 interrupt vectors, can be @option{all} @option{none} or any of the following:
  2296. @option{reset} @option{undef} @option{swi} @option{pabt} @option{dabt} @option{reserved}
  2297. @option{irq} @option{fiq}.
  2298. Can also be used on other arm9 based cores, arm966, arm920t and arm926ejs.
  2299. @end itemize
  2300. @subsection ARM966E specific commands
  2301. @cindex ARM966E specific commands
  2302. @itemize @bullet
  2303. @item @b{arm966e cp15} <@var{num}> [@var{value}]
  2304. @cindex arm966e cp15
  2305. @*display/modify cp15 register <@option{num}> [@option{value}].
  2306. @end itemize
  2307. @subsection ARM920T specific commands
  2308. @cindex ARM920T specific commands
  2309. @itemize @bullet
  2310. @item @b{arm920t cp15} <@var{num}> [@var{value}]
  2311. @cindex arm920t cp15
  2312. @*display/modify cp15 register <@option{num}> [@option{value}].
  2313. @item @b{arm920t cp15i} <@var{num}> [@var{value}] [@var{address}]
  2314. @cindex arm920t cp15i
  2315. @*display/modify cp15 (interpreted access) <@option{opcode}> [@option{value}] [@option{address}]
  2316. @item @b{arm920t cache_info}
  2317. @cindex arm920t cache_info
  2318. @*Print information about the caches found. This allows you to see if your target
  2319. is a ARM920T (2x16kByte cache) or ARM922T (2x8kByte cache).
  2320. @item @b{arm920t md<bhw>_phys} <@var{addr}> [@var{count}]
  2321. @cindex arm920t md<bhw>_phys
  2322. @*Display memory at physical address addr.
  2323. @item @b{arm920t mw<bhw>_phys} <@var{addr}> <@var{value}>
  2324. @cindex arm920t mw<bhw>_phys
  2325. @*Write memory at physical address addr.
  2326. @item @b{arm920t read_cache} <@var{filename}>
  2327. @cindex arm920t read_cache
  2328. @*Dump the content of ICache and DCache to a file.
  2329. @item @b{arm920t read_mmu} <@var{filename}>
  2330. @cindex arm920t read_mmu
  2331. @*Dump the content of the ITLB and DTLB to a file.
  2332. @item @b{arm920t virt2phys} <@var{va}>
  2333. @cindex arm920t virt2phys
  2334. @*Translate a virtual address to a physical address.
  2335. @end itemize
  2336. @subsection ARM926EJS specific commands
  2337. @cindex ARM926EJS specific commands
  2338. @itemize @bullet
  2339. @item @b{arm926ejs cp15} <@var{num}> [@var{value}]
  2340. @cindex arm926ejs cp15
  2341. @*display/modify cp15 register <@option{num}> [@option{value}].
  2342. @item @b{arm926ejs cache_info}
  2343. @cindex arm926ejs cache_info
  2344. @*Print information about the caches found.
  2345. @item @b{arm926ejs md<bhw>_phys} <@var{addr}> [@var{count}]
  2346. @cindex arm926ejs md<bhw>_phys
  2347. @*Display memory at physical address addr.
  2348. @item @b{arm926ejs mw<bhw>_phys} <@var{addr}> <@var{value}>
  2349. @cindex arm926ejs mw<bhw>_phys
  2350. @*Write memory at physical address addr.
  2351. @item @b{arm926ejs virt2phys} <@var{va}>
  2352. @cindex arm926ejs virt2phys
  2353. @*Translate a virtual address to a physical address.
  2354. @end itemize
  2355. @subsection CORTEX_M3 specific commands
  2356. @cindex CORTEX_M3 specific commands
  2357. @itemize @bullet
  2358. @item @b{cortex_m3 maskisr} <@var{on}|@var{off}>
  2359. @cindex cortex_m3 maskisr
  2360. @*Enable masking (disabling) interrupts during target step/resume.
  2361. @end itemize
  2362. @page
  2363. @section Debug commands
  2364. @cindex Debug commands
  2365. The following commands give direct access to the core, and are most likely
  2366. only useful while debugging OpenOCD.
  2367. @itemize @bullet
  2368. @item @b{arm7_9 write_xpsr} <@var{32-bit value}> <@option{0=cpsr}, @option{1=spsr}>
  2369. @cindex arm7_9 write_xpsr
  2370. @*Immediately write either the current program status register (CPSR) or the saved
  2371. program status register (SPSR), without changing the register cache (as displayed
  2372. by the @option{reg} and @option{armv4_5 reg} commands).
  2373. @item @b{arm7_9 write_xpsr_im8} <@var{8-bit value}> <@var{rotate 4-bit}>
  2374. <@var{0=cpsr},@var{1=spsr}>
  2375. @cindex arm7_9 write_xpsr_im8
  2376. @*Write the 8-bit value rotated right by 2*rotate bits, using an immediate write
  2377. operation (similar to @option{write_xpsr}).
  2378. @item @b{arm7_9 write_core_reg} <@var{num}> <@var{mode}> <@var{value}>
  2379. @cindex arm7_9 write_core_reg
  2380. @*Write a core register, without changing the register cache (as displayed by the
  2381. @option{reg} and @option{armv4_5 reg} commands). The <@var{mode}> argument takes the
  2382. encoding of the [M4:M0] bits of the PSR.
  2383. @end itemize
  2384. @section Target Requests
  2385. @cindex Target Requests
  2386. OpenOCD can handle certain target requests, currently debugmsg are only supported for arm7_9 and cortex_m3.
  2387. See libdcc in the contrib dir for more details.
  2388. @itemize @bullet
  2389. @item @b{target_request debugmsgs} <@var{enable}|@var{disable}>
  2390. @cindex target_request debugmsgs
  2391. @*Enable/disable target debugmsgs requests. debugmsgs enable messages to be sent to the debugger while the target is running.
  2392. @end itemize
  2393. @node JTAG Commands
  2394. @chapter JTAG Commands
  2395. @cindex JTAG commands
  2396. Generally most people will not use the bulk of these commands. They
  2397. are mostly used by the OpenOCD developers or those who need to
  2398. directly manipulate the JTAG taps.
  2399. In general these commands control JTAG taps at a very low level. For
  2400. example if you need to control a JTAG Route Controller (ie: the
  2401. OMAP3530 on the Beagle Board has one) you might use these commands in
  2402. a script or an event procedure.
  2403. @section Commands
  2404. @cindex Commands
  2405. @itemize @bullet
  2406. @item @b{scan_chain}
  2407. @cindex scan_chain
  2408. @*Print current scan chain configuration.
  2409. @item @b{jtag_reset} <@var{trst}> <@var{srst}>
  2410. @cindex jtag_reset
  2411. @*Toggle reset lines.
  2412. @item @b{endstate} <@var{tap_state}>
  2413. @cindex endstate
  2414. @*Finish JTAG operations in <@var{tap_state}>.
  2415. @item @b{runtest} <@var{num_cycles}>
  2416. @cindex runtest
  2417. @*Move to Run-Test/Idle, and execute <@var{num_cycles}>
  2418. @item @b{statemove} [@var{tap_state}]
  2419. @cindex statemove
  2420. @*Move to current endstate or [@var{tap_state}]
  2421. @item @b{irscan} <@var{device}> <@var{instr}> [@var{dev2}] [@var{instr2}] ...
  2422. @cindex irscan
  2423. @*Execute IR scan <@var{device}> <@var{instr}> [@var{dev2}] [@var{instr2}] ...
  2424. @item @b{drscan} <@var{device}> [@var{dev2}] [@var{var2}] ...
  2425. @cindex drscan
  2426. @*Execute DR scan <@var{device}> [@var{dev2}] [@var{var2}] ...
  2427. @item @b{verify_ircapture} <@option{enable}|@option{disable}>
  2428. @cindex verify_ircapture
  2429. @*Verify value captured during Capture-IR. Default is enabled.
  2430. @item @b{var} <@var{name}> [@var{num_fields}|@var{del}] [@var{size1}] ...
  2431. @cindex var
  2432. @*Allocate, display or delete variable <@var{name}> [@var{num_fields}|@var{del}] [@var{size1}] ...
  2433. @item @b{field} <@var{var}> <@var{field}> [@var{value}|@var{flip}]
  2434. @cindex field
  2435. Display/modify variable field <@var{var}> <@var{field}> [@var{value}|@var{flip}].
  2436. @end itemize
  2437. @section Tap states
  2438. @cindex Tap states
  2439. Available tap_states are:
  2440. @itemize @bullet
  2441. @item @b{RESET}
  2442. @cindex RESET
  2443. @item @b{IDLE}
  2444. @cindex IDLE
  2445. @item @b{DRSELECT}
  2446. @cindex DRSELECT
  2447. @item @b{DRCAPTURE}
  2448. @cindex DRCAPTURE
  2449. @item @b{DRSHIFT}
  2450. @cindex DRSHIFT
  2451. @item @b{DREXIT1}
  2452. @cindex DREXIT1
  2453. @item @b{DRPAUSE}
  2454. @cindex DRPAUSE
  2455. @item @b{DREXIT2}
  2456. @cindex DREXIT2
  2457. @item @b{DRUPDATE}
  2458. @cindex DRUPDATE
  2459. @item @b{IRSELECT}
  2460. @cindex IRSELECT
  2461. @item @b{IRCAPTURE}
  2462. @cindex IRCAPTURE
  2463. @item @b{IRSHIFT}
  2464. @cindex IRSHIFT
  2465. @item @b{IREXIT1}
  2466. @cindex IREXIT1
  2467. @item @b{IRPAUSE}
  2468. @cindex IRPAUSE
  2469. @item @b{IREXIT2}
  2470. @cindex IREXIT2
  2471. @item @b{IRUPDATE}
  2472. @cindex IRUPDATE
  2473. @end itemize
  2474. @node TFTP
  2475. @chapter TFTP
  2476. @cindex TFTP
  2477. If OpenOCD runs on an embedded host(as ZY1000 does), then tftp can
  2478. be used to access files on PCs(either developer PC or some other PC).
  2479. The way this works on the ZY1000 is to prefix a filename by
  2480. "/tftp/ip/" and append the tftp path on the tftp
  2481. server(tftpd). E.g. "load_image /tftp/10.0.0.96/c:\temp\abc.elf" will
  2482. load c:\temp\abc.elf from the developer pc (10.0.0.96) into memory as
  2483. if the file was hosted on the embedded host.
  2484. In order to achieve decent performance, you must choose a tftp server
  2485. that supports a packet size bigger than the default packet size(512 bytes). There
  2486. are numerous tftp servers out there(free and commercial) and you will have to do
  2487. a bit of googling to find something that fits your requirements.
  2488. @node Sample Scripts
  2489. @chapter Sample Scripts
  2490. @cindex scripts
  2491. This page shows how to use the target library.
  2492. The configuration script can be divided in the following section:
  2493. @itemize @bullet
  2494. @item daemon configuration
  2495. @item interface
  2496. @item jtag scan chain
  2497. @item target configuration
  2498. @item flash configuration
  2499. @end itemize
  2500. Detailed information about each section can be found at OpenOCD configuration.
  2501. @section AT91R40008 example
  2502. @cindex AT91R40008 example
  2503. To start OpenOCD with a target script for the AT91R40008 CPU and reset
  2504. the CPU upon startup of the OpenOCD daemon.
  2505. @example
  2506. openocd -f interface/parport.cfg -f target/at91r40008.cfg -c init -c reset
  2507. @end example
  2508. @node GDB and OpenOCD
  2509. @chapter GDB and OpenOCD
  2510. @cindex GDB and OpenOCD
  2511. OpenOCD complies with the remote gdbserver protocol, and as such can be used
  2512. to debug remote targets.
  2513. @section Connecting to GDB
  2514. @cindex Connecting to GDB
  2515. @anchor{Connecting to GDB}
  2516. Use GDB 6.7 or newer with OpenOCD if you run into trouble. For
  2517. instance 6.3 has a known bug where it produces bogus memory access
  2518. errors, which has since been fixed: look up 1836 in
  2519. @url{http://sourceware.org/cgi-bin/gnatsweb.pl?database=gdb}
  2520. @*OpenOCD can communicate with GDB in two ways:
  2521. @enumerate
  2522. @item
  2523. A socket (tcp) connection is typically started as follows:
  2524. @example
  2525. target remote localhost:3333
  2526. @end example
  2527. This would cause GDB to connect to the gdbserver on the local pc using port 3333.
  2528. @item
  2529. A pipe connection is typically started as follows:
  2530. @example
  2531. target remote | openocd --pipe
  2532. @end example
  2533. This would cause GDB to run OpenOCD and communicate using pipes (stdin/stdout).
  2534. Using this method has the advantage of GDB starting/stopping OpenOCD for the debug
  2535. session.
  2536. @end enumerate
  2537. @*To see a list of available OpenOCD commands type @option{monitor help} on the
  2538. GDB commandline.
  2539. OpenOCD supports the gdb @option{qSupported} packet, this enables information
  2540. to be sent by the gdb server (OpenOCD) to GDB. Typical information includes
  2541. packet size and device memory map.
  2542. Previous versions of OpenOCD required the following GDB options to increase
  2543. the packet size and speed up GDB communication.
  2544. @example
  2545. set remote memory-write-packet-size 1024
  2546. set remote memory-write-packet-size fixed
  2547. set remote memory-read-packet-size 1024
  2548. set remote memory-read-packet-size fixed
  2549. @end example
  2550. This is now handled in the @option{qSupported} PacketSize and should not be required.
  2551. @section Programming using GDB
  2552. @cindex Programming using GDB
  2553. By default the target memory map is sent to GDB, this can be disabled by
  2554. the following OpenOCD config option:
  2555. @example
  2556. gdb_memory_map disable
  2557. @end example
  2558. For this to function correctly a valid flash config must also be configured
  2559. in OpenOCD. For faster performance you should also configure a valid
  2560. working area.
  2561. Informing GDB of the memory map of the target will enable GDB to protect any
  2562. flash area of the target and use hardware breakpoints by default. This means
  2563. that the OpenOCD option @option{gdb_breakpoint_override} is not required when
  2564. using a memory map. @xref{gdb_breakpoint_override}.
  2565. To view the configured memory map in GDB, use the gdb command @option{info mem}
  2566. All other unasigned addresses within GDB are treated as RAM.
  2567. GDB 6.8 and higher set any memory area not in the memory map as inaccessible,
  2568. this can be changed to the old behaviour by using the following GDB command.
  2569. @example
  2570. set mem inaccessible-by-default off
  2571. @end example
  2572. If @option{gdb_flash_program enable} is also used, GDB will be able to
  2573. program any flash memory using the vFlash interface.
  2574. GDB will look at the target memory map when a load command is given, if any
  2575. areas to be programmed lie within the target flash area the vFlash packets
  2576. will be used.
  2577. If the target needs configuring before GDB programming, an event
  2578. script can be executed.
  2579. @example
  2580. $_TARGETNAME configure -event EVENTNAME BODY
  2581. @end example
  2582. To verify any flash programming the GDB command @option{compare-sections}
  2583. can be used.
  2584. @node TCL scripting API
  2585. @chapter TCL scripting API
  2586. @cindex TCL scripting API
  2587. API rules
  2588. The commands are stateless. E.g. the telnet command line has a concept
  2589. of currently active target, the Tcl API proc's take this sort of state
  2590. information as an argument to each proc.
  2591. There are three main types of return values: single value, name value
  2592. pair list and lists.
  2593. Name value pair. The proc 'foo' below returns a name/value pair
  2594. list.
  2595. @verbatim
  2596. > set foo(me) Duane
  2597. > set foo(you) Oyvind
  2598. > set foo(mouse) Micky
  2599. > set foo(duck) Donald
  2600. If one does this:
  2601. > set foo
  2602. The result is:
  2603. me Duane you Oyvind mouse Micky duck Donald
  2604. Thus, to get the names of the associative array is easy:
  2605. foreach { name value } [set foo] {
  2606. puts "Name: $name, Value: $value"
  2607. }
  2608. @end verbatim
  2609. Lists returned must be relatively small. Otherwise a range
  2610. should be passed in to the proc in question.
  2611. Low level commands are prefixed with "openocd_", e.g. openocd_flash_banks
  2612. is the low level API upon which "flash banks" is implemented.
  2613. @itemize @bullet
  2614. @item @b{ocd_mem2array} <@var{varname}> <@var{width}> <@var{addr}> <@var{nelems}>
  2615. Read memory and return as a TCL array for script processing
  2616. @item @b{ocd_array2mem} <@var{varname}> <@var{width}> <@var{addr}> <@var{nelems}>
  2617. Convert a TCL array to memory locations and write the values
  2618. @item @b{ocd_flash_banks} <@var{driver}> <@var{base}> <@var{size}> <@var{chip_width}> <@var{bus_width}> <@var{target}> [@option{driver options} ...]
  2619. Return information about the flash banks
  2620. @end itemize
  2621. OpenOCD commands can consist of two words, e.g. "flash banks". The
  2622. startup.tcl "unknown" proc will translate this into a tcl proc
  2623. called "flash_banks".
  2624. @node Upgrading
  2625. @chapter Deprecated/Removed Commands
  2626. @cindex Deprecated/Removed Commands
  2627. Certain OpenOCD commands have been deprecated/removed during the various revisions.
  2628. @itemize @bullet
  2629. @item @b{arm7_9 fast_writes}
  2630. @cindex arm7_9 fast_writes
  2631. @*use @option{arm7_9 fast_memory_access} command with same args. @xref{arm7_9 fast_memory_access}.
  2632. @item @b{arm7_9 force_hw_bkpts}
  2633. @cindex arm7_9 force_hw_bkpts
  2634. @*Use @option{gdb_breakpoint_override} instead. Note that GDB will use hardware breakpoints
  2635. for flash if the gdb memory map has been set up(default when flash is declared in
  2636. target configuration). @xref{gdb_breakpoint_override}.
  2637. @item @b{arm7_9 sw_bkpts}
  2638. @cindex arm7_9 sw_bkpts
  2639. @*On by default. See also @option{gdb_breakpoint_override}. @xref{gdb_breakpoint_override}.
  2640. @item @b{daemon_startup}
  2641. @cindex daemon_startup
  2642. @*this config option has been removed, simply adding @option{init} and @option{reset halt} to
  2643. the end of your config script will give the same behaviour as using @option{daemon_startup reset}
  2644. and @option{target cortex_m3 little reset_halt 0}.
  2645. @item @b{dump_binary}
  2646. @cindex dump_binary
  2647. @*use @option{dump_image} command with same args. @xref{dump_image}.
  2648. @item @b{flash erase}
  2649. @cindex flash erase
  2650. @*use @option{flash erase_sector} command with same args. @xref{flash erase_sector}.
  2651. @item @b{flash write}
  2652. @cindex flash write
  2653. @*use @option{flash write_bank} command with same args. @xref{flash write_bank}.
  2654. @item @b{flash write_binary}
  2655. @cindex flash write_binary
  2656. @*use @option{flash write_bank} command with same args. @xref{flash write_bank}.
  2657. @item @b{flash auto_erase}
  2658. @cindex flash auto_erase
  2659. @*use @option{flash write_image} command passing @option{erase} as the first parameter. @xref{flash write_image}.
  2660. @item @b{load_binary}
  2661. @cindex load_binary
  2662. @*use @option{load_image} command with same args. @xref{load_image}.
  2663. @item @b{run_and_halt_time}
  2664. @cindex run_and_halt_time
  2665. @*This command has been removed for simpler reset behaviour, it can be simulated with the
  2666. following commands:
  2667. @smallexample
  2668. reset run
  2669. sleep 100
  2670. halt
  2671. @end smallexample
  2672. @item @b{target} <@var{type}> <@var{endian}> <@var{jtag-position}>
  2673. @cindex target
  2674. @*use the create subcommand of @option{target}.
  2675. @item @b{target_script} <@var{target#}> <@var{eventname}> <@var{scriptname}>
  2676. @cindex target_script
  2677. @*use <@var{target_name}> configure -event <@var{eventname}> "script <@var{scriptname}>"
  2678. @item @b{working_area}
  2679. @cindex working_area
  2680. @*use the @option{configure} subcommand of @option{target} to set the work-area-virt, work-area-phy, work-area-size, and work-area-backup properties of the target.
  2681. @end itemize
  2682. @node FAQ
  2683. @chapter FAQ
  2684. @cindex faq
  2685. @enumerate
  2686. @item @b{RTCK, also known as: Adaptive Clocking - What is it?}
  2687. @cindex RTCK
  2688. @cindex adaptive clocking
  2689. @*
  2690. In digital circuit design it is often refered to as ``clock
  2691. synchronisation'' the JTAG interface uses one clock (TCK or TCLK)
  2692. operating at some speed, your target is operating at another. The two
  2693. clocks are not synchronised, they are ``asynchronous''
  2694. In order for the two to work together they must be synchronised. Otherwise
  2695. the two systems will get out of sync with each other and nothing will
  2696. work. There are 2 basic options.
  2697. @enumerate
  2698. @item
  2699. Use a special circuit.
  2700. @item
  2701. One clock must be some multiple slower the the other.
  2702. @end enumerate
  2703. @b{Does this really matter?} For some chips and some situations, this
  2704. is a non-issue (ie: A 500MHz ARM926) but for others - for example some
  2705. ATMEL SAM7 and SAM9 chips start operation from reset at 32kHz -
  2706. program/enable the oscillators and eventually the main clock. It is in
  2707. those critical times you must slow the jtag clock to sometimes 1 to
  2708. 4kHz.
  2709. Imagine debugging that 500MHz ARM926 hand held battery powered device
  2710. that ``deep sleeps'' at 32kHz between every keystroke. It can be
  2711. painful.
  2712. @b{Solution #1 - A special circuit}
  2713. In order to make use of this your jtag dongle must support the RTCK
  2714. feature. Not all dongles support this - keep reading!
  2715. The RTCK signal often found in some ARM chips is used to help with
  2716. this problem. ARM has a good description of the problem described at
  2717. this link: @url{http://www.arm.com/support/faqdev/4170.html} [checked
  2718. 28/nov/2008]. Link title: ``How does the jtag synchronisation logic
  2719. work? / how does adaptive clocking work?''.
  2720. The nice thing about adaptive clocking is that ``battery powered hand
  2721. held device example'' - the adaptiveness works perfectly all the
  2722. time. One can set a break point or halt the system in the deep power
  2723. down code, slow step out until the system speeds up.
  2724. @b{Solution #2 - Always works - but may be slower}
  2725. Often this is a perfectly acceptable solution.
  2726. In the most simple terms: Often the JTAG clock must be 1/10 to 1/12 of
  2727. the target clock speed. But what is that ``magic division'' it varies
  2728. depending upon the chips on your board. @b{ARM Rule of thumb} Most ARM
  2729. based systems require an 8:1 division. @b{Xilinx Rule of thumb} is
  2730. 1/12 the clock speed.
  2731. Note: Many FTDI2232C based JTAG dongles are limited to 6MHz.
  2732. You can still debug the 'lower power' situations - you just need to
  2733. manually adjust the clock speed at every step. While painful and
  2734. teadious, it is not always practical.
  2735. It is however easy to ``code your way around it'' - ie: Cheat a little
  2736. have a special debug mode in your application that does a ``high power
  2737. sleep''. If you are careful - 98% of your problems can be debugged
  2738. this way.
  2739. To set the JTAG frequency use the command:
  2740. @example
  2741. # Example: 1.234MHz
  2742. jtag_khz 1234
  2743. @end example
  2744. @item @b{Win32 Pathnames} Why does not backslashes in paths under Windows doesn't work?
  2745. OpenOCD uses Tcl and a backslash is an escape char. Use @{ and @}
  2746. around Windows filenames.
  2747. @example
  2748. > echo \a
  2749. > echo @{\a@}
  2750. \a
  2751. > echo "\a"
  2752. >
  2753. @end example
  2754. @item @b{Missing: cygwin1.dll} OpenOCD complains about a missing cygwin1.dll.
  2755. Make sure you have Cygwin installed, or at least a version of OpenOCD that
  2756. claims to come with all the necessary dlls. When using Cygwin, try launching
  2757. OpenOCD from the Cygwin shell.
  2758. @item @b{Breakpoint Issue} I'm trying to set a breakpoint using GDB (or a frontend like Insight or
  2759. Eclipse), but OpenOCD complains that "Info: arm7_9_common.c:213
  2760. arm7_9_add_breakpoint(): sw breakpoint requested, but software breakpoints not enabled".
  2761. GDB issues software breakpoints when a normal breakpoint is requested, or to implement
  2762. source-line single-stepping. On ARMv4T systems, like ARM7TDMI, ARM720t or ARM920t,
  2763. software breakpoints consume one of the two available hardware breakpoints.
  2764. @item @b{LPC2000 Flash} When erasing or writing LPC2000 on-chip flash, the operation fails sometimes
  2765. and works sometimes fine.
  2766. Make sure the core frequency specified in the @option{flash lpc2000} line matches the
  2767. clock at the time you're programming the flash. If you've specified the crystal's
  2768. frequency, make sure the PLL is disabled, if you've specified the full core speed
  2769. (e.g. 60MHz), make sure the PLL is enabled.
  2770. @item @b{Amontec Chameleon} When debugging using an Amontec Chameleon in its JTAG Accelerator configuration,
  2771. I keep getting "Error: amt_jtagaccel.c:184 amt_wait_scan_busy(): amt_jtagaccel timed
  2772. out while waiting for end of scan, rtck was disabled".
  2773. Make sure your PC's parallel port operates in EPP mode. You might have to try several
  2774. settings in your PC BIOS (ECP, EPP, and different versions of those).
  2775. @item @b{Data Aborts} When debugging with OpenOCD and GDB (plain GDB, Insight, or Eclipse),
  2776. I get lots of "Error: arm7_9_common.c:1771 arm7_9_read_memory():
  2777. memory read caused data abort".
  2778. The errors are non-fatal, and are the result of GDB trying to trace stack frames
  2779. beyond the last valid frame. It might be possible to prevent this by setting up
  2780. a proper "initial" stack frame, if you happen to know what exactly has to
  2781. be done, feel free to add this here.
  2782. @b{Simple:} In your startup code - push 8 registers of ZEROs onto the
  2783. stack before calling main(). What GDB is doing is ``climbing'' the run
  2784. time stack by reading various values on the stack using the standard
  2785. call frame for the target. GDB keeps going - until one of 2 things
  2786. happen @b{#1} an invalid frame is found, or @b{#2} some huge number of
  2787. stackframes have been processed. By pushing ZEROs on the stack, GDB
  2788. gracefully stops.
  2789. @b{Debugging Interrupt Service Routines} - In your ISR before you call
  2790. your C code, do the same, artifically push some zeros on to the stack,
  2791. remember to pop them off when the ISR is done.
  2792. @b{Also note:} If you have a multi-threaded operating system, they
  2793. often do not @b{in the intrest of saving memory} waste these few
  2794. bytes. Painful...
  2795. @item @b{JTAG Reset Config} I get the following message in the OpenOCD console (or log file):
  2796. "Warning: arm7_9_common.c:679 arm7_9_assert_reset(): srst resets test logic, too".
  2797. This warning doesn't indicate any serious problem, as long as you don't want to
  2798. debug your core right out of reset. Your .cfg file specified @option{jtag_reset
  2799. trst_and_srst srst_pulls_trst} to tell OpenOCD that either your board,
  2800. your debugger or your target uC (e.g. LPC2000) can't assert the two reset signals
  2801. independently. With this setup, it's not possible to halt the core right out of
  2802. reset, everything else should work fine.
  2803. @item @b{USB Power} When using OpenOCD in conjunction with Amontec JTAGkey and the Yagarto
  2804. Toolchain (Eclipse, arm-elf-gcc, arm-elf-gdb), the debugging seems to be
  2805. unstable. When single-stepping over large blocks of code, GDB and OpenOCD
  2806. quit with an error message. Is there a stability issue with OpenOCD?
  2807. No, this is not a stability issue concerning OpenOCD. Most users have solved
  2808. this issue by simply using a self-powered USB hub, which they connect their
  2809. Amontec JTAGkey to. Apparently, some computers do not provide a USB power
  2810. supply stable enough for the Amontec JTAGkey to be operated.
  2811. @b{Laptops running on battery have this problem too...}
  2812. @item @b{USB Power} When using the Amontec JTAGkey, sometimes OpenOCD crashes with the
  2813. following error messages: "Error: ft2232.c:201 ft2232_read(): FT_Read returned:
  2814. 4" and "Error: ft2232.c:365 ft2232_send_and_recv(): couldn't read from FT2232".
  2815. What does that mean and what might be the reason for this?
  2816. First of all, the reason might be the USB power supply. Try using a self-powered
  2817. hub instead of a direct connection to your computer. Secondly, the error code 4
  2818. corresponds to an FT_IO_ERROR, which means that the driver for the FTDI USB
  2819. chip ran into some sort of error - this points us to a USB problem.
  2820. @item @b{GDB Disconnects} When using the Amontec JTAGkey, sometimes OpenOCD crashes with the following
  2821. error message: "Error: gdb_server.c:101 gdb_get_char(): read: 10054".
  2822. What does that mean and what might be the reason for this?
  2823. Error code 10054 corresponds to WSAECONNRESET, which means that the debugger (GDB)
  2824. has closed the connection to OpenOCD. This might be a GDB issue.
  2825. @item @b{LPC2000 Flash} In the configuration file in the section where flash device configurations
  2826. are described, there is a parameter for specifying the clock frequency
  2827. for LPC2000 internal flash devices (e.g. @option{flash bank lpc2000
  2828. 0x0 0x40000 0 0 0 lpc2000_v1 14746 calc_checksum}), which must be
  2829. specified in kilohertz. However, I do have a quartz crystal of a
  2830. frequency that contains fractions of kilohertz (e.g. 14,745,600 Hz,
  2831. i.e. 14,745.600 kHz). Is it possible to specify real numbers for the
  2832. clock frequency?
  2833. No. The clock frequency specified here must be given as an integral number.
  2834. However, this clock frequency is used by the In-Application-Programming (IAP)
  2835. routines of the LPC2000 family only, which seems to be very tolerant concerning
  2836. the given clock frequency, so a slight difference between the specified clock
  2837. frequency and the actual clock frequency will not cause any trouble.
  2838. @item @b{Command Order} Do I have to keep a specific order for the commands in the configuration file?
  2839. Well, yes and no. Commands can be given in arbitrary order, yet the
  2840. devices listed for the JTAG scan chain must be given in the right
  2841. order (jtag newdevice), with the device closest to the TDO-Pin being
  2842. listed first. In general, whenever objects of the same type exist
  2843. which require an index number, then these objects must be given in the
  2844. right order (jtag newtap, targets and flash banks - a target
  2845. references a jtag newtap and a flash bank references a target).
  2846. You can use the ``scan_chain'' command to verify and display the tap order.
  2847. @item @b{JTAG Tap Order} JTAG Tap Order - Command Order
  2848. Many newer devices have multiple JTAG taps. For example: ST
  2849. Microsystems STM32 chips have two taps, a ``boundary scan tap'' and
  2850. ``CortexM3'' tap. Example: The STM32 reference manual, Document ID:
  2851. RM0008, Section 26.5, Figure 259, page 651/681, the ``TDI'' pin is
  2852. connected to the Boundary Scan Tap, which then connects to the
  2853. CortexM3 Tap, which then connects to the TDO pin.
  2854. Thus, the proper order for the STM32 chip is: (1) The CortexM3, then
  2855. (2) The Boundary Scan Tap. If your board includes an additional JTAG
  2856. chip in the scan chain (for example a Xilinx CPLD or FPGA) you could
  2857. place it before or after the stm32 chip in the chain. For example:
  2858. @itemize @bullet
  2859. @item OpenOCD_TDI(output) -> STM32 TDI Pin (BS Input)
  2860. @item STM32 BS TDO (output) -> STM32 CortexM3 TDI (input)
  2861. @item STM32 CortexM3 TDO (output) -> SM32 TDO Pin
  2862. @item STM32 TDO Pin (output) -> Xilinx TDI Pin (input)
  2863. @item Xilinx TDO Pin -> OpenOCD TDO (input)
  2864. @end itemize
  2865. The ``jtag device'' commands would thus be in the order shown below. Note
  2866. @itemize @bullet
  2867. @item jtag newtap Xilinx tap -irlen ...
  2868. @item jtag newtap stm32 cpu -irlen ...
  2869. @item jtag newtap stm32 bs -irlen ...
  2870. @item # Create the debug target and say where it is
  2871. @item target create stm32.cpu -chain-position stm32.cpu ...
  2872. @end itemize
  2873. @item @b{SYSCOMP} Sometimes my debugging session terminates with an error. When I look into the
  2874. log file, I can see these error messages: Error: arm7_9_common.c:561
  2875. arm7_9_execute_sys_speed(): timeout waiting for SYSCOMP
  2876. TODO.
  2877. @end enumerate
  2878. @node TCL Crash Course
  2879. @chapter TCL Crash Course
  2880. @cindex TCL
  2881. Not everyone knows TCL - this is not intended to be a replacement for
  2882. learning TCL, the intent of this chapter is to give you some idea of
  2883. how the TCL Scripts work.
  2884. This chapter is written with two audiences in mind. (1) OpenOCD users
  2885. who need to understand a bit more of how JIM-Tcl works so they can do
  2886. something useful, and (2) those that want to add a new command to
  2887. OpenOCD.
  2888. @section TCL Rule #1
  2889. There is a famous joke, it goes like this:
  2890. @enumerate
  2891. @item Rule #1: The wife is always correct
  2892. @item Rule #2: If you think otherwise, See Rule #1
  2893. @end enumerate
  2894. The TCL equal is this:
  2895. @enumerate
  2896. @item Rule #1: Everything is a string
  2897. @item Rule #2: If you think otherwise, See Rule #1
  2898. @end enumerate
  2899. As in the famous joke, the consequences of Rule #1 are profound. Once
  2900. you understand Rule #1, you will understand TCL.
  2901. @section TCL Rule #1b
  2902. There is a second pair of rules.
  2903. @enumerate
  2904. @item Rule #1: Control flow does not exist. Only commands
  2905. @* For example: the classic FOR loop or IF statement is not a control
  2906. flow item, they are commands, there is no such thing as control flow
  2907. in TCL.
  2908. @item Rule #2: If you think otherwise, See Rule #1
  2909. @* Actually what happens is this: There are commands that by
  2910. convention, act like control flow key words in other languages. One of
  2911. those commands is the word ``for'', another command is ``if''.
  2912. @end enumerate
  2913. @section Per Rule #1 - All Results are strings
  2914. Every TCL command results in a string. The word ``result'' is used
  2915. deliberatly. No result is just an empty string. Remember: @i{Rule #1 -
  2916. Everything is a string}
  2917. @section TCL Quoting Operators
  2918. In life of a TCL script, there are two important periods of time, the
  2919. difference is subtle.
  2920. @enumerate
  2921. @item Parse Time
  2922. @item Evaluation Time
  2923. @end enumerate
  2924. The two key items here are how ``quoted things'' work in TCL. TCL has
  2925. three primary quoting constructs, the [square-brackets] the
  2926. @{curly-braces@} and ``double-quotes''
  2927. By now you should know $VARIABLES always start with a $DOLLAR
  2928. sign. BTW, to set a variable, you actually use the command ``set'', as
  2929. in ``set VARNAME VALUE'' much like the ancient BASIC langauge ``let x
  2930. = 1'' statement, but without the equal sign.
  2931. @itemize @bullet
  2932. @item @b{[square-brackets]}
  2933. @* @b{[square-brackets]} are command subsitution. It operates much
  2934. like Unix Shell `back-ticks`. The result of a [square-bracket]
  2935. operation is exactly 1 string. @i{Remember Rule #1 - Everything is a
  2936. string}. These two statments are roughly identical.
  2937. @example
  2938. # bash example
  2939. X=`date`
  2940. echo "The Date is: $X"
  2941. # TCL example
  2942. set X [date]
  2943. puts "The Date is: $X"
  2944. @end example
  2945. @item @b{``double-quoted-things''}
  2946. @* @b{``double-quoted-things''} are just simply quoted
  2947. text. $VARIABLES and [square-brackets] are expanded in place - the
  2948. result however is exactly 1 string. @i{Remember Rule #1 - Everything
  2949. is a string}
  2950. @example
  2951. set x "Dinner"
  2952. puts "It is now \"[date]\", $x is in 1 hour"
  2953. @end example
  2954. @item @b{@{Curly-Braces@}}
  2955. @*@b{@{Curly-Braces@}} are magic: $VARIABLES and [square-brackets] are
  2956. parsed, but are NOT expanded or executed. @{Curly-Braces@} are like
  2957. 'single-quote' operators in BASH shell scripts, with the added
  2958. feature: @{curly-braces@} nest, single quotes can not. @{@{@{this is
  2959. nested 3 times@}@}@} NOTE: [date] is perhaps a bad example, as of
  2960. 28/nov/2008, Jim/OpenOCD does not have a date command.
  2961. @end itemize
  2962. @section Consequences of Rule 1/2/3/4
  2963. The consequences of Rule 1 is profound.
  2964. @subsection Tokenizing & Execution.
  2965. Of course, whitespace, blank lines and #comment lines are handled in
  2966. the normal way.
  2967. As a script is parsed, each (multi) line in the script file is
  2968. tokenized and according to the quoting rules. After tokenizing, that
  2969. line is immedatly executed.
  2970. Multi line statements end with one or more ``still-open''
  2971. @{curly-braces@} which - eventually - a few lines later closes.
  2972. @subsection Command Execution
  2973. Remember earlier: There is no such thing as ``control flow''
  2974. statements in TCL. Instead there are COMMANDS that simpily act like
  2975. control flow operators.
  2976. Commands are executed like this:
  2977. @enumerate
  2978. @item Parse the next line into (argc) and (argv[]).
  2979. @item Look up (argv[0]) in a table and call its function.
  2980. @item Repeat until End Of File.
  2981. @end enumerate
  2982. It sort of works like this:
  2983. @example
  2984. for(;;)@{
  2985. ReadAndParse( &argc, &argv );
  2986. cmdPtr = LookupCommand( argv[0] );
  2987. (*cmdPtr->Execute)( argc, argv );
  2988. @}
  2989. @end example
  2990. When the command ``proc'' is parsed (which creates a procedure
  2991. function) it gets 3 parameters on the command line. @b{1} the name of
  2992. the proc (function), @b{2} the list of parameters, and @b{3} the body
  2993. of the function. Not the choice of words: LIST and BODY. The PROC
  2994. command stores these items in a table somewhere so it can be found by
  2995. ``LookupCommand()''
  2996. @subsection The FOR Command
  2997. The most interesting command to look at is the FOR command. In TCL,
  2998. the FOR command is normally implimented in C. Remember, FOR is a
  2999. command just like any other command.
  3000. When the ascii text containing the FOR command is parsed, the parser
  3001. produces 5 parameter strings, @i{(If in doubt: Refer to Rule #1)} they
  3002. are:
  3003. @enumerate 0
  3004. @item The ascii text 'for'
  3005. @item The start text
  3006. @item The test expression
  3007. @item The next text
  3008. @item The body text
  3009. @end enumerate
  3010. Sort of reminds you of ``main( int argc, char **argv )'' does it not?
  3011. Remember @i{Rule #1 - Everything is a string.} The key point is this:
  3012. Often many of those parameters are in @{curly-braces@} - thus the
  3013. variables inside are not expanded or replaced until later.
  3014. Remember that every TCL command looks like the classic ``main( argc,
  3015. argv )'' function in C. In JimTCL - they actually look like this:
  3016. @example
  3017. int
  3018. MyCommand( Jim_Interp *interp,
  3019. int *argc,
  3020. Jim_Obj * const *argvs );
  3021. @end example
  3022. Real TCL is nearly identical. Although the newer versions have
  3023. introduced a byte-code parser and intepreter, but at the core, it
  3024. still operates in the same basic way.
  3025. @subsection FOR Command Implimentation
  3026. To understand TCL it is perhaps most helpful to see the FOR
  3027. command. Remember, it is a COMMAND not a control flow structure.
  3028. In TCL there are two underying C helper functions.
  3029. Remember Rule #1 - You are a string.
  3030. The @b{first} helper parses and executes commands found in an ascii
  3031. string. Commands can be seperated by semi-colons, or newlines. While
  3032. parsing, variables are expanded per the quoting rules
  3033. The @b{second} helper evaluates an ascii string as a numerical
  3034. expression and returns a value.
  3035. Here is an example of how the @b{FOR} command could be
  3036. implimented. The pseudo code below does not show error handling.
  3037. @example
  3038. void Execute_AsciiString( void *interp, const char *string );
  3039. int Evaluate_AsciiExpression( void *interp, const char *string );
  3040. int
  3041. MyForCommand( void *interp,
  3042. int argc,
  3043. char **argv )
  3044. @{
  3045. if( argc != 5 )@{
  3046. SetResult( interp, "WRONG number of parameters");
  3047. return ERROR;
  3048. @}
  3049. // argv[0] = the ascii string just like C
  3050. // Execute the start statement.
  3051. Execute_AsciiString( interp, argv[1] );
  3052. // Top of loop test
  3053. for(;;)@{
  3054. i = Evaluate_AsciiExpression(interp, argv[2]);
  3055. if( i == 0 )
  3056. break;
  3057. // Execute the body
  3058. Execute_AsciiString( interp, argv[3] );
  3059. // Execute the LOOP part
  3060. Execute_AsciiString( interp, argv[4] );
  3061. @}
  3062. // Return no error
  3063. SetResult( interp, "" );
  3064. return SUCCESS;
  3065. @}
  3066. @end example
  3067. Every other command IF, WHILE, FORMAT, PUTS, EXPR, everything works
  3068. in the same basic way.
  3069. @section OpenOCD TCL Usage
  3070. @subsection source and find commands
  3071. @b{Where:} In many configuration files
  3072. @* Example: @b{ source [find FILENAME] }
  3073. @*Remember the parsing rules
  3074. @enumerate
  3075. @item The FIND command is in square brackets.
  3076. @* The FIND command is executed with the parameter FILENAME. It should
  3077. find the full path to the named file. The RESULT is a string, which is
  3078. subsituted on the orginal command line.
  3079. @item The command source is executed with the resulting filename.
  3080. @* SOURCE reads a file and executes as a script.
  3081. @end enumerate
  3082. @subsection format command
  3083. @b{Where:} Generally occurs in numerous places.
  3084. @* TCL no command like @b{printf()}, intead it has @b{format}, which is really more like
  3085. @b{sprintf()}.
  3086. @b{Example}
  3087. @example
  3088. set x 6
  3089. set y 7
  3090. puts [format "The answer: %d" [expr $x * $y]]
  3091. @end example
  3092. @enumerate
  3093. @item The SET command creates 2 variables, X and Y.
  3094. @item The double [nested] EXPR command performs math
  3095. @* The EXPR command produces numerical result as a string.
  3096. @* Refer to Rule #1
  3097. @item The format command is executed, producing a single string
  3098. @* Refer to Rule #1.
  3099. @item The PUTS command outputs the text.
  3100. @end enumerate
  3101. @subsection Body Or Inlined Text
  3102. @b{Where:} Various TARGET scripts.
  3103. @example
  3104. #1 Good
  3105. proc someproc @{@} @{
  3106. ... multiple lines of stuff ...
  3107. @}
  3108. $_TARGETNAME configure -event FOO someproc
  3109. #2 Good - no variables
  3110. $_TARGETNAME confgure -event foo "this ; that;"
  3111. #3 Good Curly Braces
  3112. $_TARGETNAME configure -event FOO @{
  3113. puts "Time: [date]"
  3114. @}
  3115. #4 DANGER DANGER DANGER
  3116. $_TARGETNAME configure -event foo "puts \"Time: [date]\""
  3117. @end example
  3118. @enumerate
  3119. @item The $_TARGETNAME is an OpenOCD variable convention.
  3120. @*@b{$_TARGETNAME} represents the last target created, the value changes
  3121. each time a new target is created. Remember the parsing rules. When
  3122. the ascii text is parsed, the @b{$_TARGETNAME} becomes a simple string,
  3123. the name of the target which happens to be a TARGET (object)
  3124. command.
  3125. @item The 2nd parameter to the @option{-event} parameter is a TCBODY
  3126. @*There are 4 examples:
  3127. @enumerate
  3128. @item The TCLBODY is a simple string that happens to be a proc name
  3129. @item The TCLBODY is several simple commands semi-colon seperated
  3130. @item The TCLBODY is a multi-line @{curly-brace@} quoted string
  3131. @item The TCLBODY is a string with variables that get expanded.
  3132. @end enumerate
  3133. In the end, when the target event FOO occurs the TCLBODY is
  3134. evaluated. Method @b{#1} and @b{#2} are functionally identical. For
  3135. Method @b{#3} and @b{#4} it is more interesting. What is the TCLBODY?
  3136. Remember the parsing rules. In case #3, @{curly-braces@} mean the
  3137. $VARS and [square-brackets] are expanded later, when the EVENT occurs,
  3138. and the text is evaluated. In case #4, they are replaced before the
  3139. ``Target Object Command'' is executed. This occurs at the same time
  3140. $_TARGETNAME is replaced. In case #4 the date will never
  3141. change. @{BTW: [date] is perhaps a bad example, as of 28/nov/2008,
  3142. Jim/OpenOCD does not have a date command@}
  3143. @end enumerate
  3144. @subsection Global Variables
  3145. @b{Where:} You might discover this when writing your own procs @* In
  3146. simple terms: Inside a PROC, if you need to access a global variable
  3147. you must say so. Also see ``upvar''. Example:
  3148. @example
  3149. proc myproc @{ @} @{
  3150. set y 0 #Local variable Y
  3151. global x #Global variable X
  3152. puts [format "X=%d, Y=%d" $x $y]
  3153. @}
  3154. @end example
  3155. @section Other Tcl Hacks
  3156. @b{Dynamic Variable Creation}
  3157. @example
  3158. # Dynamically create a bunch of variables.
  3159. for @{ set x 0 @} @{ $x < 32 @} @{ set x [expr $x + 1]@} @{
  3160. # Create var name
  3161. set vn [format "BIT%d" $x]
  3162. # Make it a global
  3163. global $vn
  3164. # Set it.
  3165. set $vn [expr (1 << $x)]
  3166. @}
  3167. @end example
  3168. @b{Dynamic Proc/Command Creation}
  3169. @example
  3170. # One "X" function - 5 uart functions.
  3171. foreach who @{A B C D E@}
  3172. proc [format "show_uart%c" $who] @{ @} "show_UARTx $who"
  3173. @}
  3174. @end example
  3175. @node Target library
  3176. @chapter Target library
  3177. @cindex Target library
  3178. OpenOCD comes with a target configuration script library. These scripts can be
  3179. used as-is or serve as a starting point.
  3180. The target library is published together with the OpenOCD executable and
  3181. the path to the target library is in the OpenOCD script search path.
  3182. Similarly there are example scripts for configuring the JTAG interface.
  3183. The command line below uses the example parport configuration scripts
  3184. that ship with OpenOCD, then configures the str710.cfg target and
  3185. finally issues the init and reset command. The communication speed
  3186. is set to 10kHz for reset and 8MHz for post reset.
  3187. @example
  3188. openocd -f interface/parport.cfg -f target/str710.cfg -c "init" -c "reset"
  3189. @end example
  3190. To list the target scripts available:
  3191. @example
  3192. $ ls /usr/local/lib/openocd/target
  3193. arm7_fast.cfg lm3s6965.cfg pxa255.cfg stm32.cfg xba_revA3.cfg
  3194. at91eb40a.cfg lpc2148.cfg pxa255_sst.cfg str710.cfg zy1000.cfg
  3195. at91r40008.cfg lpc2294.cfg sam7s256.cfg str912.cfg
  3196. at91sam9260.cfg nslu2.cfg sam7x256.cfg wi-9c.cfg
  3197. @end example
  3198. @include fdl.texi
  3199. @node OpenOCD Index
  3200. @comment DO NOT use the plain word ``Index'', reason: CYGWIN filename
  3201. @comment case issue with ``Index.html'' and ``index.html''
  3202. @comment Occurs when creating ``--html --no-split'' output
  3203. @comment This fix is based on: http://sourceware.org/ml/binutils/2006-05/msg00215.html
  3204. @unnumbered OpenOCD Index
  3205. @printindex cp
  3206. @bye