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.
 
 
 
 
 
 

7666 lines
282 KiB

  1. \input texinfo @c -*-texinfo-*-
  2. @c %**start of header
  3. @setfilename openocd.info
  4. @settitle OpenOCD User's Guide
  5. @dircategory Development
  6. @direntry
  7. * OpenOCD: (openocd). OpenOCD User's Guide
  8. @end direntry
  9. @paragraphindent 0
  10. @c %**end of header
  11. @include version.texi
  12. @copying
  13. This User's Guide documents
  14. release @value{VERSION},
  15. dated @value{UPDATED},
  16. of the Open On-Chip Debugger (OpenOCD).
  17. @itemize @bullet
  18. @item Copyright @copyright{} 2008 The OpenOCD Project
  19. @item Copyright @copyright{} 2007-2008 Spencer Oliver @email{spen@@spen-soft.co.uk}
  20. @item Copyright @copyright{} 2008 Oyvind Harboe @email{oyvind.harboe@@zylin.com}
  21. @item Copyright @copyright{} 2008 Duane Ellis @email{openocd@@duaneellis.com}
  22. @item Copyright @copyright{} 2009 David Brownell
  23. @end itemize
  24. @quotation
  25. Permission is granted to copy, distribute and/or modify this document
  26. under the terms of the GNU Free Documentation License, Version 1.2 or
  27. any later version published by the Free Software Foundation; with no
  28. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  29. Texts. A copy of the license is included in the section entitled ``GNU
  30. Free Documentation License''.
  31. @end quotation
  32. @end copying
  33. @titlepage
  34. @titlefont{@emph{Open On-Chip Debugger:}}
  35. @sp 1
  36. @title OpenOCD User's Guide
  37. @subtitle for release @value{VERSION}
  38. @subtitle @value{UPDATED}
  39. @page
  40. @vskip 0pt plus 1filll
  41. @insertcopying
  42. @end titlepage
  43. @summarycontents
  44. @contents
  45. @ifnottex
  46. @node Top
  47. @top OpenOCD User's Guide
  48. @insertcopying
  49. @end ifnottex
  50. @menu
  51. * About:: About OpenOCD
  52. * Developers:: OpenOCD Developers
  53. * JTAG Hardware Dongles:: JTAG Hardware Dongles
  54. * About JIM-Tcl:: About JIM-Tcl
  55. * Running:: Running OpenOCD
  56. * OpenOCD Project Setup:: OpenOCD Project Setup
  57. * Config File Guidelines:: Config File Guidelines
  58. * Daemon Configuration:: Daemon Configuration
  59. * Interface - Dongle Configuration:: Interface - Dongle Configuration
  60. * Reset Configuration:: Reset Configuration
  61. * TAP Declaration:: TAP Declaration
  62. * CPU Configuration:: CPU Configuration
  63. * Flash Commands:: Flash Commands
  64. * NAND Flash Commands:: NAND Flash Commands
  65. * PLD/FPGA Commands:: PLD/FPGA Commands
  66. * General Commands:: General Commands
  67. * Architecture and Core Commands:: Architecture and Core Commands
  68. * JTAG Commands:: JTAG Commands
  69. * Boundary Scan Commands:: Boundary Scan Commands
  70. * TFTP:: TFTP
  71. * GDB and OpenOCD:: Using GDB and OpenOCD
  72. * Tcl Scripting API:: Tcl Scripting API
  73. * FAQ:: Frequently Asked Questions
  74. * Tcl Crash Course:: Tcl Crash Course
  75. * License:: GNU Free Documentation License
  76. @comment DO NOT use the plain word ``Index'', reason: CYGWIN filename
  77. @comment case issue with ``Index.html'' and ``index.html''
  78. @comment Occurs when creating ``--html --no-split'' output
  79. @comment This fix is based on: http://sourceware.org/ml/binutils/2006-05/msg00215.html
  80. * OpenOCD Concept Index:: Concept Index
  81. * Command and Driver Index:: Command and Driver Index
  82. @end menu
  83. @node About
  84. @unnumbered About
  85. @cindex about
  86. OpenOCD was created by Dominic Rath as part of a diploma thesis written at the
  87. University of Applied Sciences Augsburg (@uref{http://www.fh-augsburg.de}).
  88. Since that time, the project has grown into an active open-source project,
  89. supported by a diverse community of software and hardware developers from
  90. around the world.
  91. @section What is OpenOCD?
  92. @cindex TAP
  93. @cindex JTAG
  94. The Open On-Chip Debugger (OpenOCD) aims to provide debugging,
  95. in-system programming and boundary-scan testing for embedded target
  96. devices.
  97. @b{JTAG:} OpenOCD uses a ``hardware interface dongle'' to communicate
  98. with the JTAG (IEEE 1149.1) compliant TAPs on your target board.
  99. A @dfn{TAP} is a ``Test Access Port'', a module which processes
  100. special instructions and data. TAPs are daisy-chained within and
  101. between chips and boards.
  102. @b{Dongles:} OpenOCD currently supports many types of hardware dongles: USB
  103. based, parallel port based, and other standalone boxes that run
  104. OpenOCD internally. @xref{JTAG Hardware Dongles}.
  105. @b{GDB Debug:} It allows ARM7 (ARM7TDMI and ARM720t), ARM9 (ARM920T,
  106. ARM922T, ARM926EJ--S, ARM966E--S), XScale (PXA25x, IXP42x) and
  107. Cortex-M3 (Stellaris LM3 and ST STM32) based cores to be
  108. debugged via the GDB protocol.
  109. @b{Flash Programing:} Flash writing is supported for external CFI
  110. compatible NOR flashes (Intel and AMD/Spansion command set) and several
  111. internal flashes (LPC1700, LPC2000, AT91SAM7, AT91SAM3U, STR7x, STR9x, LM3, and
  112. STM32x). Preliminary support for various NAND flash controllers
  113. (LPC3180, Orion, S3C24xx, more) controller is included.
  114. @section OpenOCD Web Site
  115. The OpenOCD web site provides the latest public news from the community:
  116. @uref{http://openocd.berlios.de/web/}
  117. @section Latest User's Guide:
  118. The user's guide you are now reading may not be the latest one
  119. available. A version for more recent code may be available.
  120. Its HTML form is published irregularly at:
  121. @uref{http://openocd.berlios.de/doc/html/index.html}
  122. PDF form is likewise published at:
  123. @uref{http://openocd.berlios.de/doc/pdf/openocd.pdf}
  124. @section OpenOCD User's Forum
  125. There is an OpenOCD forum (phpBB) hosted by SparkFun,
  126. which might be helpful to you. Note that if you want
  127. anything to come to the attention of developers, you
  128. should post it to the OpenOCD Developer Mailing List
  129. instead of this forum.
  130. @uref{http://forum.sparkfun.com/viewforum.php?f=18}
  131. @node Developers
  132. @chapter OpenOCD Developer Resources
  133. @cindex developers
  134. If you are interested in improving the state of OpenOCD's debugging and
  135. testing support, new contributions will be welcome. Motivated developers
  136. can produce new target, flash or interface drivers, improve the
  137. documentation, as well as more conventional bug fixes and enhancements.
  138. The resources in this chapter are available for developers wishing to explore
  139. or expand the OpenOCD source code.
  140. @section OpenOCD GIT Repository
  141. During the 0.3.x release cycle, OpenOCD switched from Subversion to
  142. a GIT repository hosted at SourceForge. The repository URL is:
  143. @uref{git://openocd.git.sourceforge.net/gitroot/openocd/openocd}
  144. You may prefer to use a mirror and the HTTP protocol:
  145. @uref{http://repo.or.cz/r/openocd.git}
  146. With standard GIT tools, use @command{git clone} to initialize
  147. a local repository, and @command{git pull} to update it.
  148. There are also gitweb pages letting you browse the repository
  149. with a web browser, or download arbitrary snapshots without
  150. needing a GIT client:
  151. @uref{http://openocd.git.sourceforge.net/git/gitweb.cgi?p=openocd/openocd}
  152. @uref{http://repo.or.cz/w/openocd.git}
  153. The @file{README} file contains the instructions for building the project
  154. from the repository or a snapshot.
  155. Developers that want to contribute patches to the OpenOCD system are
  156. @b{strongly} encouraged to work against mainline.
  157. Patches created against older versions may require additional
  158. work from their submitter in order to be updated for newer releases.
  159. @section Doxygen Developer Manual
  160. During the 0.2.x release cycle, the OpenOCD project began
  161. providing a Doxygen reference manual. This document contains more
  162. technical information about the software internals, development
  163. processes, and similar documentation:
  164. @uref{http://openocd.berlios.de/doc/doxygen/index.html}
  165. This document is a work-in-progress, but contributions would be welcome
  166. to fill in the gaps. All of the source files are provided in-tree,
  167. listed in the Doxyfile configuration in the top of the source tree.
  168. @section OpenOCD Developer Mailing List
  169. The OpenOCD Developer Mailing List provides the primary means of
  170. communication between developers:
  171. @uref{https://lists.berlios.de/mailman/listinfo/openocd-development}
  172. Discuss and submit patches to this list.
  173. The @file{PATCHES.txt} file contains basic information about how
  174. to prepare patches.
  175. @node JTAG Hardware Dongles
  176. @chapter JTAG Hardware Dongles
  177. @cindex dongles
  178. @cindex FTDI
  179. @cindex wiggler
  180. @cindex zy1000
  181. @cindex printer port
  182. @cindex USB Adapter
  183. @cindex RTCK
  184. Defined: @b{dongle}: A small device that plugins into a computer and serves as
  185. an adapter .... [snip]
  186. In the OpenOCD case, this generally refers to @b{a small adapater} one
  187. attaches to your computer via USB or the Parallel Printer Port. The
  188. execption being the Zylin ZY1000 which is a small box you attach via
  189. an ethernet cable. The Zylin ZY1000 has the advantage that it does not
  190. require any drivers to be installed on the developer PC. It also has
  191. a built in web interface. It supports RTCK/RCLK or adaptive clocking
  192. and has a built in relay to power cycle targets remotely.
  193. @section Choosing a Dongle
  194. There are several things you should keep in mind when choosing a dongle.
  195. @enumerate
  196. @item @b{Voltage} What voltage is your target - 1.8, 2.8, 3.3, or 5V?
  197. Does your dongle support it? You might need a level converter.
  198. @item @b{Pinout} What pinout does your target board use?
  199. Does your dongle support it? You may be able to use jumper
  200. wires, or an "octopus" connector, to convert pinouts.
  201. @item @b{Connection} Does your computer have the USB, printer, or
  202. Ethernet port needed?
  203. @item @b{RTCK} Do you require RTCK? Also known as ``adaptive clocking''
  204. @end enumerate
  205. @section Stand alone Systems
  206. @b{ZY1000} See: @url{http://www.zylin.com/zy1000.html} Technically, not a
  207. dongle, but a standalone box. The ZY1000 has the advantage that it does
  208. not require any drivers installed on the developer PC. It also has
  209. a built in web interface. It supports RTCK/RCLK or adaptive clocking
  210. and has a built in relay to power cycle targets remotely.
  211. @section USB FT2232 Based
  212. There are many USB JTAG dongles on the market, many of them are based
  213. on a chip from ``Future Technology Devices International'' (FTDI)
  214. known as the FTDI FT2232; this is a USB full speed (12 Mbps) chip.
  215. See: @url{http://www.ftdichip.com} for more information.
  216. In summer 2009, USB high speed (480 Mbps) versions of these FTDI
  217. chips are starting to become available in JTAG adapters.
  218. @itemize @bullet
  219. @item @b{usbjtag}
  220. @* Link @url{http://www.hs-augsburg.de/~hhoegl/proj/usbjtag/usbjtag.html}
  221. @item @b{jtagkey}
  222. @* See: @url{http://www.amontec.com/jtagkey.shtml}
  223. @item @b{jtagkey2}
  224. @* See: @url{http://www.amontec.com/jtagkey2.shtml}
  225. @item @b{oocdlink}
  226. @* See: @url{http://www.oocdlink.com} By Joern Kaipf
  227. @item @b{signalyzer}
  228. @* See: @url{http://www.signalyzer.com}
  229. @item @b{Stellaris Eval Boards}
  230. @* See: @url{http://www.luminarymicro.com} - The Stellaris eval boards
  231. bundle FT2232-based JTAG and SWD support, which can be used to debug
  232. the Stellaris chips. Using separate JTAG adapters is optional.
  233. These boards can also be used as JTAG adapters to other target boards,
  234. disabling the Stellaris chip.
  235. @item @b{Luminary ICDI}
  236. @* See: @url{http://www.luminarymicro.com} - Luminary In-Circuit Debug
  237. Interface (ICDI) Boards are included in Stellaris LM3S9B90 and LM3S9B92
  238. Evaluation Kits. Like the non-detachable FT2232 support on the other
  239. Stellaris eval boards, they can be used to debug other target boards.
  240. @item @b{olimex-jtag}
  241. @* See: @url{http://www.olimex.com}
  242. @item @b{flyswatter}
  243. @* See: @url{http://www.tincantools.com}
  244. @item @b{turtelizer2}
  245. @* See:
  246. @uref{http://www.ethernut.de/en/hardware/turtelizer/index.html, Turtelizer 2}, or
  247. @url{http://www.ethernut.de}
  248. @item @b{comstick}
  249. @* Link: @url{http://www.hitex.com/index.php?id=383}
  250. @item @b{stm32stick}
  251. @* Link @url{http://www.hitex.com/stm32-stick}
  252. @item @b{axm0432_jtag}
  253. @* Axiom AXM-0432 Link @url{http://www.axman.com}
  254. @item @b{cortino}
  255. @* Link @url{http://www.hitex.com/index.php?id=cortino}
  256. @end itemize
  257. @section USB-JTAG / Altera USB-Blaster compatibles
  258. These devices also show up as FTDI devices, but are not
  259. protocol-compatible with the FT2232 devices. They are, however,
  260. protocol-compatible among themselves. USB-JTAG devices typically consist
  261. of a FT245 followed by a CPLD that understands a particular protocol,
  262. or emulate this protocol using some other hardware.
  263. They may appear under different USB VID/PID depending on the particular
  264. product. The driver can be configured to search for any VID/PID pair
  265. (see the section on driver commands).
  266. @itemize
  267. @item @b{USB-JTAG} Kolja Waschk's USB Blaster-compatible adapter
  268. @* Link: @url{http://www.ixo.de/info/usb_jtag/}
  269. @item @b{Altera USB-Blaster}
  270. @* Link: @url{http://www.altera.com/literature/ug/ug_usb_blstr.pdf}
  271. @end itemize
  272. @section USB JLINK based
  273. There are several OEM versions of the Segger @b{JLINK} adapter. It is
  274. an example of a micro controller based JTAG adapter, it uses an
  275. AT91SAM764 internally.
  276. @itemize @bullet
  277. @item @b{ATMEL SAMICE} Only works with ATMEL chips!
  278. @* Link: @url{http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3892}
  279. @item @b{SEGGER JLINK}
  280. @* Link: @url{http://www.segger.com/jlink.html}
  281. @item @b{IAR J-Link}
  282. @* Link: @url{http://www.iar.com/website1/1.0.1.0/369/1/index.php}
  283. @end itemize
  284. @section USB RLINK based
  285. 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.
  286. @itemize @bullet
  287. @item @b{Raisonance RLink}
  288. @* Link: @url{http://www.raisonance.com/products/RLink.php}
  289. @item @b{STM32 Primer}
  290. @* Link: @url{http://www.stm32circle.com/resources/stm32primer.php}
  291. @item @b{STM32 Primer2}
  292. @* Link: @url{http://www.stm32circle.com/resources/stm32primer2.php}
  293. @end itemize
  294. @section USB Other
  295. @itemize @bullet
  296. @item @b{USBprog}
  297. @* Link: @url{http://www.embedded-projects.net/usbprog} - which uses an Atmel MEGA32 and a UBN9604
  298. @item @b{USB - Presto}
  299. @* Link: @url{http://tools.asix.net/prg_presto.htm}
  300. @item @b{Versaloon-Link}
  301. @* Link: @url{http://www.simonqian.com/en/Versaloon}
  302. @item @b{ARM-JTAG-EW}
  303. @* Link: @url{http://www.olimex.com/dev/arm-jtag-ew.html}
  304. @end itemize
  305. @section IBM PC Parallel Printer Port Based
  306. The two well known ``JTAG Parallel Ports'' cables are the Xilnx DLC5
  307. and the MacGraigor Wiggler. There are many clones and variations of
  308. these on the market.
  309. Note that parallel ports are becoming much less common, so if you
  310. have the choice you should probably avoid these adapters in favor
  311. of USB-based ones.
  312. @itemize @bullet
  313. @item @b{Wiggler} - There are many clones of this.
  314. @* Link: @url{http://www.macraigor.com/wiggler.htm}
  315. @item @b{DLC5} - From XILINX - There are many clones of this
  316. @* Link: Search the web for: ``XILINX DLC5'' - it is no longer
  317. produced, PDF schematics are easily found and it is easy to make.
  318. @item @b{Amontec - JTAG Accelerator}
  319. @* Link: @url{http://www.amontec.com/jtag_accelerator.shtml}
  320. @item @b{GW16402}
  321. @* Link: @url{http://www.gateworks.com/products/avila_accessories/gw16042.php}
  322. @item @b{Wiggler2}
  323. @*@uref{http://www.ccac.rwth-aachen.de/@/~michaels/@/index.php/hardware/@/armjtag,
  324. Improved parallel-port wiggler-style JTAG adapter}
  325. @item @b{Wiggler_ntrst_inverted}
  326. @* Yet another variation - See the source code, src/jtag/parport.c
  327. @item @b{old_amt_wiggler}
  328. @* Unknown - probably not on the market today
  329. @item @b{arm-jtag}
  330. @* Link: Most likely @url{http://www.olimex.com/dev/arm-jtag.html} [another wiggler clone]
  331. @item @b{chameleon}
  332. @* Link: @url{http://www.amontec.com/chameleon.shtml}
  333. @item @b{Triton}
  334. @* Unknown.
  335. @item @b{Lattice}
  336. @* ispDownload from Lattice Semiconductor
  337. @url{http://www.latticesemi.com/lit/docs/@/devtools/dlcable.pdf}
  338. @item @b{flashlink}
  339. @* From ST Microsystems;
  340. @uref{http://www.st.com/stonline/@/products/literature/um/7889.pdf,
  341. FlashLINK JTAG programing cable for PSD and uPSD}
  342. @end itemize
  343. @section Other...
  344. @itemize @bullet
  345. @item @b{ep93xx}
  346. @* An EP93xx based Linux machine using the GPIO pins directly.
  347. @item @b{at91rm9200}
  348. @* Like the EP93xx - but an ATMEL AT91RM9200 based solution using the GPIO pins on the chip.
  349. @end itemize
  350. @node About JIM-Tcl
  351. @chapter About JIM-Tcl
  352. @cindex JIM Tcl
  353. @cindex tcl
  354. OpenOCD includes a small ``Tcl Interpreter'' known as JIM-Tcl.
  355. This programming language provides a simple and extensible
  356. command interpreter.
  357. All commands presented in this Guide are extensions to JIM-Tcl.
  358. You can use them as simple commands, without needing to learn
  359. much of anything about Tcl.
  360. Alternatively, can write Tcl programs with them.
  361. You can learn more about JIM at its website, @url{http://jim.berlios.de}.
  362. @itemize @bullet
  363. @item @b{JIM vs. Tcl}
  364. @* JIM-TCL is a stripped down version of the well known Tcl language,
  365. which can be found here: @url{http://www.tcl.tk}. JIM-Tcl has far
  366. fewer features. JIM-Tcl is a single .C file and a single .H file and
  367. implements the basic Tcl command set. In contrast: Tcl 8.6 is a
  368. 4.2 MB .zip file containing 1540 files.
  369. @item @b{Missing Features}
  370. @* Our practice has been: Add/clone the real Tcl feature if/when
  371. needed. We welcome JIM Tcl improvements, not bloat.
  372. @item @b{Scripts}
  373. @* OpenOCD configuration scripts are JIM Tcl Scripts. OpenOCD's
  374. command interpreter today is a mixture of (newer)
  375. JIM-Tcl commands, and (older) the orginal command interpreter.
  376. @item @b{Commands}
  377. @* At the OpenOCD telnet command line (or via the GDB mon command) one
  378. can type a Tcl for() loop, set variables, etc.
  379. Some of the commands documented in this guide are implemented
  380. as Tcl scripts, from a @file{startup.tcl} file internal to the server.
  381. @item @b{Historical Note}
  382. @* JIM-Tcl was introduced to OpenOCD in spring 2008.
  383. @item @b{Need a crash course in Tcl?}
  384. @*@xref{Tcl Crash Course}.
  385. @end itemize
  386. @node Running
  387. @chapter Running
  388. @cindex command line options
  389. @cindex logfile
  390. @cindex directory search
  391. The @option{--help} option shows:
  392. @verbatim
  393. bash$ openocd --help
  394. --help | -h display this help
  395. --version | -v display OpenOCD version
  396. --file | -f use configuration file <name>
  397. --search | -s dir to search for config files and scripts
  398. --debug | -d set debug level <0-3>
  399. --log_output | -l redirect log output to file <name>
  400. --command | -c run <command>
  401. --pipe | -p use pipes when talking to gdb
  402. @end verbatim
  403. By default OpenOCD reads the configuration file @file{openocd.cfg}.
  404. To specify a different (or multiple)
  405. configuration file, you can use the @option{-f} option. For example:
  406. @example
  407. openocd -f config1.cfg -f config2.cfg -f config3.cfg
  408. @end example
  409. Configuration files and scripts are searched for in
  410. @enumerate
  411. @item the current directory,
  412. @item any search dir specified on the command line using the @option{-s} option,
  413. @item @file{$HOME/.openocd} (not on Windows),
  414. @item the site wide script library @file{$pkgdatadir/site} and
  415. @item the OpenOCD-supplied script library @file{$pkgdatadir/scripts}.
  416. @end enumerate
  417. The first found file with a matching file name will be used.
  418. @section Simple setup, no customization
  419. In the best case, you can use two scripts from one of the script
  420. libraries, hook up your JTAG adapter, and start the server ... and
  421. your JTAG setup will just work "out of the box". Always try to
  422. start by reusing those scripts, but assume you'll need more
  423. customization even if this works. @xref{OpenOCD Project Setup}.
  424. If you find a script for your JTAG adapter, and for your board or
  425. target, you may be able to hook up your JTAG adapter then start
  426. the server like:
  427. @example
  428. openocd -f interface/ADAPTER.cfg -f board/MYBOARD.cfg
  429. @end example
  430. You might also need to configure which reset signals are present,
  431. using @option{-c 'reset_config trst_and_srst'} or something similar.
  432. If all goes well you'll see output something like
  433. @example
  434. Open On-Chip Debugger 0.4.0 (2010-01-14-15:06)
  435. For bug reports, read
  436. http://openocd.berlios.de/doc/doxygen/bugs.html
  437. Info : JTAG tap: lm3s.cpu tap/device found: 0x3ba00477
  438. (mfg: 0x23b, part: 0xba00, ver: 0x3)
  439. @end example
  440. Seeing that "tap/device found" message, and no warnings, means
  441. the JTAG communication is working. That's a key milestone, but
  442. you'll probably need more project-specific setup.
  443. @section What OpenOCD does as it starts
  444. OpenOCD starts by processing the configuration commands provided
  445. on the command line or, if there were no @option{-c command} or
  446. @option{-f file.cfg} options given, in @file{openocd.cfg}.
  447. @xref{Configuration Stage}.
  448. At the end of the configuration stage it verifies the JTAG scan
  449. chain defined using those commands; your configuration should
  450. ensure that this always succeeds.
  451. Normally, OpenOCD then starts running as a daemon.
  452. Alternatively, commands may be used to terminate the configuration
  453. stage early, perform work (such as updating some flash memory),
  454. and then shut down without acting as a daemon.
  455. Once OpenOCD starts running as a daemon, it waits for connections from
  456. clients (Telnet, GDB, Other) and processes the commands issued through
  457. those channels.
  458. If you are having problems, you can enable internal debug messages via
  459. the @option{-d} option.
  460. Also it is possible to interleave JIM-Tcl commands w/config scripts using the
  461. @option{-c} command line switch.
  462. To enable debug output (when reporting problems or working on OpenOCD
  463. itself), use the @option{-d} command line switch. This sets the
  464. @option{debug_level} to "3", outputting the most information,
  465. including debug messages. The default setting is "2", outputting only
  466. informational messages, warnings and errors. You can also change this
  467. setting from within a telnet or gdb session using @command{debug_level
  468. <n>} (@pxref{debug_level}).
  469. You can redirect all output from the daemon to a file using the
  470. @option{-l <logfile>} switch.
  471. For details on the @option{-p} option. @xref{Connecting to GDB}.
  472. Note! OpenOCD will launch the GDB & telnet server even if it can not
  473. establish a connection with the target. In general, it is possible for
  474. the JTAG controller to be unresponsive until the target is set up
  475. correctly via e.g. GDB monitor commands in a GDB init script.
  476. @node OpenOCD Project Setup
  477. @chapter OpenOCD Project Setup
  478. To use OpenOCD with your development projects, you need to do more than
  479. just connecting the JTAG adapter hardware (dongle) to your development board
  480. and then starting the OpenOCD server.
  481. You also need to configure that server so that it knows
  482. about that adapter and board, and helps your work.
  483. You may also want to connect OpenOCD to GDB, possibly
  484. using Eclipse or some other GUI.
  485. @section Hooking up the JTAG Adapter
  486. Today's most common case is a dongle with a JTAG cable on one side
  487. (such as a ribbon cable with a 10-pin or 20-pin IDC connector)
  488. and a USB cable on the other.
  489. Instead of USB, some cables use Ethernet;
  490. older ones may use a PC parallel port, or even a serial port.
  491. @enumerate
  492. @item @emph{Start with power to your target board turned off},
  493. and nothing connected to your JTAG adapter.
  494. If you're particularly paranoid, unplug power to the board.
  495. It's important to have the ground signal properly set up,
  496. unless you are using a JTAG adapter which provides
  497. galvanic isolation between the target board and the
  498. debugging host.
  499. @item @emph{Be sure it's the right kind of JTAG connector.}
  500. If your dongle has a 20-pin ARM connector, you need some kind
  501. of adapter (or octopus, see below) to hook it up to
  502. boards using 14-pin or 10-pin connectors ... or to 20-pin
  503. connectors which don't use ARM's pinout.
  504. In the same vein, make sure the voltage levels are compatible.
  505. Not all JTAG adapters have the level shifters needed to work
  506. with 1.2 Volt boards.
  507. @item @emph{Be certain the cable is properly oriented} or you might
  508. damage your board. In most cases there are only two possible
  509. ways to connect the cable.
  510. Connect the JTAG cable from your adapter to the board.
  511. Be sure it's firmly connected.
  512. In the best case, the connector is keyed to physically
  513. prevent you from inserting it wrong.
  514. This is most often done using a slot on the board's male connector
  515. housing, which must match a key on the JTAG cable's female connector.
  516. If there's no housing, then you must look carefully and
  517. make sure pin 1 on the cable hooks up to pin 1 on the board.
  518. Ribbon cables are frequently all grey except for a wire on one
  519. edge, which is red. The red wire is pin 1.
  520. Sometimes dongles provide cables where one end is an ``octopus'' of
  521. color coded single-wire connectors, instead of a connector block.
  522. These are great when converting from one JTAG pinout to another,
  523. but are tedious to set up.
  524. Use these with connector pinout diagrams to help you match up the
  525. adapter signals to the right board pins.
  526. @item @emph{Connect the adapter's other end} once the JTAG cable is connected.
  527. A USB, parallel, or serial port connector will go to the host which
  528. you are using to run OpenOCD.
  529. For Ethernet, consult the documentation and your network administrator.
  530. For USB based JTAG adapters you have an easy sanity check at this point:
  531. does the host operating system see the JTAG adapter? If that host is an
  532. MS-Windows host, you'll need to install a driver before OpenOCD works.
  533. @item @emph{Connect the adapter's power supply, if needed.}
  534. This step is primarily for non-USB adapters,
  535. but sometimes USB adapters need extra power.
  536. @item @emph{Power up the target board.}
  537. Unless you just let the magic smoke escape,
  538. you're now ready to set up the OpenOCD server
  539. so you can use JTAG to work with that board.
  540. @end enumerate
  541. Talk with the OpenOCD server using
  542. telnet (@code{telnet localhost 4444} on many systems) or GDB.
  543. @xref{GDB and OpenOCD}.
  544. @section Project Directory
  545. There are many ways you can configure OpenOCD and start it up.
  546. A simple way to organize them all involves keeping a
  547. single directory for your work with a given board.
  548. When you start OpenOCD from that directory,
  549. it searches there first for configuration files, scripts,
  550. files accessed through semihosting,
  551. and for code you upload to the target board.
  552. It is also the natural place to write files,
  553. such as log files and data you download from the board.
  554. @section Configuration Basics
  555. There are two basic ways of configuring OpenOCD, and
  556. a variety of ways you can mix them.
  557. Think of the difference as just being how you start the server:
  558. @itemize
  559. @item Many @option{-f file} or @option{-c command} options on the command line
  560. @item No options, but a @dfn{user config file}
  561. in the current directory named @file{openocd.cfg}
  562. @end itemize
  563. Here is an example @file{openocd.cfg} file for a setup
  564. using a Signalyzer FT2232-based JTAG adapter to talk to
  565. a board with an Atmel AT91SAM7X256 microcontroller:
  566. @example
  567. source [find interface/signalyzer.cfg]
  568. # GDB can also flash my flash!
  569. gdb_memory_map enable
  570. gdb_flash_program enable
  571. source [find target/sam7x256.cfg]
  572. @end example
  573. Here is the command line equivalent of that configuration:
  574. @example
  575. openocd -f interface/signalyzer.cfg \
  576. -c "gdb_memory_map enable" \
  577. -c "gdb_flash_program enable" \
  578. -f target/sam7x256.cfg
  579. @end example
  580. You could wrap such long command lines in shell scripts,
  581. each supporting a different development task.
  582. One might re-flash the board with a specific firmware version.
  583. Another might set up a particular debugging or run-time environment.
  584. @quotation Important
  585. At this writing (October 2009) the command line method has
  586. problems with how it treats variables.
  587. For example, after @option{-c "set VAR value"}, or doing the
  588. same in a script, the variable @var{VAR} will have no value
  589. that can be tested in a later script.
  590. @end quotation
  591. Here we will focus on the simpler solution: one user config
  592. file, including basic configuration plus any TCL procedures
  593. to simplify your work.
  594. @section User Config Files
  595. @cindex config file, user
  596. @cindex user config file
  597. @cindex config file, overview
  598. A user configuration file ties together all the parts of a project
  599. in one place.
  600. One of the following will match your situation best:
  601. @itemize
  602. @item Ideally almost everything comes from configuration files
  603. provided by someone else.
  604. For example, OpenOCD distributes a @file{scripts} directory
  605. (probably in @file{/usr/share/openocd/scripts} on Linux).
  606. Board and tool vendors can provide these too, as can individual
  607. user sites; the @option{-s} command line option lets you say
  608. where to find these files. (@xref{Running}.)
  609. The AT91SAM7X256 example above works this way.
  610. Three main types of non-user configuration file each have their
  611. own subdirectory in the @file{scripts} directory:
  612. @enumerate
  613. @item @b{interface} -- one for each kind of JTAG adapter/dongle
  614. @item @b{board} -- one for each different board
  615. @item @b{target} -- the chips which integrate CPUs and other JTAG TAPs
  616. @end enumerate
  617. Best case: include just two files, and they handle everything else.
  618. The first is an interface config file.
  619. The second is board-specific, and it sets up the JTAG TAPs and
  620. their GDB targets (by deferring to some @file{target.cfg} file),
  621. declares all flash memory, and leaves you nothing to do except
  622. meet your deadline:
  623. @example
  624. source [find interface/olimex-jtag-tiny.cfg]
  625. source [find board/csb337.cfg]
  626. @end example
  627. Boards with a single microcontroller often won't need more
  628. than the target config file, as in the AT91SAM7X256 example.
  629. That's because there is no external memory (flash, DDR RAM), and
  630. the board differences are encapsulated by application code.
  631. @item Maybe you don't know yet what your board looks like to JTAG.
  632. Once you know the @file{interface.cfg} file to use, you may
  633. need help from OpenOCD to discover what's on the board.
  634. Once you find the TAPs, you can just search for appropriate
  635. configuration files ... or write your own, from the bottom up.
  636. @xref{Autoprobing}.
  637. @item You can often reuse some standard config files but
  638. need to write a few new ones, probably a @file{board.cfg} file.
  639. You will be using commands described later in this User's Guide,
  640. and working with the guidelines in the next chapter.
  641. For example, there may be configuration files for your JTAG adapter
  642. and target chip, but you need a new board-specific config file
  643. giving access to your particular flash chips.
  644. Or you might need to write another target chip configuration file
  645. for a new chip built around the Cortex M3 core.
  646. @quotation Note
  647. When you write new configuration files, please submit
  648. them for inclusion in the next OpenOCD release.
  649. For example, a @file{board/newboard.cfg} file will help the
  650. next users of that board, and a @file{target/newcpu.cfg}
  651. will help support users of any board using that chip.
  652. @end quotation
  653. @item
  654. You may may need to write some C code.
  655. It may be as simple as a supporting a new ft2232 or parport
  656. based dongle; a bit more involved, like a NAND or NOR flash
  657. controller driver; or a big piece of work like supporting
  658. a new chip architecture.
  659. @end itemize
  660. Reuse the existing config files when you can.
  661. Look first in the @file{scripts/boards} area, then @file{scripts/targets}.
  662. You may find a board configuration that's a good example to follow.
  663. When you write config files, separate the reusable parts
  664. (things every user of that interface, chip, or board needs)
  665. from ones specific to your environment and debugging approach.
  666. @itemize
  667. @item
  668. For example, a @code{gdb-attach} event handler that invokes
  669. the @command{reset init} command will interfere with debugging
  670. early boot code, which performs some of the same actions
  671. that the @code{reset-init} event handler does.
  672. @item
  673. Likewise, the @command{arm9 vector_catch} command (or
  674. @cindex vector_catch
  675. its siblings @command{xscale vector_catch}
  676. and @command{cortex_m3 vector_catch}) can be a timesaver
  677. during some debug sessions, but don't make everyone use that either.
  678. Keep those kinds of debugging aids in your user config file,
  679. along with messaging and tracing setup.
  680. (@xref{Software Debug Messages and Tracing}.)
  681. @item
  682. You might need to override some defaults.
  683. For example, you might need to move, shrink, or back up the target's
  684. work area if your application needs much SRAM.
  685. @item
  686. TCP/IP port configuration is another example of something which
  687. is environment-specific, and should only appear in
  688. a user config file. @xref{TCP/IP Ports}.
  689. @end itemize
  690. @section Project-Specific Utilities
  691. A few project-specific utility
  692. routines may well speed up your work.
  693. Write them, and keep them in your project's user config file.
  694. For example, if you are making a boot loader work on a
  695. board, it's nice to be able to debug the ``after it's
  696. loaded to RAM'' parts separately from the finicky early
  697. code which sets up the DDR RAM controller and clocks.
  698. A script like this one, or a more GDB-aware sibling,
  699. may help:
  700. @example
  701. proc ramboot @{ @} @{
  702. # Reset, running the target's "reset-init" scripts
  703. # to initialize clocks and the DDR RAM controller.
  704. # Leave the CPU halted.
  705. reset init
  706. # Load CONFIG_SKIP_LOWLEVEL_INIT version into DDR RAM.
  707. load_image u-boot.bin 0x20000000
  708. # Start running.
  709. resume 0x20000000
  710. @}
  711. @end example
  712. Then once that code is working you will need to make it
  713. boot from NOR flash; a different utility would help.
  714. Alternatively, some developers write to flash using GDB.
  715. (You might use a similar script if you're working with a flash
  716. based microcontroller application instead of a boot loader.)
  717. @example
  718. proc newboot @{ @} @{
  719. # Reset, leaving the CPU halted. The "reset-init" event
  720. # proc gives faster access to the CPU and to NOR flash;
  721. # "reset halt" would be slower.
  722. reset init
  723. # Write standard version of U-Boot into the first two
  724. # sectors of NOR flash ... the standard version should
  725. # do the same lowlevel init as "reset-init".
  726. flash protect 0 0 1 off
  727. flash erase_sector 0 0 1
  728. flash write_bank 0 u-boot.bin 0x0
  729. flash protect 0 0 1 on
  730. # Reboot from scratch using that new boot loader.
  731. reset run
  732. @}
  733. @end example
  734. You may need more complicated utility procedures when booting
  735. from NAND.
  736. That often involves an extra bootloader stage,
  737. running from on-chip SRAM to perform DDR RAM setup so it can load
  738. the main bootloader code (which won't fit into that SRAM).
  739. Other helper scripts might be used to write production system images,
  740. involving considerably more than just a three stage bootloader.
  741. @section Target Software Changes
  742. Sometimes you may want to make some small changes to the software
  743. you're developing, to help make JTAG debugging work better.
  744. For example, in C or assembly language code you might
  745. use @code{#ifdef JTAG_DEBUG} (or its converse) around code
  746. handling issues like:
  747. @itemize @bullet
  748. @item @b{Watchdog Timers}...
  749. Watchog timers are typically used to automatically reset systems if
  750. some application task doesn't periodically reset the timer. (The
  751. assumption is that the system has locked up if the task can't run.)
  752. When a JTAG debugger halts the system, that task won't be able to run
  753. and reset the timer ... potentially causing resets in the middle of
  754. your debug sessions.
  755. It's rarely a good idea to disable such watchdogs, since their usage
  756. needs to be debugged just like all other parts of your firmware.
  757. That might however be your only option.
  758. Look instead for chip-specific ways to stop the watchdog from counting
  759. while the system is in a debug halt state. It may be simplest to set
  760. that non-counting mode in your debugger startup scripts. You may however
  761. need a different approach when, for example, a motor could be physically
  762. damaged by firmware remaining inactive in a debug halt state. That might
  763. involve a type of firmware mode where that "non-counting" mode is disabled
  764. at the beginning then re-enabled at the end; a watchdog reset might fire
  765. and complicate the debug session, but hardware (or people) would be
  766. protected.@footnote{Note that many systems support a "monitor mode" debug
  767. that is a somewhat cleaner way to address such issues. You can think of
  768. it as only halting part of the system, maybe just one task,
  769. instead of the whole thing.
  770. At this writing, January 2010, OpenOCD based debugging does not support
  771. monitor mode debug, only "halt mode" debug.}
  772. @item @b{ARM Semihosting}...
  773. @cindex ARM semihosting
  774. When linked with a special runtime library provided with many
  775. toolchains@footnote{See chapter 8 "Semihosting" in
  776. @uref{http://infocenter.arm.com/help/topic/com.arm.doc.dui0203i/DUI0203I_rvct_developer_guide.pdf,
  777. ARM DUI 0203I}, the "RealView Compilation Tools Developer Guide".
  778. The CodeSourcery EABI toolchain also includes a semihosting library.},
  779. your target code can use I/O facilities on the debug host. That library
  780. provides a small set of system calls which are handled by OpenOCD.
  781. It can let the debugger provide your system console and a file system,
  782. helping with early debugging or providing a more capable environment
  783. for sometimes-complex tasks like installing system firmware onto
  784. NAND or SPI flash.
  785. @item @b{ARM Wait-For-Interrupt}...
  786. Many ARM chips synchronize the JTAG clock using the core clock.
  787. Low power states which stop that core clock thus prevent JTAG access.
  788. Idle loops in tasking environments often enter those low power states
  789. via the @code{WFI} instruction (or its coprocessor equivalent, before ARMv7).
  790. You may want to @emph{disable that instruction} in source code,
  791. or otherwise prevent using that state,
  792. to ensure you can get JTAG access at any time.@footnote{As a more
  793. polite alternative, some processors have special debug-oriented
  794. registers which can be used to change various features including
  795. how the low power states are clocked while debugging.
  796. The STM32 DBGMCU_CR register is an example; at the cost of extra
  797. power consumption, JTAG can be used during low power states.}
  798. For example, the OpenOCD @command{halt} command may not
  799. work for an idle processor otherwise.
  800. @item @b{Delay after reset}...
  801. Not all chips have good support for debugger access
  802. right after reset; many LPC2xxx chips have issues here.
  803. Similarly, applications that reconfigure pins used for
  804. JTAG access as they start will also block debugger access.
  805. To work with boards like this, @emph{enable a short delay loop}
  806. the first thing after reset, before "real" startup activities.
  807. For example, one second's delay is usually more than enough
  808. time for a JTAG debugger to attach, so that
  809. early code execution can be debugged
  810. or firmware can be replaced.
  811. @item @b{Debug Communications Channel (DCC)}...
  812. Some processors include mechanisms to send messages over JTAG.
  813. Many ARM cores support these, as do some cores from other vendors.
  814. (OpenOCD may be able to use this DCC internally, speeding up some
  815. operations like writing to memory.)
  816. Your application may want to deliver various debugging messages
  817. over JTAG, by @emph{linking with a small library of code}
  818. provided with OpenOCD and using the utilities there to send
  819. various kinds of message.
  820. @xref{Software Debug Messages and Tracing}.
  821. @end itemize
  822. @node Config File Guidelines
  823. @chapter Config File Guidelines
  824. This chapter is aimed at any user who needs to write a config file,
  825. including developers and integrators of OpenOCD and any user who
  826. needs to get a new board working smoothly.
  827. It provides guidelines for creating those files.
  828. You should find the following directories under @t{$(INSTALLDIR)/scripts},
  829. with files including the ones listed here.
  830. Use them as-is where you can; or as models for new files.
  831. @itemize @bullet
  832. @item @file{interface} ...
  833. think JTAG Dongle. Files that configure JTAG adapters go here.
  834. @example
  835. $ ls interface
  836. arm-jtag-ew.cfg hitex_str9-comstick.cfg oocdlink.cfg
  837. arm-usb-ocd.cfg icebear.cfg openocd-usb.cfg
  838. at91rm9200.cfg jlink.cfg parport.cfg
  839. axm0432.cfg jtagkey2.cfg parport_dlc5.cfg
  840. calao-usb-a9260-c01.cfg jtagkey.cfg rlink.cfg
  841. calao-usb-a9260-c02.cfg jtagkey-tiny.cfg sheevaplug.cfg
  842. calao-usb-a9260.cfg luminary.cfg signalyzer.cfg
  843. chameleon.cfg luminary-icdi.cfg stm32-stick.cfg
  844. cortino.cfg luminary-lm3s811.cfg turtelizer2.cfg
  845. dummy.cfg olimex-arm-usb-ocd.cfg usbprog.cfg
  846. flyswatter.cfg olimex-jtag-tiny.cfg vsllink.cfg
  847. $
  848. @end example
  849. @item @file{board} ...
  850. think Circuit Board, PWA, PCB, they go by many names. Board files
  851. contain initialization items that are specific to a board.
  852. They reuse target configuration files, since the same
  853. microprocessor chips are used on many boards,
  854. but support for external parts varies widely. For
  855. example, the SDRAM initialization sequence for the board, or the type
  856. of external flash and what address it uses. Any initialization
  857. sequence to enable that external flash or SDRAM should be found in the
  858. board file. Boards may also contain multiple targets: two CPUs; or
  859. a CPU and an FPGA.
  860. @example
  861. $ ls board
  862. arm_evaluator7t.cfg keil_mcb1700.cfg
  863. at91rm9200-dk.cfg keil_mcb2140.cfg
  864. at91sam9g20-ek.cfg linksys_nslu2.cfg
  865. atmel_at91sam7s-ek.cfg logicpd_imx27.cfg
  866. atmel_at91sam9260-ek.cfg mini2440.cfg
  867. atmel_sam3u_ek.cfg olimex_LPC2378STK.cfg
  868. crossbow_tech_imote2.cfg olimex_lpc_h2148.cfg
  869. csb337.cfg olimex_sam7_ex256.cfg
  870. csb732.cfg olimex_sam9_l9260.cfg
  871. digi_connectcore_wi-9c.cfg olimex_stm32_h103.cfg
  872. dm355evm.cfg omap2420_h4.cfg
  873. dm365evm.cfg osk5912.cfg
  874. dm6446evm.cfg pic-p32mx.cfg
  875. eir.cfg propox_mmnet1001.cfg
  876. ek-lm3s1968.cfg pxa255_sst.cfg
  877. ek-lm3s3748.cfg sheevaplug.cfg
  878. ek-lm3s811.cfg stm3210e_eval.cfg
  879. ek-lm3s9b9x.cfg stm32f10x_128k_eval.cfg
  880. hammer.cfg str910-eval.cfg
  881. hitex_lpc2929.cfg telo.cfg
  882. hitex_stm32-performancestick.cfg ti_beagleboard.cfg
  883. hitex_str9-comstick.cfg topas910.cfg
  884. iar_str912_sk.cfg topasa900.cfg
  885. imx27ads.cfg unknown_at91sam9260.cfg
  886. imx27lnst.cfg x300t.cfg
  887. imx31pdk.cfg zy1000.cfg
  888. $
  889. @end example
  890. @item @file{target} ...
  891. think chip. The ``target'' directory represents the JTAG TAPs
  892. on a chip
  893. which OpenOCD should control, not a board. Two common types of targets
  894. are ARM chips and FPGA or CPLD chips.
  895. When a chip has multiple TAPs (maybe it has both ARM and DSP cores),
  896. the target config file defines all of them.
  897. @example
  898. $ ls target
  899. aduc702x.cfg imx27.cfg pxa255.cfg
  900. ar71xx.cfg imx31.cfg pxa270.cfg
  901. at91eb40a.cfg imx35.cfg readme.txt
  902. at91r40008.cfg is5114.cfg sam7se512.cfg
  903. at91rm9200.cfg ixp42x.cfg sam7x256.cfg
  904. at91sam3u1c.cfg lm3s1968.cfg samsung_s3c2410.cfg
  905. at91sam3u1e.cfg lm3s3748.cfg samsung_s3c2440.cfg
  906. at91sam3u2c.cfg lm3s6965.cfg samsung_s3c2450.cfg
  907. at91sam3u2e.cfg lm3s811.cfg samsung_s3c4510.cfg
  908. at91sam3u4c.cfg lm3s9b9x.cfg samsung_s3c6410.cfg
  909. at91sam3u4e.cfg lpc1768.cfg sharp_lh79532.cfg
  910. at91sam3uXX.cfg lpc2103.cfg smdk6410.cfg
  911. at91sam7sx.cfg lpc2124.cfg smp8634.cfg
  912. at91sam9260.cfg lpc2129.cfg stm32.cfg
  913. c100.cfg lpc2148.cfg str710.cfg
  914. c100config.tcl lpc2294.cfg str730.cfg
  915. c100helper.tcl lpc2378.cfg str750.cfg
  916. c100regs.tcl lpc2478.cfg str912.cfg
  917. cs351x.cfg lpc2900.cfg telo.cfg
  918. davinci.cfg mega128.cfg ti_dm355.cfg
  919. dragonite.cfg netx500.cfg ti_dm365.cfg
  920. epc9301.cfg omap2420.cfg ti_dm6446.cfg
  921. feroceon.cfg omap3530.cfg tmpa900.cfg
  922. icepick.cfg omap5912.cfg tmpa910.cfg
  923. imx21.cfg pic32mx.cfg xba_revA3.cfg
  924. $
  925. @end example
  926. @item @emph{more} ... browse for other library files which may be useful.
  927. For example, there are various generic and CPU-specific utilities.
  928. @end itemize
  929. The @file{openocd.cfg} user config
  930. file may override features in any of the above files by
  931. setting variables before sourcing the target file, or by adding
  932. commands specific to their situation.
  933. @section Interface Config Files
  934. The user config file
  935. should be able to source one of these files with a command like this:
  936. @example
  937. source [find interface/FOOBAR.cfg]
  938. @end example
  939. A preconfigured interface file should exist for every interface in use
  940. today, that said, perhaps some interfaces have only been used by the
  941. sole developer who created it.
  942. A separate chapter gives information about how to set these up.
  943. @xref{Interface - Dongle Configuration}.
  944. Read the OpenOCD source code if you have a new kind of hardware interface
  945. and need to provide a driver for it.
  946. @section Board Config Files
  947. @cindex config file, board
  948. @cindex board config file
  949. The user config file
  950. should be able to source one of these files with a command like this:
  951. @example
  952. source [find board/FOOBAR.cfg]
  953. @end example
  954. The point of a board config file is to package everything
  955. about a given board that user config files need to know.
  956. In summary the board files should contain (if present)
  957. @enumerate
  958. @item One or more @command{source [target/...cfg]} statements
  959. @item NOR flash configuration (@pxref{NOR Configuration})
  960. @item NAND flash configuration (@pxref{NAND Configuration})
  961. @item Target @code{reset} handlers for SDRAM and I/O configuration
  962. @item JTAG adapter reset configuration (@pxref{Reset Configuration})
  963. @item All things that are not ``inside a chip''
  964. @end enumerate
  965. Generic things inside target chips belong in target config files,
  966. not board config files. So for example a @code{reset-init} event
  967. handler should know board-specific oscillator and PLL parameters,
  968. which it passes to target-specific utility code.
  969. The most complex task of a board config file is creating such a
  970. @code{reset-init} event handler.
  971. Define those handlers last, after you verify the rest of the board
  972. configuration works.
  973. @subsection Communication Between Config files
  974. In addition to target-specific utility code, another way that
  975. board and target config files communicate is by following a
  976. convention on how to use certain variables.
  977. The full Tcl/Tk language supports ``namespaces'', but JIM-Tcl does not.
  978. Thus the rule we follow in OpenOCD is this: Variables that begin with
  979. a leading underscore are temporary in nature, and can be modified and
  980. used at will within a target configuration file.
  981. Complex board config files can do the things like this,
  982. for a board with three chips:
  983. @example
  984. # Chip #1: PXA270 for network side, big endian
  985. set CHIPNAME network
  986. set ENDIAN big
  987. source [find target/pxa270.cfg]
  988. # on return: _TARGETNAME = network.cpu
  989. # other commands can refer to the "network.cpu" target.
  990. $_TARGETNAME configure .... events for this CPU..
  991. # Chip #2: PXA270 for video side, little endian
  992. set CHIPNAME video
  993. set ENDIAN little
  994. source [find target/pxa270.cfg]
  995. # on return: _TARGETNAME = video.cpu
  996. # other commands can refer to the "video.cpu" target.
  997. $_TARGETNAME configure .... events for this CPU..
  998. # Chip #3: Xilinx FPGA for glue logic
  999. set CHIPNAME xilinx
  1000. unset ENDIAN
  1001. source [find target/spartan3.cfg]
  1002. @end example
  1003. That example is oversimplified because it doesn't show any flash memory,
  1004. or the @code{reset-init} event handlers to initialize external DRAM
  1005. or (assuming it needs it) load a configuration into the FPGA.
  1006. Such features are usually needed for low-level work with many boards,
  1007. where ``low level'' implies that the board initialization software may
  1008. not be working. (That's a common reason to need JTAG tools. Another
  1009. is to enable working with microcontroller-based systems, which often
  1010. have no debugging support except a JTAG connector.)
  1011. Target config files may also export utility functions to board and user
  1012. config files. Such functions should use name prefixes, to help avoid
  1013. naming collisions.
  1014. Board files could also accept input variables from user config files.
  1015. For example, there might be a @code{J4_JUMPER} setting used to identify
  1016. what kind of flash memory a development board is using, or how to set
  1017. up other clocks and peripherals.
  1018. @subsection Variable Naming Convention
  1019. @cindex variable names
  1020. Most boards have only one instance of a chip.
  1021. However, it should be easy to create a board with more than
  1022. one such chip (as shown above).
  1023. Accordingly, we encourage these conventions for naming
  1024. variables associated with different @file{target.cfg} files,
  1025. to promote consistency and
  1026. so that board files can override target defaults.
  1027. Inputs to target config files include:
  1028. @itemize @bullet
  1029. @item @code{CHIPNAME} ...
  1030. This gives a name to the overall chip, and is used as part of
  1031. tap identifier dotted names.
  1032. While the default is normally provided by the chip manufacturer,
  1033. board files may need to distinguish between instances of a chip.
  1034. @item @code{ENDIAN} ...
  1035. By default @option{little} - although chips may hard-wire @option{big}.
  1036. Chips that can't change endianness don't need to use this variable.
  1037. @item @code{CPUTAPID} ...
  1038. When OpenOCD examines the JTAG chain, it can be told verify the
  1039. chips against the JTAG IDCODE register.
  1040. The target file will hold one or more defaults, but sometimes the
  1041. chip in a board will use a different ID (perhaps a newer revision).
  1042. @end itemize
  1043. Outputs from target config files include:
  1044. @itemize @bullet
  1045. @item @code{_TARGETNAME} ...
  1046. By convention, this variable is created by the target configuration
  1047. script. The board configuration file may make use of this variable to
  1048. configure things like a ``reset init'' script, or other things
  1049. specific to that board and that target.
  1050. If the chip has 2 targets, the names are @code{_TARGETNAME0},
  1051. @code{_TARGETNAME1}, ... etc.
  1052. @end itemize
  1053. @subsection The reset-init Event Handler
  1054. @cindex event, reset-init
  1055. @cindex reset-init handler
  1056. Board config files run in the OpenOCD configuration stage;
  1057. they can't use TAPs or targets, since they haven't been
  1058. fully set up yet.
  1059. This means you can't write memory or access chip registers;
  1060. you can't even verify that a flash chip is present.
  1061. That's done later in event handlers, of which the target @code{reset-init}
  1062. handler is one of the most important.
  1063. Except on microcontrollers, the basic job of @code{reset-init} event
  1064. handlers is setting up flash and DRAM, as normally handled by boot loaders.
  1065. Microcontrollers rarely use boot loaders; they run right out of their
  1066. on-chip flash and SRAM memory. But they may want to use one of these
  1067. handlers too, if just for developer convenience.
  1068. @quotation Note
  1069. Because this is so very board-specific, and chip-specific, no examples
  1070. are included here.
  1071. Instead, look at the board config files distributed with OpenOCD.
  1072. If you have a boot loader, its source code will help; so will
  1073. configuration files for other JTAG tools
  1074. (@pxref{Translating Configuration Files}).
  1075. @end quotation
  1076. Some of this code could probably be shared between different boards.
  1077. For example, setting up a DRAM controller often doesn't differ by
  1078. much except the bus width (16 bits or 32?) and memory timings, so a
  1079. reusable TCL procedure loaded by the @file{target.cfg} file might take
  1080. those as parameters.
  1081. Similarly with oscillator, PLL, and clock setup;
  1082. and disabling the watchdog.
  1083. Structure the code cleanly, and provide comments to help
  1084. the next developer doing such work.
  1085. (@emph{You might be that next person} trying to reuse init code!)
  1086. The last thing normally done in a @code{reset-init} handler is probing
  1087. whatever flash memory was configured. For most chips that needs to be
  1088. done while the associated target is halted, either because JTAG memory
  1089. access uses the CPU or to prevent conflicting CPU access.
  1090. @subsection JTAG Clock Rate
  1091. Before your @code{reset-init} handler has set up
  1092. the PLLs and clocking, you may need to run with
  1093. a low JTAG clock rate.
  1094. @xref{JTAG Speed}.
  1095. Then you'd increase that rate after your handler has
  1096. made it possible to use the faster JTAG clock.
  1097. When the initial low speed is board-specific, for example
  1098. because it depends on a board-specific oscillator speed, then
  1099. you should probably set it up in the board config file;
  1100. if it's target-specific, it belongs in the target config file.
  1101. For most ARM-based processors the fastest JTAG clock@footnote{A FAQ
  1102. @uref{http://www.arm.com/support/faqdev/4170.html} gives details.}
  1103. is one sixth of the CPU clock; or one eighth for ARM11 cores.
  1104. Consult chip documentation to determine the peak JTAG clock rate,
  1105. which might be less than that.
  1106. @quotation Warning
  1107. On most ARMs, JTAG clock detection is coupled to the core clock, so
  1108. software using a @option{wait for interrupt} operation blocks JTAG access.
  1109. Adaptive clocking provides a partial workaround, but a more complete
  1110. solution just avoids using that instruction with JTAG debuggers.
  1111. @end quotation
  1112. If the board supports adaptive clocking, use the @command{jtag_rclk}
  1113. command, in case your board is used with JTAG adapter which
  1114. also supports it. Otherwise use @command{jtag_khz}.
  1115. Set the slow rate at the beginning of the reset sequence,
  1116. and the faster rate as soon as the clocks are at full speed.
  1117. @section Target Config Files
  1118. @cindex config file, target
  1119. @cindex target config file
  1120. Board config files communicate with target config files using
  1121. naming conventions as described above, and may source one or
  1122. more target config files like this:
  1123. @example
  1124. source [find target/FOOBAR.cfg]
  1125. @end example
  1126. The point of a target config file is to package everything
  1127. about a given chip that board config files need to know.
  1128. In summary the target files should contain
  1129. @enumerate
  1130. @item Set defaults
  1131. @item Add TAPs to the scan chain
  1132. @item Add CPU targets (includes GDB support)
  1133. @item CPU/Chip/CPU-Core specific features
  1134. @item On-Chip flash
  1135. @end enumerate
  1136. As a rule of thumb, a target file sets up only one chip.
  1137. For a microcontroller, that will often include a single TAP,
  1138. which is a CPU needing a GDB target, and its on-chip flash.
  1139. More complex chips may include multiple TAPs, and the target
  1140. config file may need to define them all before OpenOCD
  1141. can talk to the chip.
  1142. For example, some phone chips have JTAG scan chains that include
  1143. an ARM core for operating system use, a DSP,
  1144. another ARM core embedded in an image processing engine,
  1145. and other processing engines.
  1146. @subsection Default Value Boiler Plate Code
  1147. All target configuration files should start with code like this,
  1148. letting board config files express environment-specific
  1149. differences in how things should be set up.
  1150. @example
  1151. # Boards may override chip names, perhaps based on role,
  1152. # but the default should match what the vendor uses
  1153. if @{ [info exists CHIPNAME] @} @{
  1154. set _CHIPNAME $CHIPNAME
  1155. @} else @{
  1156. set _CHIPNAME sam7x256
  1157. @}
  1158. # ONLY use ENDIAN with targets that can change it.
  1159. if @{ [info exists ENDIAN] @} @{
  1160. set _ENDIAN $ENDIAN
  1161. @} else @{
  1162. set _ENDIAN little
  1163. @}
  1164. # TAP identifiers may change as chips mature, for example with
  1165. # new revision fields (the "3" here). Pick a good default; you
  1166. # can pass several such identifiers to the "jtag newtap" command.
  1167. if @{ [info exists CPUTAPID ] @} @{
  1168. set _CPUTAPID $CPUTAPID
  1169. @} else @{
  1170. set _CPUTAPID 0x3f0f0f0f
  1171. @}
  1172. @end example
  1173. @c but 0x3f0f0f0f is for an str73x part ...
  1174. @emph{Remember:} Board config files may include multiple target
  1175. config files, or the same target file multiple times
  1176. (changing at least @code{CHIPNAME}).
  1177. Likewise, the target configuration file should define
  1178. @code{_TARGETNAME} (or @code{_TARGETNAME0} etc) and
  1179. use it later on when defining debug targets:
  1180. @example
  1181. set _TARGETNAME $_CHIPNAME.cpu
  1182. target create $_TARGETNAME arm7tdmi -chain-position $_TARGETNAME
  1183. @end example
  1184. @subsection Adding TAPs to the Scan Chain
  1185. After the ``defaults'' are set up,
  1186. add the TAPs on each chip to the JTAG scan chain.
  1187. @xref{TAP Declaration}, and the naming convention
  1188. for taps.
  1189. In the simplest case the chip has only one TAP,
  1190. probably for a CPU or FPGA.
  1191. The config file for the Atmel AT91SAM7X256
  1192. looks (in part) like this:
  1193. @example
  1194. jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
  1195. @end example
  1196. A board with two such at91sam7 chips would be able
  1197. to source such a config file twice, with different
  1198. values for @code{CHIPNAME}, so
  1199. it adds a different TAP each time.
  1200. If there are nonzero @option{-expected-id} values,
  1201. OpenOCD attempts to verify the actual tap id against those values.
  1202. It will issue error messages if there is mismatch, which
  1203. can help to pinpoint problems in OpenOCD configurations.
  1204. @example
  1205. JTAG tap: sam7x256.cpu tap/device found: 0x3f0f0f0f
  1206. (Manufacturer: 0x787, Part: 0xf0f0, Version: 0x3)
  1207. ERROR: Tap: sam7x256.cpu - Expected id: 0x12345678, Got: 0x3f0f0f0f
  1208. ERROR: expected: mfg: 0x33c, part: 0x2345, ver: 0x1
  1209. ERROR: got: mfg: 0x787, part: 0xf0f0, ver: 0x3
  1210. @end example
  1211. There are more complex examples too, with chips that have
  1212. multiple TAPs. Ones worth looking at include:
  1213. @itemize
  1214. @item @file{target/omap3530.cfg} -- with disabled ARM and DSP,
  1215. plus a JRC to enable them
  1216. @item @file{target/str912.cfg} -- with flash, CPU, and boundary scan
  1217. @item @file{target/ti_dm355.cfg} -- with ETM, ARM, and JRC (this JRC
  1218. is not currently used)
  1219. @end itemize
  1220. @subsection Add CPU targets
  1221. After adding a TAP for a CPU, you should set it up so that
  1222. GDB and other commands can use it.
  1223. @xref{CPU Configuration}.
  1224. For the at91sam7 example above, the command can look like this;
  1225. note that @code{$_ENDIAN} is not needed, since OpenOCD defaults
  1226. to little endian, and this chip doesn't support changing that.
  1227. @example
  1228. set _TARGETNAME $_CHIPNAME.cpu
  1229. target create $_TARGETNAME arm7tdmi -chain-position $_TARGETNAME
  1230. @end example
  1231. Work areas are small RAM areas associated with CPU targets.
  1232. They are used by OpenOCD to speed up downloads,
  1233. and to download small snippets of code to program flash chips.
  1234. If the chip includes a form of ``on-chip-ram'' - and many do - define
  1235. a work area if you can.
  1236. Again using the at91sam7 as an example, this can look like:
  1237. @example
  1238. $_TARGETNAME configure -work-area-phys 0x00200000 \
  1239. -work-area-size 0x4000 -work-area-backup 0
  1240. @end example
  1241. @subsection Chip Reset Setup
  1242. As a rule, you should put the @command{reset_config} command
  1243. into the board file. Most things you think you know about a
  1244. chip can be tweaked by the board.
  1245. Some chips have specific ways the TRST and SRST signals are
  1246. managed. In the unusual case that these are @emph{chip specific}
  1247. and can never be changed by board wiring, they could go here.
  1248. For example, some chips can't support JTAG debugging without
  1249. both signals.
  1250. Provide a @code{reset-assert} event handler if you can.
  1251. Such a handler uses JTAG operations to reset the target,
  1252. letting this target config be used in systems which don't
  1253. provide the optional SRST signal, or on systems where you
  1254. don't want to reset all targets at once.
  1255. Such a handler might write to chip registers to force a reset,
  1256. use a JRC to do that (preferable -- the target may be wedged!),
  1257. or force a watchdog timer to trigger.
  1258. (For Cortex-M3 targets, this is not necessary. The target
  1259. driver knows how to use trigger an NVIC reset when SRST is
  1260. not available.)
  1261. Some chips need special attention during reset handling if
  1262. they're going to be used with JTAG.
  1263. An example might be needing to send some commands right
  1264. after the target's TAP has been reset, providing a
  1265. @code{reset-deassert-post} event handler that writes a chip
  1266. register to report that JTAG debugging is being done.
  1267. Another would be reconfiguring the watchdog so that it stops
  1268. counting while the core is halted in the debugger.
  1269. JTAG clocking constraints often change during reset, and in
  1270. some cases target config files (rather than board config files)
  1271. are the right places to handle some of those issues.
  1272. For example, immediately after reset most chips run using a
  1273. slower clock than they will use later.
  1274. That means that after reset (and potentially, as OpenOCD
  1275. first starts up) they must use a slower JTAG clock rate
  1276. than they will use later.
  1277. @xref{JTAG Speed}.
  1278. @quotation Important
  1279. When you are debugging code that runs right after chip
  1280. reset, getting these issues right is critical.
  1281. In particular, if you see intermittent failures when
  1282. OpenOCD verifies the scan chain after reset,
  1283. look at how you are setting up JTAG clocking.
  1284. @end quotation
  1285. @subsection ARM Core Specific Hacks
  1286. If the chip has a DCC, enable it. If the chip is an ARM9 with some
  1287. special high speed download features - enable it.
  1288. If present, the MMU, the MPU and the CACHE should be disabled.
  1289. Some ARM cores are equipped with trace support, which permits
  1290. examination of the instruction and data bus activity. Trace
  1291. activity is controlled through an ``Embedded Trace Module'' (ETM)
  1292. on one of the core's scan chains. The ETM emits voluminous data
  1293. through a ``trace port''. (@xref{ARM Hardware Tracing}.)
  1294. If you are using an external trace port,
  1295. configure it in your board config file.
  1296. If you are using an on-chip ``Embedded Trace Buffer'' (ETB),
  1297. configure it in your target config file.
  1298. @example
  1299. etm config $_TARGETNAME 16 normal full etb
  1300. etb config $_TARGETNAME $_CHIPNAME.etb
  1301. @end example
  1302. @subsection Internal Flash Configuration
  1303. This applies @b{ONLY TO MICROCONTROLLERS} that have flash built in.
  1304. @b{Never ever} in the ``target configuration file'' define any type of
  1305. flash that is external to the chip. (For example a BOOT flash on
  1306. Chip Select 0.) Such flash information goes in a board file - not
  1307. the TARGET (chip) file.
  1308. Examples:
  1309. @itemize @bullet
  1310. @item at91sam7x256 - has 256K flash YES enable it.
  1311. @item str912 - has flash internal YES enable it.
  1312. @item imx27 - uses boot flash on CS0 - it goes in the board file.
  1313. @item pxa270 - again - CS0 flash - it goes in the board file.
  1314. @end itemize
  1315. @anchor{Translating Configuration Files}
  1316. @section Translating Configuration Files
  1317. @cindex translation
  1318. If you have a configuration file for another hardware debugger
  1319. or toolset (Abatron, BDI2000, BDI3000, CCS,
  1320. Lauterbach, Segger, Macraigor, etc.), translating
  1321. it into OpenOCD syntax is often quite straightforward. The most tricky
  1322. part of creating a configuration script is oftentimes the reset init
  1323. sequence where e.g. PLLs, DRAM and the like is set up.
  1324. One trick that you can use when translating is to write small
  1325. Tcl procedures to translate the syntax into OpenOCD syntax. This
  1326. can avoid manual translation errors and make it easier to
  1327. convert other scripts later on.
  1328. Example of transforming quirky arguments to a simple search and
  1329. replace job:
  1330. @example
  1331. # Lauterbach syntax(?)
  1332. #
  1333. # Data.Set c15:0x042f %long 0x40000015
  1334. #
  1335. # OpenOCD syntax when using procedure below.
  1336. #
  1337. # setc15 0x01 0x00050078
  1338. proc setc15 @{regs value@} @{
  1339. global TARGETNAME
  1340. echo [format "set p15 0x%04x, 0x%08x" $regs $value]
  1341. arm mcr 15 [expr ($regs>>12)&0x7] \
  1342. [expr ($regs>>0)&0xf] [expr ($regs>>4)&0xf] \
  1343. [expr ($regs>>8)&0x7] $value
  1344. @}
  1345. @end example
  1346. @node Daemon Configuration
  1347. @chapter Daemon Configuration
  1348. @cindex initialization
  1349. The commands here are commonly found in the openocd.cfg file and are
  1350. used to specify what TCP/IP ports are used, and how GDB should be
  1351. supported.
  1352. @anchor{Configuration Stage}
  1353. @section Configuration Stage
  1354. @cindex configuration stage
  1355. @cindex config command
  1356. When the OpenOCD server process starts up, it enters a
  1357. @emph{configuration stage} which is the only time that
  1358. certain commands, @emph{configuration commands}, may be issued.
  1359. Normally, configuration commands are only available
  1360. inside startup scripts.
  1361. In this manual, the definition of a configuration command is
  1362. presented as a @emph{Config Command}, not as a @emph{Command}
  1363. which may be issued interactively.
  1364. The runtime @command{help} command also highlights configuration
  1365. commands, and those which may be issued at any time.
  1366. Those configuration commands include declaration of TAPs,
  1367. flash banks,
  1368. the interface used for JTAG communication,
  1369. and other basic setup.
  1370. The server must leave the configuration stage before it
  1371. may access or activate TAPs.
  1372. After it leaves this stage, configuration commands may no
  1373. longer be issued.
  1374. @section Entering the Run Stage
  1375. The first thing OpenOCD does after leaving the configuration
  1376. stage is to verify that it can talk to the scan chain
  1377. (list of TAPs) which has been configured.
  1378. It will warn if it doesn't find TAPs it expects to find,
  1379. or finds TAPs that aren't supposed to be there.
  1380. You should see no errors at this point.
  1381. If you see errors, resolve them by correcting the
  1382. commands you used to configure the server.
  1383. Common errors include using an initial JTAG speed that's too
  1384. fast, and not providing the right IDCODE values for the TAPs
  1385. on the scan chain.
  1386. Once OpenOCD has entered the run stage, a number of commands
  1387. become available.
  1388. A number of these relate to the debug targets you may have declared.
  1389. For example, the @command{mww} command will not be available until
  1390. a target has been successfuly instantiated.
  1391. If you want to use those commands, you may need to force
  1392. entry to the run stage.
  1393. @deffn {Config Command} init
  1394. This command terminates the configuration stage and
  1395. enters the run stage. This helps when you need to have
  1396. the startup scripts manage tasks such as resetting the target,
  1397. programming flash, etc. To reset the CPU upon startup, add "init" and
  1398. "reset" at the end of the config script or at the end of the OpenOCD
  1399. command line using the @option{-c} command line switch.
  1400. If this command does not appear in any startup/configuration file
  1401. OpenOCD executes the command for you after processing all
  1402. configuration files and/or command line options.
  1403. @b{NOTE:} This command normally occurs at or near the end of your
  1404. openocd.cfg file to force OpenOCD to ``initialize'' and make the
  1405. targets ready. For example: If your openocd.cfg file needs to
  1406. read/write memory on your target, @command{init} must occur before
  1407. the memory read/write commands. This includes @command{nand probe}.
  1408. @end deffn
  1409. @deffn {Overridable Procedure} jtag_init
  1410. This is invoked at server startup to verify that it can talk
  1411. to the scan chain (list of TAPs) which has been configured.
  1412. The default implementation first tries @command{jtag arp_init},
  1413. which uses only a lightweight JTAG reset before examining the
  1414. scan chain.
  1415. If that fails, it tries again, using a harder reset
  1416. from the overridable procedure @command{init_reset}.
  1417. Implementations must have verified the JTAG scan chain before
  1418. they return.
  1419. This is done by calling @command{jtag arp_init}
  1420. (or @command{jtag arp_init-reset}).
  1421. @end deffn
  1422. @anchor{TCP/IP Ports}
  1423. @section TCP/IP Ports
  1424. @cindex TCP port
  1425. @cindex server
  1426. @cindex port
  1427. @cindex security
  1428. The OpenOCD server accepts remote commands in several syntaxes.
  1429. Each syntax uses a different TCP/IP port, which you may specify
  1430. only during configuration (before those ports are opened).
  1431. For reasons including security, you may wish to prevent remote
  1432. access using one or more of these ports.
  1433. In such cases, just specify the relevant port number as zero.
  1434. If you disable all access through TCP/IP, you will need to
  1435. use the command line @option{-pipe} option.
  1436. @deffn {Command} gdb_port [number]
  1437. @cindex GDB server
  1438. Specify or query the first port used for incoming GDB connections.
  1439. The GDB port for the
  1440. first target will be gdb_port, the second target will listen on gdb_port + 1, and so on.
  1441. When not specified during the configuration stage,
  1442. the port @var{number} defaults to 3333.
  1443. When specified as zero, GDB remote access ports are not activated.
  1444. @end deffn
  1445. @deffn {Command} tcl_port [number]
  1446. Specify or query the port used for a simplified RPC
  1447. connection that can be used by clients to issue TCL commands and get the
  1448. output from the Tcl engine.
  1449. Intended as a machine interface.
  1450. When not specified during the configuration stage,
  1451. the port @var{number} defaults to 6666.
  1452. When specified as zero, this port is not activated.
  1453. @end deffn
  1454. @deffn {Command} telnet_port [number]
  1455. Specify or query the
  1456. port on which to listen for incoming telnet connections.
  1457. This port is intended for interaction with one human through TCL commands.
  1458. When not specified during the configuration stage,
  1459. the port @var{number} defaults to 4444.
  1460. When specified as zero, this port is not activated.
  1461. @end deffn
  1462. @anchor{GDB Configuration}
  1463. @section GDB Configuration
  1464. @cindex GDB
  1465. @cindex GDB configuration
  1466. You can reconfigure some GDB behaviors if needed.
  1467. The ones listed here are static and global.
  1468. @xref{Target Configuration}, about configuring individual targets.
  1469. @xref{Target Events}, about configuring target-specific event handling.
  1470. @anchor{gdb_breakpoint_override}
  1471. @deffn {Command} gdb_breakpoint_override [@option{hard}|@option{soft}|@option{disable}]
  1472. Force breakpoint type for gdb @command{break} commands.
  1473. This option supports GDB GUIs which don't
  1474. distinguish hard versus soft breakpoints, if the default OpenOCD and
  1475. GDB behaviour is not sufficient. GDB normally uses hardware
  1476. breakpoints if the memory map has been set up for flash regions.
  1477. @end deffn
  1478. @anchor{gdb_flash_program}
  1479. @deffn {Config Command} gdb_flash_program (@option{enable}|@option{disable})
  1480. Set to @option{enable} to cause OpenOCD to program the flash memory when a
  1481. vFlash packet is received.
  1482. The default behaviour is @option{enable}.
  1483. @end deffn
  1484. @deffn {Config Command} gdb_memory_map (@option{enable}|@option{disable})
  1485. Set to @option{enable} to cause OpenOCD to send the memory configuration to GDB when
  1486. requested. GDB will then know when to set hardware breakpoints, and program flash
  1487. using the GDB load command. @command{gdb_flash_program enable} must also be enabled
  1488. for flash programming to work.
  1489. Default behaviour is @option{enable}.
  1490. @xref{gdb_flash_program}.
  1491. @end deffn
  1492. @deffn {Config Command} gdb_report_data_abort (@option{enable}|@option{disable})
  1493. Specifies whether data aborts cause an error to be reported
  1494. by GDB memory read packets.
  1495. The default behaviour is @option{disable};
  1496. use @option{enable} see these errors reported.
  1497. @end deffn
  1498. @anchor{Event Polling}
  1499. @section Event Polling
  1500. Hardware debuggers are parts of asynchronous systems,
  1501. where significant events can happen at any time.
  1502. The OpenOCD server needs to detect some of these events,
  1503. so it can report them to through TCL command line
  1504. or to GDB.
  1505. Examples of such events include:
  1506. @itemize
  1507. @item One of the targets can stop running ... maybe it triggers
  1508. a code breakpoint or data watchpoint, or halts itself.
  1509. @item Messages may be sent over ``debug message'' channels ... many
  1510. targets support such messages sent over JTAG,
  1511. for receipt by the person debugging or tools.
  1512. @item Loss of power ... some adapters can detect these events.
  1513. @item Resets not issued through JTAG ... such reset sources
  1514. can include button presses or other system hardware, sometimes
  1515. including the target itself (perhaps through a watchdog).
  1516. @item Debug instrumentation sometimes supports event triggering
  1517. such as ``trace buffer full'' (so it can quickly be emptied)
  1518. or other signals (to correlate with code behavior).
  1519. @end itemize
  1520. None of those events are signaled through standard JTAG signals.
  1521. However, most conventions for JTAG connectors include voltage
  1522. level and system reset (SRST) signal detection.
  1523. Some connectors also include instrumentation signals, which
  1524. can imply events when those signals are inputs.
  1525. In general, OpenOCD needs to periodically check for those events,
  1526. either by looking at the status of signals on the JTAG connector
  1527. or by sending synchronous ``tell me your status'' JTAG requests
  1528. to the various active targets.
  1529. There is a command to manage and monitor that polling,
  1530. which is normally done in the background.
  1531. @deffn Command poll [@option{on}|@option{off}]
  1532. Poll the current target for its current state.
  1533. (Also, @pxref{target curstate}.)
  1534. If that target is in debug mode, architecture
  1535. specific information about the current state is printed.
  1536. An optional parameter
  1537. allows background polling to be enabled and disabled.
  1538. You could use this from the TCL command shell, or
  1539. from GDB using @command{monitor poll} command.
  1540. Leave background polling enabled while you're using GDB.
  1541. @example
  1542. > poll
  1543. background polling: on
  1544. target state: halted
  1545. target halted in ARM state due to debug-request, \
  1546. current mode: Supervisor
  1547. cpsr: 0x800000d3 pc: 0x11081bfc
  1548. MMU: disabled, D-Cache: disabled, I-Cache: enabled
  1549. >
  1550. @end example
  1551. @end deffn
  1552. @node Interface - Dongle Configuration
  1553. @chapter Interface - Dongle Configuration
  1554. @cindex config file, interface
  1555. @cindex interface config file
  1556. JTAG Adapters/Interfaces/Dongles are normally configured
  1557. through commands in an interface configuration
  1558. file which is sourced by your @file{openocd.cfg} file, or
  1559. through a command line @option{-f interface/....cfg} option.
  1560. @example
  1561. source [find interface/olimex-jtag-tiny.cfg]
  1562. @end example
  1563. These commands tell
  1564. OpenOCD what type of JTAG adapter you have, and how to talk to it.
  1565. A few cases are so simple that you only need to say what driver to use:
  1566. @example
  1567. # jlink interface
  1568. interface jlink
  1569. @end example
  1570. Most adapters need a bit more configuration than that.
  1571. @section Interface Configuration
  1572. The interface command tells OpenOCD what type of JTAG dongle you are
  1573. using. Depending on the type of dongle, you may need to have one or
  1574. more additional commands.
  1575. @deffn {Config Command} {interface} name
  1576. Use the interface driver @var{name} to connect to the
  1577. target.
  1578. @end deffn
  1579. @deffn Command {interface_list}
  1580. List the interface drivers that have been built into
  1581. the running copy of OpenOCD.
  1582. @end deffn
  1583. @deffn Command {jtag interface}
  1584. Returns the name of the interface driver being used.
  1585. @end deffn
  1586. @section Interface Drivers
  1587. Each of the interface drivers listed here must be explicitly
  1588. enabled when OpenOCD is configured, in order to be made
  1589. available at run time.
  1590. @deffn {Interface Driver} {amt_jtagaccel}
  1591. Amontec Chameleon in its JTAG Accelerator configuration,
  1592. connected to a PC's EPP mode parallel port.
  1593. This defines some driver-specific commands:
  1594. @deffn {Config Command} {parport_port} number
  1595. Specifies either the address of the I/O port (default: 0x378 for LPT1) or
  1596. the number of the @file{/dev/parport} device.
  1597. @end deffn
  1598. @deffn {Config Command} rtck [@option{enable}|@option{disable}]
  1599. Displays status of RTCK option.
  1600. Optionally sets that option first.
  1601. @end deffn
  1602. @end deffn
  1603. @deffn {Interface Driver} {arm-jtag-ew}
  1604. Olimex ARM-JTAG-EW USB adapter
  1605. This has one driver-specific command:
  1606. @deffn Command {armjtagew_info}
  1607. Logs some status
  1608. @end deffn
  1609. @end deffn
  1610. @deffn {Interface Driver} {at91rm9200}
  1611. Supports bitbanged JTAG from the local system,
  1612. presuming that system is an Atmel AT91rm9200
  1613. and a specific set of GPIOs is used.
  1614. @c command: at91rm9200_device NAME
  1615. @c chooses among list of bit configs ... only one option
  1616. @end deffn
  1617. @deffn {Interface Driver} {dummy}
  1618. A dummy software-only driver for debugging.
  1619. @end deffn
  1620. @deffn {Interface Driver} {ep93xx}
  1621. Cirrus Logic EP93xx based single-board computer bit-banging (in development)
  1622. @end deffn
  1623. @deffn {Interface Driver} {ft2232}
  1624. FTDI FT2232 (USB) based devices over one of the userspace libraries.
  1625. These interfaces have several commands, used to configure the driver
  1626. before initializing the JTAG scan chain:
  1627. @deffn {Config Command} {ft2232_device_desc} description
  1628. Provides the USB device description (the @emph{iProduct string})
  1629. of the FTDI FT2232 device. If not
  1630. specified, the FTDI default value is used. This setting is only valid
  1631. if compiled with FTD2XX support.
  1632. @end deffn
  1633. @deffn {Config Command} {ft2232_serial} serial-number
  1634. Specifies the @var{serial-number} of the FTDI FT2232 device to use,
  1635. in case the vendor provides unique IDs and more than one FT2232 device
  1636. is connected to the host.
  1637. If not specified, serial numbers are not considered.
  1638. (Note that USB serial numbers can be arbitrary Unicode strings,
  1639. and are not restricted to containing only decimal digits.)
  1640. @end deffn
  1641. @deffn {Config Command} {ft2232_layout} name
  1642. Each vendor's FT2232 device can use different GPIO signals
  1643. to control output-enables, reset signals, and LEDs.
  1644. Currently valid layout @var{name} values include:
  1645. @itemize @minus
  1646. @item @b{axm0432_jtag} Axiom AXM-0432
  1647. @item @b{comstick} Hitex STR9 comstick
  1648. @item @b{cortino} Hitex Cortino JTAG interface
  1649. @item @b{evb_lm3s811} Luminary Micro EVB_LM3S811 as a JTAG interface,
  1650. either for the local Cortex-M3 (SRST only)
  1651. or in a passthrough mode (neither SRST nor TRST)
  1652. This layout can not support the SWO trace mechanism, and should be
  1653. used only for older boards (before rev C).
  1654. @item @b{luminary_icdi} This layout should be used with most Luminary
  1655. eval boards, including Rev C LM3S811 eval boards and the eponymous
  1656. ICDI boards, to debug either the local Cortex-M3 or in passthrough mode
  1657. to debug some other target. It can support the SWO trace mechanism.
  1658. @item @b{flyswatter} Tin Can Tools Flyswatter
  1659. @item @b{icebear} ICEbear JTAG adapter from Section 5
  1660. @item @b{jtagkey} Amontec JTAGkey and JTAGkey-Tiny (and compatibles)
  1661. @item @b{jtagkey2} Amontec JTAGkey2 (and compatibles)
  1662. @item @b{m5960} American Microsystems M5960
  1663. @item @b{olimex-jtag} Olimex ARM-USB-OCD and ARM-USB-Tiny
  1664. @item @b{oocdlink} OOCDLink
  1665. @c oocdlink ~= jtagkey_prototype_v1
  1666. @item @b{sheevaplug} Marvell Sheevaplug development kit
  1667. @item @b{signalyzer} Xverve Signalyzer
  1668. @item @b{stm32stick} Hitex STM32 Performance Stick
  1669. @item @b{turtelizer2} egnite Software turtelizer2
  1670. @item @b{usbjtag} "USBJTAG-1" layout described in the OpenOCD diploma thesis
  1671. @end itemize
  1672. @end deffn
  1673. @deffn {Config Command} {ft2232_vid_pid} [vid pid]+
  1674. The vendor ID and product ID of the FTDI FT2232 device. If not specified, the FTDI
  1675. default values are used.
  1676. Currently, up to eight [@var{vid}, @var{pid}] pairs may be given, e.g.
  1677. @example
  1678. ft2232_vid_pid 0x0403 0xcff8 0x15ba 0x0003
  1679. @end example
  1680. @end deffn
  1681. @deffn {Config Command} {ft2232_latency} ms
  1682. On some systems using FT2232 based JTAG interfaces the FT_Read function call in
  1683. ft2232_read() fails to return the expected number of bytes. This can be caused by
  1684. USB communication delays and has proved hard to reproduce and debug. Setting the
  1685. FT2232 latency timer to a larger value increases delays for short USB packets but it
  1686. also reduces the risk of timeouts before receiving the expected number of bytes.
  1687. The OpenOCD default value is 2 and for some systems a value of 10 has proved useful.
  1688. @end deffn
  1689. For example, the interface config file for a
  1690. Turtelizer JTAG Adapter looks something like this:
  1691. @example
  1692. interface ft2232
  1693. ft2232_device_desc "Turtelizer JTAG/RS232 Adapter"
  1694. ft2232_layout turtelizer2
  1695. ft2232_vid_pid 0x0403 0xbdc8
  1696. @end example
  1697. @end deffn
  1698. @deffn {Interface Driver} {usb_blaster}
  1699. USB JTAG/USB-Blaster compatibles over one of the userspace libraries
  1700. for FTDI chips. These interfaces have several commands, used to
  1701. configure the driver before initializing the JTAG scan chain:
  1702. @deffn {Config Command} {usb_blaster_device_desc} description
  1703. Provides the USB device description (the @emph{iProduct string})
  1704. of the FTDI FT245 device. If not
  1705. specified, the FTDI default value is used. This setting is only valid
  1706. if compiled with FTD2XX support.
  1707. @end deffn
  1708. @deffn {Config Command} {usb_blaster_vid_pid} vid pid
  1709. The vendor ID and product ID of the FTDI FT245 device. If not specified,
  1710. default values are used.
  1711. Currently, only one @var{vid}, @var{pid} pair may be given, e.g. for
  1712. Altera USB-Blaster (default):
  1713. @example
  1714. ft2232_vid_pid 0x09FB 0x6001
  1715. @end example
  1716. The following VID/PID is for Kolja Waschk's USB JTAG:
  1717. @example
  1718. ft2232_vid_pid 0x16C0 0x06AD
  1719. @end example
  1720. @end deffn
  1721. @deffn {Command} {usb_blaster} (@option{pin6}|@option{pin8}) (@option{0}|@option{1})
  1722. Sets the state of the unused GPIO pins on USB-Blasters (pins 6 and 8 on the
  1723. female JTAG header). These pins can be used as SRST and/or TRST provided the
  1724. appropriate connections are made on the target board.
  1725. For example, to use pin 6 as SRST (as with an AVR board):
  1726. @example
  1727. $_TARGETNAME configure -event reset-assert \
  1728. "usb_blaster pin6 1; wait 1; usb_blaster pin6 0"
  1729. @end example
  1730. @end deffn
  1731. @end deffn
  1732. @deffn {Interface Driver} {gw16012}
  1733. Gateworks GW16012 JTAG programmer.
  1734. This has one driver-specific command:
  1735. @deffn {Config Command} {parport_port} [port_number]
  1736. Display either the address of the I/O port
  1737. (default: 0x378 for LPT1) or the number of the @file{/dev/parport} device.
  1738. If a parameter is provided, first switch to use that port.
  1739. This is a write-once setting.
  1740. @end deffn
  1741. @end deffn
  1742. @deffn {Interface Driver} {jlink}
  1743. Segger jlink USB adapter
  1744. @c command: jlink_info
  1745. @c dumps status
  1746. @c command: jlink_hw_jtag (2|3)
  1747. @c sets version 2 or 3
  1748. @end deffn
  1749. @deffn {Interface Driver} {parport}
  1750. Supports PC parallel port bit-banging cables:
  1751. Wigglers, PLD download cable, and more.
  1752. These interfaces have several commands, used to configure the driver
  1753. before initializing the JTAG scan chain:
  1754. @deffn {Config Command} {parport_cable} name
  1755. Set the layout of the parallel port cable used to connect to the target.
  1756. This is a write-once setting.
  1757. Currently valid cable @var{name} values include:
  1758. @itemize @minus
  1759. @item @b{altium} Altium Universal JTAG cable.
  1760. @item @b{arm-jtag} Same as original wiggler except SRST and
  1761. TRST connections reversed and TRST is also inverted.
  1762. @item @b{chameleon} The Amontec Chameleon's CPLD when operated
  1763. in configuration mode. This is only used to
  1764. program the Chameleon itself, not a connected target.
  1765. @item @b{dlc5} The Xilinx Parallel cable III.
  1766. @item @b{flashlink} The ST Parallel cable.
  1767. @item @b{lattice} Lattice ispDOWNLOAD Cable
  1768. @item @b{old_amt_wiggler} The Wiggler configuration that comes with
  1769. some versions of
  1770. Amontec's Chameleon Programmer. The new version available from
  1771. the website uses the original Wiggler layout ('@var{wiggler}')
  1772. @item @b{triton} The parallel port adapter found on the
  1773. ``Karo Triton 1 Development Board''.
  1774. This is also the layout used by the HollyGates design
  1775. (see @uref{http://www.lartmaker.nl/projects/jtag/}).
  1776. @item @b{wiggler} The original Wiggler layout, also supported by
  1777. several clones, such as the Olimex ARM-JTAG
  1778. @item @b{wiggler2} Same as original wiggler except an led is fitted on D5.
  1779. @item @b{wiggler_ntrst_inverted} Same as original wiggler except TRST is inverted.
  1780. @end itemize
  1781. @end deffn
  1782. @deffn {Config Command} {parport_port} [port_number]
  1783. Display either the address of the I/O port
  1784. (default: 0x378 for LPT1) or the number of the @file{/dev/parport} device.
  1785. If a parameter is provided, first switch to use that port.
  1786. This is a write-once setting.
  1787. When using PPDEV to access the parallel port, use the number of the parallel port:
  1788. @option{parport_port 0} (the default). If @option{parport_port 0x378} is specified
  1789. you may encounter a problem.
  1790. @end deffn
  1791. @deffn Command {parport_toggling_time} [nanoseconds]
  1792. Displays how many nanoseconds the hardware needs to toggle TCK;
  1793. the parport driver uses this value to obey the
  1794. @command{jtag_khz} configuration.
  1795. When the optional @var{nanoseconds} parameter is given,
  1796. that setting is changed before displaying the current value.
  1797. The default setting should work reasonably well on commodity PC hardware.
  1798. However, you may want to calibrate for your specific hardware.
  1799. @quotation Tip
  1800. To measure the toggling time with a logic analyzer or a digital storage
  1801. oscilloscope, follow the procedure below:
  1802. @example
  1803. > parport_toggling_time 1000
  1804. > jtag_khz 500
  1805. @end example
  1806. This sets the maximum JTAG clock speed of the hardware, but
  1807. the actual speed probably deviates from the requested 500 kHz.
  1808. Now, measure the time between the two closest spaced TCK transitions.
  1809. You can use @command{runtest 1000} or something similar to generate a
  1810. large set of samples.
  1811. Update the setting to match your measurement:
  1812. @example
  1813. > parport_toggling_time <measured nanoseconds>
  1814. @end example
  1815. Now the clock speed will be a better match for @command{jtag_khz rate}
  1816. commands given in OpenOCD scripts and event handlers.
  1817. You can do something similar with many digital multimeters, but note
  1818. that you'll probably need to run the clock continuously for several
  1819. seconds before it decides what clock rate to show. Adjust the
  1820. toggling time up or down until the measured clock rate is a good
  1821. match for the jtag_khz rate you specified; be conservative.
  1822. @end quotation
  1823. @end deffn
  1824. @deffn {Config Command} {parport_write_on_exit} (@option{on}|@option{off})
  1825. This will configure the parallel driver to write a known
  1826. cable-specific value to the parallel interface on exiting OpenOCD.
  1827. @end deffn
  1828. For example, the interface configuration file for a
  1829. classic ``Wiggler'' cable on LPT2 might look something like this:
  1830. @example
  1831. interface parport
  1832. parport_port 0x278
  1833. parport_cable wiggler
  1834. @end example
  1835. @end deffn
  1836. @deffn {Interface Driver} {presto}
  1837. ASIX PRESTO USB JTAG programmer.
  1838. @deffn {Config Command} {presto_serial} serial_string
  1839. Configures the USB serial number of the Presto device to use.
  1840. @end deffn
  1841. @end deffn
  1842. @deffn {Interface Driver} {rlink}
  1843. Raisonance RLink USB adapter
  1844. @end deffn
  1845. @deffn {Interface Driver} {usbprog}
  1846. usbprog is a freely programmable USB adapter.
  1847. @end deffn
  1848. @deffn {Interface Driver} {vsllink}
  1849. vsllink is part of Versaloon which is a versatile USB programmer.
  1850. @quotation Note
  1851. This defines quite a few driver-specific commands,
  1852. which are not currently documented here.
  1853. @end quotation
  1854. @end deffn
  1855. @deffn {Interface Driver} {ZY1000}
  1856. This is the Zylin ZY1000 JTAG debugger.
  1857. @quotation Note
  1858. This defines some driver-specific commands,
  1859. which are not currently documented here.
  1860. @end quotation
  1861. @deffn Command power [@option{on}|@option{off}]
  1862. Turn power switch to target on/off.
  1863. No arguments: print status.
  1864. @end deffn
  1865. @end deffn
  1866. @anchor{JTAG Speed}
  1867. @section JTAG Speed
  1868. JTAG clock setup is part of system setup.
  1869. It @emph{does not belong with interface setup} since any interface
  1870. only knows a few of the constraints for the JTAG clock speed.
  1871. Sometimes the JTAG speed is
  1872. changed during the target initialization process: (1) slow at
  1873. reset, (2) program the CPU clocks, (3) run fast.
  1874. Both the "slow" and "fast" clock rates are functions of the
  1875. oscillators used, the chip, the board design, and sometimes
  1876. power management software that may be active.
  1877. The speed used during reset, and the scan chain verification which
  1878. follows reset, can be adjusted using a @code{reset-start}
  1879. target event handler.
  1880. It can then be reconfigured to a faster speed by a
  1881. @code{reset-init} target event handler after it reprograms those
  1882. CPU clocks, or manually (if something else, such as a boot loader,
  1883. sets up those clocks).
  1884. @xref{Target Events}.
  1885. When the initial low JTAG speed is a chip characteristic, perhaps
  1886. because of a required oscillator speed, provide such a handler
  1887. in the target config file.
  1888. When that speed is a function of a board-specific characteristic
  1889. such as which speed oscillator is used, it belongs in the board
  1890. config file instead.
  1891. In both cases it's safest to also set the initial JTAG clock rate
  1892. to that same slow speed, so that OpenOCD never starts up using a
  1893. clock speed that's faster than the scan chain can support.
  1894. @example
  1895. jtag_rclk 3000
  1896. $_TARGET.cpu configure -event reset-start @{ jtag_rclk 3000 @}
  1897. @end example
  1898. If your system supports adaptive clocking (RTCK), configuring
  1899. JTAG to use that is probably the most robust approach.
  1900. However, it introduces delays to synchronize clocks; so it
  1901. may not be the fastest solution.
  1902. @b{NOTE:} Script writers should consider using @command{jtag_rclk}
  1903. instead of @command{jtag_khz}.
  1904. @deffn {Command} jtag_khz max_speed_kHz
  1905. A non-zero speed is in KHZ. Hence: 3000 is 3mhz.
  1906. JTAG interfaces usually support a limited number of
  1907. speeds. The speed actually used won't be faster
  1908. than the speed specified.
  1909. Chip data sheets generally include a top JTAG clock rate.
  1910. The actual rate is often a function of a CPU core clock,
  1911. and is normally less than that peak rate.
  1912. For example, most ARM cores accept at most one sixth of the CPU clock.
  1913. Speed 0 (khz) selects RTCK method.
  1914. @xref{FAQ RTCK}.
  1915. If your system uses RTCK, you won't need to change the
  1916. JTAG clocking after setup.
  1917. Not all interfaces, boards, or targets support ``rtck''.
  1918. If the interface device can not
  1919. support it, an error is returned when you try to use RTCK.
  1920. @end deffn
  1921. @defun jtag_rclk fallback_speed_kHz
  1922. @cindex adaptive clocking
  1923. @cindex RTCK
  1924. This Tcl proc (defined in @file{startup.tcl}) attempts to enable RTCK/RCLK.
  1925. If that fails (maybe the interface, board, or target doesn't
  1926. support it), falls back to the specified frequency.
  1927. @example
  1928. # Fall back to 3mhz if RTCK is not supported
  1929. jtag_rclk 3000
  1930. @end example
  1931. @end defun
  1932. @node Reset Configuration
  1933. @chapter Reset Configuration
  1934. @cindex Reset Configuration
  1935. Every system configuration may require a different reset
  1936. configuration. This can also be quite confusing.
  1937. Resets also interact with @var{reset-init} event handlers,
  1938. which do things like setting up clocks and DRAM, and
  1939. JTAG clock rates. (@xref{JTAG Speed}.)
  1940. They can also interact with JTAG routers.
  1941. Please see the various board files for examples.
  1942. @quotation Note
  1943. To maintainers and integrators:
  1944. Reset configuration touches several things at once.
  1945. Normally the board configuration file
  1946. should define it and assume that the JTAG adapter supports
  1947. everything that's wired up to the board's JTAG connector.
  1948. However, the target configuration file could also make note
  1949. of something the silicon vendor has done inside the chip,
  1950. which will be true for most (or all) boards using that chip.
  1951. And when the JTAG adapter doesn't support everything, the
  1952. user configuration file will need to override parts of
  1953. the reset configuration provided by other files.
  1954. @end quotation
  1955. @section Types of Reset
  1956. There are many kinds of reset possible through JTAG, but
  1957. they may not all work with a given board and adapter.
  1958. That's part of why reset configuration can be error prone.
  1959. @itemize @bullet
  1960. @item
  1961. @emph{System Reset} ... the @emph{SRST} hardware signal
  1962. resets all chips connected to the JTAG adapter, such as processors,
  1963. power management chips, and I/O controllers. Normally resets triggered
  1964. with this signal behave exactly like pressing a RESET button.
  1965. @item
  1966. @emph{JTAG TAP Reset} ... the @emph{TRST} hardware signal resets
  1967. just the TAP controllers connected to the JTAG adapter.
  1968. Such resets should not be visible to the rest of the system; resetting a
  1969. device's the TAP controller just puts that controller into a known state.
  1970. @item
  1971. @emph{Emulation Reset} ... many devices can be reset through JTAG
  1972. commands. These resets are often distinguishable from system
  1973. resets, either explicitly (a "reset reason" register says so)
  1974. or implicitly (not all parts of the chip get reset).
  1975. @item
  1976. @emph{Other Resets} ... system-on-chip devices often support
  1977. several other types of reset.
  1978. You may need to arrange that a watchdog timer stops
  1979. while debugging, preventing a watchdog reset.
  1980. There may be individual module resets.
  1981. @end itemize
  1982. In the best case, OpenOCD can hold SRST, then reset
  1983. the TAPs via TRST and send commands through JTAG to halt the
  1984. CPU at the reset vector before the 1st instruction is executed.
  1985. Then when it finally releases the SRST signal, the system is
  1986. halted under debugger control before any code has executed.
  1987. This is the behavior required to support the @command{reset halt}
  1988. and @command{reset init} commands; after @command{reset init} a
  1989. board-specific script might do things like setting up DRAM.
  1990. (@xref{Reset Command}.)
  1991. @anchor{SRST and TRST Issues}
  1992. @section SRST and TRST Issues
  1993. Because SRST and TRST are hardware signals, they can have a
  1994. variety of system-specific constraints. Some of the most
  1995. common issues are:
  1996. @itemize @bullet
  1997. @item @emph{Signal not available} ... Some boards don't wire
  1998. SRST or TRST to the JTAG connector. Some JTAG adapters don't
  1999. support such signals even if they are wired up.
  2000. Use the @command{reset_config} @var{signals} options to say
  2001. when either of those signals is not connected.
  2002. When SRST is not available, your code might not be able to rely
  2003. on controllers having been fully reset during code startup.
  2004. Missing TRST is not a problem, since JTAG level resets can
  2005. be triggered using with TMS signaling.
  2006. @item @emph{Signals shorted} ... Sometimes a chip, board, or
  2007. adapter will connect SRST to TRST, instead of keeping them separate.
  2008. Use the @command{reset_config} @var{combination} options to say
  2009. when those signals aren't properly independent.
  2010. @item @emph{Timing} ... Reset circuitry like a resistor/capacitor
  2011. delay circuit, reset supervisor, or on-chip features can extend
  2012. the effect of a JTAG adapter's reset for some time after the adapter
  2013. stops issuing the reset. For example, there may be chip or board
  2014. requirements that all reset pulses last for at least a
  2015. certain amount of time; and reset buttons commonly have
  2016. hardware debouncing.
  2017. Use the @command{jtag_nsrst_delay} and @command{jtag_ntrst_delay}
  2018. commands to say when extra delays are needed.
  2019. @item @emph{Drive type} ... Reset lines often have a pullup
  2020. resistor, letting the JTAG interface treat them as open-drain
  2021. signals. But that's not a requirement, so the adapter may need
  2022. to use push/pull output drivers.
  2023. Also, with weak pullups it may be advisable to drive
  2024. signals to both levels (push/pull) to minimize rise times.
  2025. Use the @command{reset_config} @var{trst_type} and
  2026. @var{srst_type} parameters to say how to drive reset signals.
  2027. @item @emph{Special initialization} ... Targets sometimes need
  2028. special JTAG initialization sequences to handle chip-specific
  2029. issues (not limited to errata).
  2030. For example, certain JTAG commands might need to be issued while
  2031. the system as a whole is in a reset state (SRST active)
  2032. but the JTAG scan chain is usable (TRST inactive).
  2033. Many systems treat combined assertion of SRST and TRST as a
  2034. trigger for a harder reset than SRST alone.
  2035. Such custom reset handling is discussed later in this chapter.
  2036. @end itemize
  2037. There can also be other issues.
  2038. Some devices don't fully conform to the JTAG specifications.
  2039. Trivial system-specific differences are common, such as
  2040. SRST and TRST using slightly different names.
  2041. There are also vendors who distribute key JTAG documentation for
  2042. their chips only to developers who have signed a Non-Disclosure
  2043. Agreement (NDA).
  2044. Sometimes there are chip-specific extensions like a requirement to use
  2045. the normally-optional TRST signal (precluding use of JTAG adapters which
  2046. don't pass TRST through), or needing extra steps to complete a TAP reset.
  2047. In short, SRST and especially TRST handling may be very finicky,
  2048. needing to cope with both architecture and board specific constraints.
  2049. @section Commands for Handling Resets
  2050. @deffn {Command} jtag_nsrst_assert_width milliseconds
  2051. Minimum amount of time (in milliseconds) OpenOCD should wait
  2052. after asserting nSRST (active-low system reset) before
  2053. allowing it to be deasserted.
  2054. @end deffn
  2055. @deffn {Command} jtag_nsrst_delay milliseconds
  2056. How long (in milliseconds) OpenOCD should wait after deasserting
  2057. nSRST (active-low system reset) before starting new JTAG operations.
  2058. When a board has a reset button connected to SRST line it will
  2059. probably have hardware debouncing, implying you should use this.
  2060. @end deffn
  2061. @deffn {Command} jtag_ntrst_assert_width milliseconds
  2062. Minimum amount of time (in milliseconds) OpenOCD should wait
  2063. after asserting nTRST (active-low JTAG TAP reset) before
  2064. allowing it to be deasserted.
  2065. @end deffn
  2066. @deffn {Command} jtag_ntrst_delay milliseconds
  2067. How long (in milliseconds) OpenOCD should wait after deasserting
  2068. nTRST (active-low JTAG TAP reset) before starting new JTAG operations.
  2069. @end deffn
  2070. @deffn {Command} reset_config mode_flag ...
  2071. This command displays or modifies the reset configuration
  2072. of your combination of JTAG board and target in target
  2073. configuration scripts.
  2074. Information earlier in this section describes the kind of problems
  2075. the command is intended to address (@pxref{SRST and TRST Issues}).
  2076. As a rule this command belongs only in board config files,
  2077. describing issues like @emph{board doesn't connect TRST};
  2078. or in user config files, addressing limitations derived
  2079. from a particular combination of interface and board.
  2080. (An unlikely example would be using a TRST-only adapter
  2081. with a board that only wires up SRST.)
  2082. The @var{mode_flag} options can be specified in any order, but only one
  2083. of each type -- @var{signals}, @var{combination},
  2084. @var{gates},
  2085. @var{trst_type},
  2086. and @var{srst_type} -- may be specified at a time.
  2087. If you don't provide a new value for a given type, its previous
  2088. value (perhaps the default) is unchanged.
  2089. For example, this means that you don't need to say anything at all about
  2090. TRST just to declare that if the JTAG adapter should want to drive SRST,
  2091. it must explicitly be driven high (@option{srst_push_pull}).
  2092. @itemize
  2093. @item
  2094. @var{signals} can specify which of the reset signals are connected.
  2095. For example, If the JTAG interface provides SRST, but the board doesn't
  2096. connect that signal properly, then OpenOCD can't use it.
  2097. Possible values are @option{none} (the default), @option{trst_only},
  2098. @option{srst_only} and @option{trst_and_srst}.
  2099. @quotation Tip
  2100. If your board provides SRST and/or TRST through the JTAG connector,
  2101. you must declare that so those signals can be used.
  2102. @end quotation
  2103. @item
  2104. The @var{combination} is an optional value specifying broken reset
  2105. signal implementations.
  2106. The default behaviour if no option given is @option{separate},
  2107. indicating everything behaves normally.
  2108. @option{srst_pulls_trst} states that the
  2109. test logic is reset together with the reset of the system (e.g. NXP
  2110. LPC2000, "broken" board layout), @option{trst_pulls_srst} says that
  2111. the system is reset together with the test logic (only hypothetical, I
  2112. haven't seen hardware with such a bug, and can be worked around).
  2113. @option{combined} implies both @option{srst_pulls_trst} and
  2114. @option{trst_pulls_srst}.
  2115. @item
  2116. The @var{gates} tokens control flags that describe some cases where
  2117. JTAG may be unvailable during reset.
  2118. @option{srst_gates_jtag} (default)
  2119. indicates that asserting SRST gates the
  2120. JTAG clock. This means that no communication can happen on JTAG
  2121. while SRST is asserted.
  2122. Its converse is @option{srst_nogate}, indicating that JTAG commands
  2123. can safely be issued while SRST is active.
  2124. @end itemize
  2125. The optional @var{trst_type} and @var{srst_type} parameters allow the
  2126. driver mode of each reset line to be specified. These values only affect
  2127. JTAG interfaces with support for different driver modes, like the Amontec
  2128. JTAGkey and JTAG Accelerator. Also, they are necessarily ignored if the
  2129. relevant signal (TRST or SRST) is not connected.
  2130. @itemize
  2131. @item
  2132. Possible @var{trst_type} driver modes for the test reset signal (TRST)
  2133. are the default @option{trst_push_pull}, and @option{trst_open_drain}.
  2134. Most boards connect this signal to a pulldown, so the JTAG TAPs
  2135. never leave reset unless they are hooked up to a JTAG adapter.
  2136. @item
  2137. Possible @var{srst_type} driver modes for the system reset signal (SRST)
  2138. are the default @option{srst_open_drain}, and @option{srst_push_pull}.
  2139. Most boards connect this signal to a pullup, and allow the
  2140. signal to be pulled low by various events including system
  2141. powerup and pressing a reset button.
  2142. @end itemize
  2143. @end deffn
  2144. @section Custom Reset Handling
  2145. @cindex events
  2146. OpenOCD has several ways to help support the various reset
  2147. mechanisms provided by chip and board vendors.
  2148. The commands shown in the previous section give standard parameters.
  2149. There are also @emph{event handlers} associated with TAPs or Targets.
  2150. Those handlers are Tcl procedures you can provide, which are invoked
  2151. at particular points in the reset sequence.
  2152. @emph{When SRST is not an option} you must set
  2153. up a @code{reset-assert} event handler for your target.
  2154. For example, some JTAG adapters don't include the SRST signal;
  2155. and some boards have multiple targets, and you won't always
  2156. want to reset everything at once.
  2157. After configuring those mechanisms, you might still
  2158. find your board doesn't start up or reset correctly.
  2159. For example, maybe it needs a slightly different sequence
  2160. of SRST and/or TRST manipulations, because of quirks that
  2161. the @command{reset_config} mechanism doesn't address;
  2162. or asserting both might trigger a stronger reset, which
  2163. needs special attention.
  2164. Experiment with lower level operations, such as @command{jtag_reset}
  2165. and the @command{jtag arp_*} operations shown here,
  2166. to find a sequence of operations that works.
  2167. @xref{JTAG Commands}.
  2168. When you find a working sequence, it can be used to override
  2169. @command{jtag_init}, which fires during OpenOCD startup
  2170. (@pxref{Configuration Stage});
  2171. or @command{init_reset}, which fires during reset processing.
  2172. You might also want to provide some project-specific reset
  2173. schemes. For example, on a multi-target board the standard
  2174. @command{reset} command would reset all targets, but you
  2175. may need the ability to reset only one target at time and
  2176. thus want to avoid using the board-wide SRST signal.
  2177. @deffn {Overridable Procedure} init_reset mode
  2178. This is invoked near the beginning of the @command{reset} command,
  2179. usually to provide as much of a cold (power-up) reset as practical.
  2180. By default it is also invoked from @command{jtag_init} if
  2181. the scan chain does not respond to pure JTAG operations.
  2182. The @var{mode} parameter is the parameter given to the
  2183. low level reset command (@option{halt},
  2184. @option{init}, or @option{run}), @option{setup},
  2185. or potentially some other value.
  2186. The default implementation just invokes @command{jtag arp_init-reset}.
  2187. Replacements will normally build on low level JTAG
  2188. operations such as @command{jtag_reset}.
  2189. Operations here must not address individual TAPs
  2190. (or their associated targets)
  2191. until the JTAG scan chain has first been verified to work.
  2192. Implementations must have verified the JTAG scan chain before
  2193. they return.
  2194. This is done by calling @command{jtag arp_init}
  2195. (or @command{jtag arp_init-reset}).
  2196. @end deffn
  2197. @deffn Command {jtag arp_init}
  2198. This validates the scan chain using just the four
  2199. standard JTAG signals (TMS, TCK, TDI, TDO).
  2200. It starts by issuing a JTAG-only reset.
  2201. Then it performs checks to verify that the scan chain configuration
  2202. matches the TAPs it can observe.
  2203. Those checks include checking IDCODE values for each active TAP,
  2204. and verifying the length of their instruction registers using
  2205. TAP @code{-ircapture} and @code{-irmask} values.
  2206. If these tests all pass, TAP @code{setup} events are
  2207. issued to all TAPs with handlers for that event.
  2208. @end deffn
  2209. @deffn Command {jtag arp_init-reset}
  2210. This uses TRST and SRST to try resetting
  2211. everything on the JTAG scan chain
  2212. (and anything else connected to SRST).
  2213. It then invokes the logic of @command{jtag arp_init}.
  2214. @end deffn
  2215. @node TAP Declaration
  2216. @chapter TAP Declaration
  2217. @cindex TAP declaration
  2218. @cindex TAP configuration
  2219. @emph{Test Access Ports} (TAPs) are the core of JTAG.
  2220. TAPs serve many roles, including:
  2221. @itemize @bullet
  2222. @item @b{Debug Target} A CPU TAP can be used as a GDB debug target
  2223. @item @b{Flash Programing} Some chips program the flash directly via JTAG.
  2224. Others do it indirectly, making a CPU do it.
  2225. @item @b{Program Download} Using the same CPU support GDB uses,
  2226. you can initialize a DRAM controller, download code to DRAM, and then
  2227. start running that code.
  2228. @item @b{Boundary Scan} Most chips support boundary scan, which
  2229. helps test for board assembly problems like solder bridges
  2230. and missing connections
  2231. @end itemize
  2232. OpenOCD must know about the active TAPs on your board(s).
  2233. Setting up the TAPs is the core task of your configuration files.
  2234. Once those TAPs are set up, you can pass their names to code
  2235. which sets up CPUs and exports them as GDB targets,
  2236. probes flash memory, performs low-level JTAG operations, and more.
  2237. @section Scan Chains
  2238. @cindex scan chain
  2239. TAPs are part of a hardware @dfn{scan chain},
  2240. which is daisy chain of TAPs.
  2241. They also need to be added to
  2242. OpenOCD's software mirror of that hardware list,
  2243. giving each member a name and associating other data with it.
  2244. Simple scan chains, with a single TAP, are common in
  2245. systems with a single microcontroller or microprocessor.
  2246. More complex chips may have several TAPs internally.
  2247. Very complex scan chains might have a dozen or more TAPs:
  2248. several in one chip, more in the next, and connecting
  2249. to other boards with their own chips and TAPs.
  2250. You can display the list with the @command{scan_chain} command.
  2251. (Don't confuse this with the list displayed by the @command{targets}
  2252. command, presented in the next chapter.
  2253. That only displays TAPs for CPUs which are configured as
  2254. debugging targets.)
  2255. Here's what the scan chain might look like for a chip more than one TAP:
  2256. @verbatim
  2257. TapName Enabled IdCode Expected IrLen IrCap IrMask
  2258. -- ------------------ ------- ---------- ---------- ----- ----- ------
  2259. 0 omap5912.dsp Y 0x03df1d81 0x03df1d81 38 0x01 0x03
  2260. 1 omap5912.arm Y 0x0692602f 0x0692602f 4 0x01 0x0f
  2261. 2 omap5912.unknown Y 0x00000000 0x00000000 8 0x01 0x03
  2262. @end verbatim
  2263. OpenOCD can detect some of that information, but not all
  2264. of it. @xref{Autoprobing}.
  2265. Unfortunately those TAPs can't always be autoconfigured,
  2266. because not all devices provide good support for that.
  2267. JTAG doesn't require supporting IDCODE instructions, and
  2268. chips with JTAG routers may not link TAPs into the chain
  2269. until they are told to do so.
  2270. The configuration mechanism currently supported by OpenOCD
  2271. requires explicit configuration of all TAP devices using
  2272. @command{jtag newtap} commands, as detailed later in this chapter.
  2273. A command like this would declare one tap and name it @code{chip1.cpu}:
  2274. @example
  2275. jtag newtap chip1 cpu -irlen 4 -expected-id 0x3ba00477
  2276. @end example
  2277. Each target configuration file lists the TAPs provided
  2278. by a given chip.
  2279. Board configuration files combine all the targets on a board,
  2280. and so forth.
  2281. Note that @emph{the order in which TAPs are declared is very important.}
  2282. It must match the order in the JTAG scan chain, both inside
  2283. a single chip and between them.
  2284. @xref{FAQ TAP Order}.
  2285. For example, the ST Microsystems STR912 chip has
  2286. three separate TAPs@footnote{See the ST
  2287. document titled: @emph{STR91xFAxxx, Section 3.15 Jtag Interface, Page:
  2288. 28/102, Figure 3: JTAG chaining inside the STR91xFA}.
  2289. @url{http://eu.st.com/stonline/products/literature/ds/13495.pdf}}.
  2290. To configure those taps, @file{target/str912.cfg}
  2291. includes commands something like this:
  2292. @example
  2293. jtag newtap str912 flash ... params ...
  2294. jtag newtap str912 cpu ... params ...
  2295. jtag newtap str912 bs ... params ...
  2296. @end example
  2297. Actual config files use a variable instead of literals like
  2298. @option{str912}, to support more than one chip of each type.
  2299. @xref{Config File Guidelines}.
  2300. @deffn Command {jtag names}
  2301. Returns the names of all current TAPs in the scan chain.
  2302. Use @command{jtag cget} or @command{jtag tapisenabled}
  2303. to examine attributes and state of each TAP.
  2304. @example
  2305. foreach t [jtag names] @{
  2306. puts [format "TAP: %s\n" $t]
  2307. @}
  2308. @end example
  2309. @end deffn
  2310. @deffn Command {scan_chain}
  2311. Displays the TAPs in the scan chain configuration,
  2312. and their status.
  2313. The set of TAPs listed by this command is fixed by
  2314. exiting the OpenOCD configuration stage,
  2315. but systems with a JTAG router can
  2316. enable or disable TAPs dynamically.
  2317. @end deffn
  2318. @c FIXME! "jtag cget" should be able to return all TAP
  2319. @c attributes, like "$target_name cget" does for targets.
  2320. @c Probably want "jtag eventlist", and a "tap-reset" event
  2321. @c (on entry to RESET state).
  2322. @section TAP Names
  2323. @cindex dotted name
  2324. When TAP objects are declared with @command{jtag newtap},
  2325. a @dfn{dotted.name} is created for the TAP, combining the
  2326. name of a module (usually a chip) and a label for the TAP.
  2327. For example: @code{xilinx.tap}, @code{str912.flash},
  2328. @code{omap3530.jrc}, @code{dm6446.dsp}, or @code{stm32.cpu}.
  2329. Many other commands use that dotted.name to manipulate or
  2330. refer to the TAP. For example, CPU configuration uses the
  2331. name, as does declaration of NAND or NOR flash banks.
  2332. The components of a dotted name should follow ``C'' symbol
  2333. name rules: start with an alphabetic character, then numbers
  2334. and underscores are OK; while others (including dots!) are not.
  2335. @quotation Tip
  2336. In older code, JTAG TAPs were numbered from 0..N.
  2337. This feature is still present.
  2338. However its use is highly discouraged, and
  2339. should not be relied on; it will be removed by mid-2010.
  2340. Update all of your scripts to use TAP names rather than numbers,
  2341. by paying attention to the runtime warnings they trigger.
  2342. Using TAP numbers in target configuration scripts prevents
  2343. reusing those scripts on boards with multiple targets.
  2344. @end quotation
  2345. @section TAP Declaration Commands
  2346. @c shouldn't this be(come) a {Config Command}?
  2347. @anchor{jtag newtap}
  2348. @deffn Command {jtag newtap} chipname tapname configparams...
  2349. Declares a new TAP with the dotted name @var{chipname}.@var{tapname},
  2350. and configured according to the various @var{configparams}.
  2351. The @var{chipname} is a symbolic name for the chip.
  2352. Conventionally target config files use @code{$_CHIPNAME},
  2353. defaulting to the model name given by the chip vendor but
  2354. overridable.
  2355. @cindex TAP naming convention
  2356. The @var{tapname} reflects the role of that TAP,
  2357. and should follow this convention:
  2358. @itemize @bullet
  2359. @item @code{bs} -- For boundary scan if this is a seperate TAP;
  2360. @item @code{cpu} -- The main CPU of the chip, alternatively
  2361. @code{arm} and @code{dsp} on chips with both ARM and DSP CPUs,
  2362. @code{arm1} and @code{arm2} on chips two ARMs, and so forth;
  2363. @item @code{etb} -- For an embedded trace buffer (example: an ARM ETB11);
  2364. @item @code{flash} -- If the chip has a flash TAP, like the str912;
  2365. @item @code{jrc} -- For JTAG route controller (example: the ICEpick modules
  2366. on many Texas Instruments chips, like the OMAP3530 on Beagleboards);
  2367. @item @code{tap} -- Should be used only FPGA or CPLD like devices
  2368. with a single TAP;
  2369. @item @code{unknownN} -- If you have no idea what the TAP is for (N is a number);
  2370. @item @emph{when in doubt} -- Use the chip maker's name in their data sheet.
  2371. For example, the Freescale IMX31 has a SDMA (Smart DMA) with
  2372. a JTAG TAP; that TAP should be named @code{sdma}.
  2373. @end itemize
  2374. Every TAP requires at least the following @var{configparams}:
  2375. @itemize @bullet
  2376. @item @code{-irlen} @var{NUMBER}
  2377. @*The length in bits of the
  2378. instruction register, such as 4 or 5 bits.
  2379. @end itemize
  2380. A TAP may also provide optional @var{configparams}:
  2381. @itemize @bullet
  2382. @item @code{-disable} (or @code{-enable})
  2383. @*Use the @code{-disable} parameter to flag a TAP which is not
  2384. linked in to the scan chain after a reset using either TRST
  2385. or the JTAG state machine's @sc{reset} state.
  2386. You may use @code{-enable} to highlight the default state
  2387. (the TAP is linked in).
  2388. @xref{Enabling and Disabling TAPs}.
  2389. @item @code{-expected-id} @var{number}
  2390. @*A non-zero @var{number} represents a 32-bit IDCODE
  2391. which you expect to find when the scan chain is examined.
  2392. These codes are not required by all JTAG devices.
  2393. @emph{Repeat the option} as many times as required if more than one
  2394. ID code could appear (for example, multiple versions).
  2395. Specify @var{number} as zero to suppress warnings about IDCODE
  2396. values that were found but not included in the list.
  2397. Provide this value if at all possible, since it lets OpenOCD
  2398. tell when the scan chain it sees isn't right. These values
  2399. are provided in vendors' chip documentation, usually a technical
  2400. reference manual. Sometimes you may need to probe the JTAG
  2401. hardware to find these values.
  2402. @xref{Autoprobing}.
  2403. @item @code{-ignore-version}
  2404. @*Specify this to ignore the JTAG version field in the @code{-expected-id}
  2405. option. When vendors put out multiple versions of a chip, or use the same
  2406. JTAG-level ID for several largely-compatible chips, it may be more practical
  2407. to ignore the version field than to update config files to handle all of
  2408. the various chip IDs.
  2409. @item @code{-ircapture} @var{NUMBER}
  2410. @*The bit pattern loaded by the TAP into the JTAG shift register
  2411. on entry to the @sc{ircapture} state, such as 0x01.
  2412. JTAG requires the two LSBs of this value to be 01.
  2413. By default, @code{-ircapture} and @code{-irmask} are set
  2414. up to verify that two-bit value. You may provide
  2415. additional bits, if you know them, or indicate that
  2416. a TAP doesn't conform to the JTAG specification.
  2417. @item @code{-irmask} @var{NUMBER}
  2418. @*A mask used with @code{-ircapture}
  2419. to verify that instruction scans work correctly.
  2420. Such scans are not used by OpenOCD except to verify that
  2421. there seems to be no problems with JTAG scan chain operations.
  2422. @end itemize
  2423. @end deffn
  2424. @section Other TAP commands
  2425. @deffn Command {jtag cget} dotted.name @option{-event} name
  2426. @deffnx Command {jtag configure} dotted.name @option{-event} name string
  2427. At this writing this TAP attribute
  2428. mechanism is used only for event handling.
  2429. (It is not a direct analogue of the @code{cget}/@code{configure}
  2430. mechanism for debugger targets.)
  2431. See the next section for information about the available events.
  2432. The @code{configure} subcommand assigns an event handler,
  2433. a TCL string which is evaluated when the event is triggered.
  2434. The @code{cget} subcommand returns that handler.
  2435. @end deffn
  2436. @anchor{TAP Events}
  2437. @section TAP Events
  2438. @cindex events
  2439. @cindex TAP events
  2440. OpenOCD includes two event mechanisms.
  2441. The one presented here applies to all JTAG TAPs.
  2442. The other applies to debugger targets,
  2443. which are associated with certain TAPs.
  2444. The TAP events currently defined are:
  2445. @itemize @bullet
  2446. @item @b{post-reset}
  2447. @* The TAP has just completed a JTAG reset.
  2448. The tap may still be in the JTAG @sc{reset} state.
  2449. Handlers for these events might perform initialization sequences
  2450. such as issuing TCK cycles, TMS sequences to ensure
  2451. exit from the ARM SWD mode, and more.
  2452. Because the scan chain has not yet been verified, handlers for these events
  2453. @emph{should not issue commands which scan the JTAG IR or DR registers}
  2454. of any particular target.
  2455. @b{NOTE:} As this is written (September 2009), nothing prevents such access.
  2456. @item @b{setup}
  2457. @* The scan chain has been reset and verified.
  2458. This handler may enable TAPs as needed.
  2459. @item @b{tap-disable}
  2460. @* The TAP needs to be disabled. This handler should
  2461. implement @command{jtag tapdisable}
  2462. by issuing the relevant JTAG commands.
  2463. @item @b{tap-enable}
  2464. @* The TAP needs to be enabled. This handler should
  2465. implement @command{jtag tapenable}
  2466. by issuing the relevant JTAG commands.
  2467. @end itemize
  2468. If you need some action after each JTAG reset, which isn't actually
  2469. specific to any TAP (since you can't yet trust the scan chain's
  2470. contents to be accurate), you might:
  2471. @example
  2472. jtag configure CHIP.jrc -event post-reset @{
  2473. echo "JTAG Reset done"
  2474. ... non-scan jtag operations to be done after reset
  2475. @}
  2476. @end example
  2477. @anchor{Enabling and Disabling TAPs}
  2478. @section Enabling and Disabling TAPs
  2479. @cindex JTAG Route Controller
  2480. @cindex jrc
  2481. In some systems, a @dfn{JTAG Route Controller} (JRC)
  2482. is used to enable and/or disable specific JTAG TAPs.
  2483. Many ARM based chips from Texas Instruments include
  2484. an ``ICEpick'' module, which is a JRC.
  2485. Such chips include DaVinci and OMAP3 processors.
  2486. A given TAP may not be visible until the JRC has been
  2487. told to link it into the scan chain; and if the JRC
  2488. has been told to unlink that TAP, it will no longer
  2489. be visible.
  2490. Such routers address problems that JTAG ``bypass mode''
  2491. ignores, such as:
  2492. @itemize
  2493. @item The scan chain can only go as fast as its slowest TAP.
  2494. @item Having many TAPs slows instruction scans, since all
  2495. TAPs receive new instructions.
  2496. @item TAPs in the scan chain must be powered up, which wastes
  2497. power and prevents debugging some power management mechanisms.
  2498. @end itemize
  2499. The IEEE 1149.1 JTAG standard has no concept of a ``disabled'' tap,
  2500. as implied by the existence of JTAG routers.
  2501. However, the upcoming IEEE 1149.7 framework (layered on top of JTAG)
  2502. does include a kind of JTAG router functionality.
  2503. @c (a) currently the event handlers don't seem to be able to
  2504. @c fail in a way that could lead to no-change-of-state.
  2505. In OpenOCD, tap enabling/disabling is invoked by the Tcl commands
  2506. shown below, and is implemented using TAP event handlers.
  2507. So for example, when defining a TAP for a CPU connected to
  2508. a JTAG router, your @file{target.cfg} file
  2509. should define TAP event handlers using
  2510. code that looks something like this:
  2511. @example
  2512. jtag configure CHIP.cpu -event tap-enable @{
  2513. ... jtag operations using CHIP.jrc
  2514. @}
  2515. jtag configure CHIP.cpu -event tap-disable @{
  2516. ... jtag operations using CHIP.jrc
  2517. @}
  2518. @end example
  2519. Then you might want that CPU's TAP enabled almost all the time:
  2520. @example
  2521. jtag configure $CHIP.jrc -event setup "jtag tapenable $CHIP.cpu"
  2522. @end example
  2523. Note how that particular setup event handler declaration
  2524. uses quotes to evaluate @code{$CHIP} when the event is configured.
  2525. Using brackets @{ @} would cause it to be evaluated later,
  2526. at runtime, when it might have a different value.
  2527. @deffn Command {jtag tapdisable} dotted.name
  2528. If necessary, disables the tap
  2529. by sending it a @option{tap-disable} event.
  2530. Returns the string "1" if the tap
  2531. specified by @var{dotted.name} is enabled,
  2532. and "0" if it is disabled.
  2533. @end deffn
  2534. @deffn Command {jtag tapenable} dotted.name
  2535. If necessary, enables the tap
  2536. by sending it a @option{tap-enable} event.
  2537. Returns the string "1" if the tap
  2538. specified by @var{dotted.name} is enabled,
  2539. and "0" if it is disabled.
  2540. @end deffn
  2541. @deffn Command {jtag tapisenabled} dotted.name
  2542. Returns the string "1" if the tap
  2543. specified by @var{dotted.name} is enabled,
  2544. and "0" if it is disabled.
  2545. @quotation Note
  2546. Humans will find the @command{scan_chain} command more helpful
  2547. for querying the state of the JTAG taps.
  2548. @end quotation
  2549. @end deffn
  2550. @anchor{Autoprobing}
  2551. @section Autoprobing
  2552. @cindex autoprobe
  2553. @cindex JTAG autoprobe
  2554. TAP configuration is the first thing that needs to be done
  2555. after interface and reset configuration. Sometimes it's
  2556. hard finding out what TAPs exist, or how they are identified.
  2557. Vendor documentation is not always easy to find and use.
  2558. To help you get past such problems, OpenOCD has a limited
  2559. @emph{autoprobing} ability to look at the scan chain, doing
  2560. a @dfn{blind interrogation} and then reporting the TAPs it finds.
  2561. To use this mechanism, start the OpenOCD server with only data
  2562. that configures your JTAG interface, and arranges to come up
  2563. with a slow clock (many devices don't support fast JTAG clocks
  2564. right when they come out of reset).
  2565. For example, your @file{openocd.cfg} file might have:
  2566. @example
  2567. source [find interface/olimex-arm-usb-tiny-h.cfg]
  2568. reset_config trst_and_srst
  2569. jtag_rclk 8
  2570. @end example
  2571. When you start the server without any TAPs configured, it will
  2572. attempt to autoconfigure the TAPs. There are two parts to this:
  2573. @enumerate
  2574. @item @emph{TAP discovery} ...
  2575. After a JTAG reset (sometimes a system reset may be needed too),
  2576. each TAP's data registers will hold the contents of either the
  2577. IDCODE or BYPASS register.
  2578. If JTAG communication is working, OpenOCD will see each TAP,
  2579. and report what @option{-expected-id} to use with it.
  2580. @item @emph{IR Length discovery} ...
  2581. Unfortunately JTAG does not provide a reliable way to find out
  2582. the value of the @option{-irlen} parameter to use with a TAP
  2583. that is discovered.
  2584. If OpenOCD can discover the length of a TAP's instruction
  2585. register, it will report it.
  2586. Otherwise you may need to consult vendor documentation, such
  2587. as chip data sheets or BSDL files.
  2588. @end enumerate
  2589. In many cases your board will have a simple scan chain with just
  2590. a single device. Here's what OpenOCD reported with one board
  2591. that's a bit more complex:
  2592. @example
  2593. clock speed 8 kHz
  2594. There are no enabled taps. AUTO PROBING MIGHT NOT WORK!!
  2595. AUTO auto0.tap - use "jtag newtap auto0 tap -expected-id 0x2b900f0f ..."
  2596. AUTO auto1.tap - use "jtag newtap auto1 tap -expected-id 0x07926001 ..."
  2597. AUTO auto2.tap - use "jtag newtap auto2 tap -expected-id 0x0b73b02f ..."
  2598. AUTO auto0.tap - use "... -irlen 4"
  2599. AUTO auto1.tap - use "... -irlen 4"
  2600. AUTO auto2.tap - use "... -irlen 6"
  2601. no gdb ports allocated as no target has been specified
  2602. @end example
  2603. Given that information, you should be able to either find some existing
  2604. config files to use, or create your own. If you create your own, you
  2605. would configure from the bottom up: first a @file{target.cfg} file
  2606. with these TAPs, any targets associated with them, and any on-chip
  2607. resources; then a @file{board.cfg} with off-chip resources, clocking,
  2608. and so forth.
  2609. @node CPU Configuration
  2610. @chapter CPU Configuration
  2611. @cindex GDB target
  2612. This chapter discusses how to set up GDB debug targets for CPUs.
  2613. You can also access these targets without GDB
  2614. (@pxref{Architecture and Core Commands},
  2615. and @ref{Target State handling}) and
  2616. through various kinds of NAND and NOR flash commands.
  2617. If you have multiple CPUs you can have multiple such targets.
  2618. We'll start by looking at how to examine the targets you have,
  2619. then look at how to add one more target and how to configure it.
  2620. @section Target List
  2621. @cindex target, current
  2622. @cindex target, list
  2623. All targets that have been set up are part of a list,
  2624. where each member has a name.
  2625. That name should normally be the same as the TAP name.
  2626. You can display the list with the @command{targets}
  2627. (plural!) command.
  2628. This display often has only one CPU; here's what it might
  2629. look like with more than one:
  2630. @verbatim
  2631. TargetName Type Endian TapName State
  2632. -- ------------------ ---------- ------ ------------------ ------------
  2633. 0* at91rm9200.cpu arm920t little at91rm9200.cpu running
  2634. 1 MyTarget cortex_m3 little mychip.foo tap-disabled
  2635. @end verbatim
  2636. One member of that list is the @dfn{current target}, which
  2637. is implicitly referenced by many commands.
  2638. It's the one marked with a @code{*} near the target name.
  2639. In particular, memory addresses often refer to the address
  2640. space seen by that current target.
  2641. Commands like @command{mdw} (memory display words)
  2642. and @command{flash erase_address} (erase NOR flash blocks)
  2643. are examples; and there are many more.
  2644. Several commands let you examine the list of targets:
  2645. @deffn Command {target count}
  2646. @emph{Note: target numbers are deprecated; don't use them.
  2647. They will be removed shortly after August 2010, including this command.
  2648. Iterate target using @command{target names}, not by counting.}
  2649. Returns the number of targets, @math{N}.
  2650. The highest numbered target is @math{N - 1}.
  2651. @example
  2652. set c [target count]
  2653. for @{ set x 0 @} @{ $x < $c @} @{ incr x @} @{
  2654. # Assuming you have created this function
  2655. print_target_details $x
  2656. @}
  2657. @end example
  2658. @end deffn
  2659. @deffn Command {target current}
  2660. Returns the name of the current target.
  2661. @end deffn
  2662. @deffn Command {target names}
  2663. Lists the names of all current targets in the list.
  2664. @example
  2665. foreach t [target names] @{
  2666. puts [format "Target: %s\n" $t]
  2667. @}
  2668. @end example
  2669. @end deffn
  2670. @deffn Command {target number} number
  2671. @emph{Note: target numbers are deprecated; don't use them.
  2672. They will be removed shortly after August 2010, including this command.}
  2673. The list of targets is numbered starting at zero.
  2674. This command returns the name of the target at index @var{number}.
  2675. @example
  2676. set thename [target number $x]
  2677. puts [format "Target %d is: %s\n" $x $thename]
  2678. @end example
  2679. @end deffn
  2680. @c yep, "target list" would have been better.
  2681. @c plus maybe "target setdefault".
  2682. @deffn Command targets [name]
  2683. @emph{Note: the name of this command is plural. Other target
  2684. command names are singular.}
  2685. With no parameter, this command displays a table of all known
  2686. targets in a user friendly form.
  2687. With a parameter, this command sets the current target to
  2688. the given target with the given @var{name}; this is
  2689. only relevant on boards which have more than one target.
  2690. @end deffn
  2691. @section Target CPU Types and Variants
  2692. @cindex target type
  2693. @cindex CPU type
  2694. @cindex CPU variant
  2695. Each target has a @dfn{CPU type}, as shown in the output of
  2696. the @command{targets} command. You need to specify that type
  2697. when calling @command{target create}.
  2698. The CPU type indicates more than just the instruction set.
  2699. It also indicates how that instruction set is implemented,
  2700. what kind of debug support it integrates,
  2701. whether it has an MMU (and if so, what kind),
  2702. what core-specific commands may be available
  2703. (@pxref{Architecture and Core Commands}),
  2704. and more.
  2705. For some CPU types, OpenOCD also defines @dfn{variants} which
  2706. indicate differences that affect their handling.
  2707. For example, a particular implementation bug might need to be
  2708. worked around in some chip versions.
  2709. It's easy to see what target types are supported,
  2710. since there's a command to list them.
  2711. However, there is currently no way to list what target variants
  2712. are supported (other than by reading the OpenOCD source code).
  2713. @anchor{target types}
  2714. @deffn Command {target types}
  2715. Lists all supported target types.
  2716. At this writing, the supported CPU types and variants are:
  2717. @itemize @bullet
  2718. @item @code{arm11} -- this is a generation of ARMv6 cores
  2719. @item @code{arm720t} -- this is an ARMv4 core with an MMU
  2720. @item @code{arm7tdmi} -- this is an ARMv4 core
  2721. @item @code{arm920t} -- this is an ARMv5 core with an MMU
  2722. @item @code{arm926ejs} -- this is an ARMv5 core with an MMU
  2723. @item @code{arm966e} -- this is an ARMv5 core
  2724. @item @code{arm9tdmi} -- this is an ARMv4 core
  2725. @item @code{avr} -- implements Atmel's 8-bit AVR instruction set.
  2726. (Support for this is preliminary and incomplete.)
  2727. @item @code{cortex_a8} -- this is an ARMv7 core with an MMU
  2728. @item @code{cortex_m3} -- this is an ARMv7 core, supporting only the
  2729. compact Thumb2 instruction set. It supports one variant:
  2730. @itemize @minus
  2731. @item @code{lm3s} ... Use this when debugging older Stellaris LM3S targets.
  2732. This will cause OpenOCD to use a software reset rather than asserting
  2733. SRST, to avoid a issue with clearing the debug registers.
  2734. This is fixed in Fury Rev B, DustDevil Rev B, Tempest; these revisions will
  2735. be detected and the normal reset behaviour used.
  2736. @end itemize
  2737. @item @code{dragonite} -- resembles arm966e
  2738. @item @code{dsp563xx} -- implements Freescale's 24-bit DSP.
  2739. (Support for this is still incomplete.)
  2740. @item @code{fa526} -- resembles arm920 (w/o Thumb)
  2741. @item @code{feroceon} -- resembles arm926
  2742. @item @code{mips_m4k} -- a MIPS core. This supports one variant:
  2743. @itemize @minus
  2744. @item @code{ejtag_srst} ... Use this when debugging targets that do not
  2745. provide a functional SRST line on the EJTAG connector. This causes
  2746. OpenOCD to instead use an EJTAG software reset command to reset the
  2747. processor.
  2748. You still need to enable @option{srst} on the @command{reset_config}
  2749. command to enable OpenOCD hardware reset functionality.
  2750. @end itemize
  2751. @item @code{xscale} -- this is actually an architecture,
  2752. not a CPU type. It is based on the ARMv5 architecture.
  2753. There are several variants defined:
  2754. @itemize @minus
  2755. @item @code{ixp42x}, @code{ixp45x}, @code{ixp46x},
  2756. @code{pxa27x} ... instruction register length is 7 bits
  2757. @item @code{pxa250}, @code{pxa255},
  2758. @code{pxa26x} ... instruction register length is 5 bits
  2759. @item @code{pxa3xx} ... instruction register length is 11 bits
  2760. @end itemize
  2761. @end itemize
  2762. @end deffn
  2763. To avoid being confused by the variety of ARM based cores, remember
  2764. this key point: @emph{ARM is a technology licencing company}.
  2765. (See: @url{http://www.arm.com}.)
  2766. The CPU name used by OpenOCD will reflect the CPU design that was
  2767. licenced, not a vendor brand which incorporates that design.
  2768. Name prefixes like arm7, arm9, arm11, and cortex
  2769. reflect design generations;
  2770. while names like ARMv4, ARMv5, ARMv6, and ARMv7
  2771. reflect an architecture version implemented by a CPU design.
  2772. @anchor{Target Configuration}
  2773. @section Target Configuration
  2774. Before creating a ``target'', you must have added its TAP to the scan chain.
  2775. When you've added that TAP, you will have a @code{dotted.name}
  2776. which is used to set up the CPU support.
  2777. The chip-specific configuration file will normally configure its CPU(s)
  2778. right after it adds all of the chip's TAPs to the scan chain.
  2779. Although you can set up a target in one step, it's often clearer if you
  2780. use shorter commands and do it in two steps: create it, then configure
  2781. optional parts.
  2782. All operations on the target after it's created will use a new
  2783. command, created as part of target creation.
  2784. The two main things to configure after target creation are
  2785. a work area, which usually has target-specific defaults even
  2786. if the board setup code overrides them later;
  2787. and event handlers (@pxref{Target Events}), which tend
  2788. to be much more board-specific.
  2789. The key steps you use might look something like this
  2790. @example
  2791. target create MyTarget cortex_m3 -chain-position mychip.cpu
  2792. $MyTarget configure -work-area-phys 0x08000 -work-area-size 8096
  2793. $MyTarget configure -event reset-deassert-pre @{ jtag_rclk 5 @}
  2794. $MyTarget configure -event reset-init @{ myboard_reinit @}
  2795. @end example
  2796. You should specify a working area if you can; typically it uses some
  2797. on-chip SRAM.
  2798. Such a working area can speed up many things, including bulk
  2799. writes to target memory;
  2800. flash operations like checking to see if memory needs to be erased;
  2801. GDB memory checksumming;
  2802. and more.
  2803. @quotation Warning
  2804. On more complex chips, the work area can become
  2805. inaccessible when application code
  2806. (such as an operating system)
  2807. enables or disables the MMU.
  2808. For example, the particular MMU context used to acess the virtual
  2809. address will probably matter ... and that context might not have
  2810. easy access to other addresses needed.
  2811. At this writing, OpenOCD doesn't have much MMU intelligence.
  2812. @end quotation
  2813. It's often very useful to define a @code{reset-init} event handler.
  2814. For systems that are normally used with a boot loader,
  2815. common tasks include updating clocks and initializing memory
  2816. controllers.
  2817. That may be needed to let you write the boot loader into flash,
  2818. in order to ``de-brick'' your board; or to load programs into
  2819. external DDR memory without having run the boot loader.
  2820. @deffn Command {target create} target_name type configparams...
  2821. This command creates a GDB debug target that refers to a specific JTAG tap.
  2822. It enters that target into a list, and creates a new
  2823. command (@command{@var{target_name}}) which is used for various
  2824. purposes including additional configuration.
  2825. @itemize @bullet
  2826. @item @var{target_name} ... is the name of the debug target.
  2827. By convention this should be the same as the @emph{dotted.name}
  2828. of the TAP associated with this target, which must be specified here
  2829. using the @code{-chain-position @var{dotted.name}} configparam.
  2830. This name is also used to create the target object command,
  2831. referred to here as @command{$target_name},
  2832. and in other places the target needs to be identified.
  2833. @item @var{type} ... specifies the target type. @xref{target types}.
  2834. @item @var{configparams} ... all parameters accepted by
  2835. @command{$target_name configure} are permitted.
  2836. If the target is big-endian, set it here with @code{-endian big}.
  2837. If the variant matters, set it here with @code{-variant}.
  2838. You @emph{must} set the @code{-chain-position @var{dotted.name}} here.
  2839. @end itemize
  2840. @end deffn
  2841. @deffn Command {$target_name configure} configparams...
  2842. The options accepted by this command may also be
  2843. specified as parameters to @command{target create}.
  2844. Their values can later be queried one at a time by
  2845. using the @command{$target_name cget} command.
  2846. @emph{Warning:} changing some of these after setup is dangerous.
  2847. For example, moving a target from one TAP to another;
  2848. and changing its endianness or variant.
  2849. @itemize @bullet
  2850. @item @code{-chain-position} @var{dotted.name} -- names the TAP
  2851. used to access this target.
  2852. @item @code{-endian} (@option{big}|@option{little}) -- specifies
  2853. whether the CPU uses big or little endian conventions
  2854. @item @code{-event} @var{event_name} @var{event_body} --
  2855. @xref{Target Events}.
  2856. Note that this updates a list of named event handlers.
  2857. Calling this twice with two different event names assigns
  2858. two different handlers, but calling it twice with the
  2859. same event name assigns only one handler.
  2860. @item @code{-variant} @var{name} -- specifies a variant of the target,
  2861. which OpenOCD needs to know about.
  2862. @item @code{-work-area-backup} (@option{0}|@option{1}) -- says
  2863. whether the work area gets backed up; by default,
  2864. @emph{it is not backed up.}
  2865. When possible, use a working_area that doesn't need to be backed up,
  2866. since performing a backup slows down operations.
  2867. For example, the beginning of an SRAM block is likely to
  2868. be used by most build systems, but the end is often unused.
  2869. @item @code{-work-area-size} @var{size} -- specify work are size,
  2870. in bytes. The same size applies regardless of whether its physical
  2871. or virtual address is being used.
  2872. @item @code{-work-area-phys} @var{address} -- set the work area
  2873. base @var{address} to be used when no MMU is active.
  2874. @item @code{-work-area-virt} @var{address} -- set the work area
  2875. base @var{address} to be used when an MMU is active.
  2876. @emph{Do not specify a value for this except on targets with an MMU.}
  2877. The value should normally correspond to a static mapping for the
  2878. @code{-work-area-phys} address, set up by the current operating system.
  2879. @end itemize
  2880. @end deffn
  2881. @section Other $target_name Commands
  2882. @cindex object command
  2883. The Tcl/Tk language has the concept of object commands,
  2884. and OpenOCD adopts that same model for targets.
  2885. A good Tk example is a on screen button.
  2886. Once a button is created a button
  2887. has a name (a path in Tk terms) and that name is useable as a first
  2888. class command. For example in Tk, one can create a button and later
  2889. configure it like this:
  2890. @example
  2891. # Create
  2892. button .foobar -background red -command @{ foo @}
  2893. # Modify
  2894. .foobar configure -foreground blue
  2895. # Query
  2896. set x [.foobar cget -background]
  2897. # Report
  2898. puts [format "The button is %s" $x]
  2899. @end example
  2900. In OpenOCD's terms, the ``target'' is an object just like a Tcl/Tk
  2901. button, and its object commands are invoked the same way.
  2902. @example
  2903. str912.cpu mww 0x1234 0x42
  2904. omap3530.cpu mww 0x5555 123
  2905. @end example
  2906. The commands supported by OpenOCD target objects are:
  2907. @deffn Command {$target_name arp_examine}
  2908. @deffnx Command {$target_name arp_halt}
  2909. @deffnx Command {$target_name arp_poll}
  2910. @deffnx Command {$target_name arp_reset}
  2911. @deffnx Command {$target_name arp_waitstate}
  2912. Internal OpenOCD scripts (most notably @file{startup.tcl})
  2913. use these to deal with specific reset cases.
  2914. They are not otherwise documented here.
  2915. @end deffn
  2916. @deffn Command {$target_name array2mem} arrayname width address count
  2917. @deffnx Command {$target_name mem2array} arrayname width address count
  2918. These provide an efficient script-oriented interface to memory.
  2919. The @code{array2mem} primitive writes bytes, halfwords, or words;
  2920. while @code{mem2array} reads them.
  2921. In both cases, the TCL side uses an array, and
  2922. the target side uses raw memory.
  2923. The efficiency comes from enabling the use of
  2924. bulk JTAG data transfer operations.
  2925. The script orientation comes from working with data
  2926. values that are packaged for use by TCL scripts;
  2927. @command{mdw} type primitives only print data they retrieve,
  2928. and neither store nor return those values.
  2929. @itemize
  2930. @item @var{arrayname} ... is the name of an array variable
  2931. @item @var{width} ... is 8/16/32 - indicating the memory access size
  2932. @item @var{address} ... is the target memory address
  2933. @item @var{count} ... is the number of elements to process
  2934. @end itemize
  2935. @end deffn
  2936. @deffn Command {$target_name cget} queryparm
  2937. Each configuration parameter accepted by
  2938. @command{$target_name configure}
  2939. can be individually queried, to return its current value.
  2940. The @var{queryparm} is a parameter name
  2941. accepted by that command, such as @code{-work-area-phys}.
  2942. There are a few special cases:
  2943. @itemize @bullet
  2944. @item @code{-event} @var{event_name} -- returns the handler for the
  2945. event named @var{event_name}.
  2946. This is a special case because setting a handler requires
  2947. two parameters.
  2948. @item @code{-type} -- returns the target type.
  2949. This is a special case because this is set using
  2950. @command{target create} and can't be changed
  2951. using @command{$target_name configure}.
  2952. @end itemize
  2953. For example, if you wanted to summarize information about
  2954. all the targets you might use something like this:
  2955. @example
  2956. foreach name [target names] @{
  2957. set y [$name cget -endian]
  2958. set z [$name cget -type]
  2959. puts [format "Chip %d is %s, Endian: %s, type: %s" \
  2960. $x $name $y $z]
  2961. @}
  2962. @end example
  2963. @end deffn
  2964. @anchor{target curstate}
  2965. @deffn Command {$target_name curstate}
  2966. Displays the current target state:
  2967. @code{debug-running},
  2968. @code{halted},
  2969. @code{reset},
  2970. @code{running}, or @code{unknown}.
  2971. (Also, @pxref{Event Polling}.)
  2972. @end deffn
  2973. @deffn Command {$target_name eventlist}
  2974. Displays a table listing all event handlers
  2975. currently associated with this target.
  2976. @xref{Target Events}.
  2977. @end deffn
  2978. @deffn Command {$target_name invoke-event} event_name
  2979. Invokes the handler for the event named @var{event_name}.
  2980. (This is primarily intended for use by OpenOCD framework
  2981. code, for example by the reset code in @file{startup.tcl}.)
  2982. @end deffn
  2983. @deffn Command {$target_name mdw} addr [count]
  2984. @deffnx Command {$target_name mdh} addr [count]
  2985. @deffnx Command {$target_name mdb} addr [count]
  2986. Display contents of address @var{addr}, as
  2987. 32-bit words (@command{mdw}), 16-bit halfwords (@command{mdh}),
  2988. or 8-bit bytes (@command{mdb}).
  2989. If @var{count} is specified, displays that many units.
  2990. (If you want to manipulate the data instead of displaying it,
  2991. see the @code{mem2array} primitives.)
  2992. @end deffn
  2993. @deffn Command {$target_name mww} addr word
  2994. @deffnx Command {$target_name mwh} addr halfword
  2995. @deffnx Command {$target_name mwb} addr byte
  2996. Writes the specified @var{word} (32 bits),
  2997. @var{halfword} (16 bits), or @var{byte} (8-bit) pattern,
  2998. at the specified address @var{addr}.
  2999. @end deffn
  3000. @anchor{Target Events}
  3001. @section Target Events
  3002. @cindex target events
  3003. @cindex events
  3004. At various times, certain things can happen, or you want them to happen.
  3005. For example:
  3006. @itemize @bullet
  3007. @item What should happen when GDB connects? Should your target reset?
  3008. @item When GDB tries to flash the target, do you need to enable the flash via a special command?
  3009. @item Is using SRST appropriate (and possible) on your system?
  3010. Or instead of that, do you need to issue JTAG commands to trigger reset?
  3011. SRST usually resets everything on the scan chain, which can be inappropriate.
  3012. @item During reset, do you need to write to certain memory locations
  3013. to set up system clocks or
  3014. to reconfigure the SDRAM?
  3015. How about configuring the watchdog timer, or other peripherals,
  3016. to stop running while you hold the core stopped for debugging?
  3017. @end itemize
  3018. All of the above items can be addressed by target event handlers.
  3019. These are set up by @command{$target_name configure -event} or
  3020. @command{target create ... -event}.
  3021. The programmer's model matches the @code{-command} option used in Tcl/Tk
  3022. buttons and events. The two examples below act the same, but one creates
  3023. and invokes a small procedure while the other inlines it.
  3024. @example
  3025. proc my_attach_proc @{ @} @{
  3026. echo "Reset..."
  3027. reset halt
  3028. @}
  3029. mychip.cpu configure -event gdb-attach my_attach_proc
  3030. mychip.cpu configure -event gdb-attach @{
  3031. echo "Reset..."
  3032. reset halt
  3033. @}
  3034. @end example
  3035. The following target events are defined:
  3036. @itemize @bullet
  3037. @item @b{debug-halted}
  3038. @* The target has halted for debug reasons (i.e.: breakpoint)
  3039. @item @b{debug-resumed}
  3040. @* The target has resumed (i.e.: gdb said run)
  3041. @item @b{early-halted}
  3042. @* Occurs early in the halt process
  3043. @ignore
  3044. @item @b{examine-end}
  3045. @* Currently not used (goal: when JTAG examine completes)
  3046. @item @b{examine-start}
  3047. @* Currently not used (goal: when JTAG examine starts)
  3048. @end ignore
  3049. @item @b{gdb-attach}
  3050. @* When GDB connects
  3051. @item @b{gdb-detach}
  3052. @* When GDB disconnects
  3053. @item @b{gdb-end}
  3054. @* When the target has halted and GDB is not doing anything (see early halt)
  3055. @item @b{gdb-flash-erase-start}
  3056. @* Before the GDB flash process tries to erase the flash
  3057. @item @b{gdb-flash-erase-end}
  3058. @* After the GDB flash process has finished erasing the flash
  3059. @item @b{gdb-flash-write-start}
  3060. @* Before GDB writes to the flash
  3061. @item @b{gdb-flash-write-end}
  3062. @* After GDB writes to the flash
  3063. @item @b{gdb-start}
  3064. @* Before the target steps, gdb is trying to start/resume the target
  3065. @item @b{halted}
  3066. @* The target has halted
  3067. @ignore
  3068. @item @b{old-gdb_program_config}
  3069. @* DO NOT USE THIS: Used internally
  3070. @item @b{old-pre_resume}
  3071. @* DO NOT USE THIS: Used internally
  3072. @end ignore
  3073. @item @b{reset-assert-pre}
  3074. @* Issued as part of @command{reset} processing
  3075. after @command{reset_init} was triggered
  3076. but before either SRST alone is re-asserted on the scan chain,
  3077. or @code{reset-assert} is triggered.
  3078. @item @b{reset-assert}
  3079. @* Issued as part of @command{reset} processing
  3080. after @command{reset-assert-pre} was triggered.
  3081. When such a handler is present, cores which support this event will use
  3082. it instead of asserting SRST.
  3083. This support is essential for debugging with JTAG interfaces which
  3084. don't include an SRST line (JTAG doesn't require SRST), and for
  3085. selective reset on scan chains that have multiple targets.
  3086. @item @b{reset-assert-post}
  3087. @* Issued as part of @command{reset} processing
  3088. after @code{reset-assert} has been triggered.
  3089. or the target asserted SRST on the entire scan chain.
  3090. @item @b{reset-deassert-pre}
  3091. @* Issued as part of @command{reset} processing
  3092. after @code{reset-assert-post} has been triggered.
  3093. @item @b{reset-deassert-post}
  3094. @* Issued as part of @command{reset} processing
  3095. after @code{reset-deassert-pre} has been triggered
  3096. and (if the target is using it) after SRST has been
  3097. released on the scan chain.
  3098. @item @b{reset-end}
  3099. @* Issued as the final step in @command{reset} processing.
  3100. @ignore
  3101. @item @b{reset-halt-post}
  3102. @* Currently not used
  3103. @item @b{reset-halt-pre}
  3104. @* Currently not used
  3105. @end ignore
  3106. @item @b{reset-init}
  3107. @* Used by @b{reset init} command for board-specific initialization.
  3108. This event fires after @emph{reset-deassert-post}.
  3109. This is where you would configure PLLs and clocking, set up DRAM so
  3110. you can download programs that don't fit in on-chip SRAM, set up pin
  3111. multiplexing, and so on.
  3112. (You may be able to switch to a fast JTAG clock rate here, after
  3113. the target clocks are fully set up.)
  3114. @item @b{reset-start}
  3115. @* Issued as part of @command{reset} processing
  3116. before @command{reset_init} is called.
  3117. This is the most robust place to use @command{jtag_rclk}
  3118. or @command{jtag_khz} to switch to a low JTAG clock rate,
  3119. when reset disables PLLs needed to use a fast clock.
  3120. @ignore
  3121. @item @b{reset-wait-pos}
  3122. @* Currently not used
  3123. @item @b{reset-wait-pre}
  3124. @* Currently not used
  3125. @end ignore
  3126. @item @b{resume-start}
  3127. @* Before any target is resumed
  3128. @item @b{resume-end}
  3129. @* After all targets have resumed
  3130. @item @b{resume-ok}
  3131. @* Success
  3132. @item @b{resumed}
  3133. @* Target has resumed
  3134. @end itemize
  3135. @node Flash Commands
  3136. @chapter Flash Commands
  3137. OpenOCD has different commands for NOR and NAND flash;
  3138. the ``flash'' command works with NOR flash, while
  3139. the ``nand'' command works with NAND flash.
  3140. This partially reflects different hardware technologies:
  3141. NOR flash usually supports direct CPU instruction and data bus access,
  3142. while data from a NAND flash must be copied to memory before it can be
  3143. used. (SPI flash must also be copied to memory before use.)
  3144. However, the documentation also uses ``flash'' as a generic term;
  3145. for example, ``Put flash configuration in board-specific files''.
  3146. Flash Steps:
  3147. @enumerate
  3148. @item Configure via the command @command{flash bank}
  3149. @* Do this in a board-specific configuration file,
  3150. passing parameters as needed by the driver.
  3151. @item Operate on the flash via @command{flash subcommand}
  3152. @* Often commands to manipulate the flash are typed by a human, or run
  3153. via a script in some automated way. Common tasks include writing a
  3154. boot loader, operating system, or other data.
  3155. @item GDB Flashing
  3156. @* Flashing via GDB requires the flash be configured via ``flash
  3157. bank'', and the GDB flash features be enabled.
  3158. @xref{GDB Configuration}.
  3159. @end enumerate
  3160. Many CPUs have the ablity to ``boot'' from the first flash bank.
  3161. This means that misprogramming that bank can ``brick'' a system,
  3162. so that it can't boot.
  3163. JTAG tools, like OpenOCD, are often then used to ``de-brick'' the
  3164. board by (re)installing working boot firmware.
  3165. @anchor{NOR Configuration}
  3166. @section Flash Configuration Commands
  3167. @cindex flash configuration
  3168. @deffn {Config Command} {flash bank} name driver base size chip_width bus_width target [driver_options]
  3169. Configures a flash bank which provides persistent storage
  3170. for addresses from @math{base} to @math{base + size - 1}.
  3171. These banks will often be visible to GDB through the target's memory map.
  3172. In some cases, configuring a flash bank will activate extra commands;
  3173. see the driver-specific documentation.
  3174. @itemize @bullet
  3175. @item @var{name} ... may be used to reference the flash bank
  3176. in other flash commands. A number is also available.
  3177. @item @var{driver} ... identifies the controller driver
  3178. associated with the flash bank being declared.
  3179. This is usually @code{cfi} for external flash, or else
  3180. the name of a microcontroller with embedded flash memory.
  3181. @xref{Flash Driver List}.
  3182. @item @var{base} ... Base address of the flash chip.
  3183. @item @var{size} ... Size of the chip, in bytes.
  3184. For some drivers, this value is detected from the hardware.
  3185. @item @var{chip_width} ... Width of the flash chip, in bytes;
  3186. ignored for most microcontroller drivers.
  3187. @item @var{bus_width} ... Width of the data bus used to access the
  3188. chip, in bytes; ignored for most microcontroller drivers.
  3189. @item @var{target} ... Names the target used to issue
  3190. commands to the flash controller.
  3191. @comment Actually, it's currently a controller-specific parameter...
  3192. @item @var{driver_options} ... drivers may support, or require,
  3193. additional parameters. See the driver-specific documentation
  3194. for more information.
  3195. @end itemize
  3196. @quotation Note
  3197. This command is not available after OpenOCD initialization has completed.
  3198. Use it in board specific configuration files, not interactively.
  3199. @end quotation
  3200. @end deffn
  3201. @comment the REAL name for this command is "ocd_flash_banks"
  3202. @comment less confusing would be: "flash list" (like "nand list")
  3203. @deffn Command {flash banks}
  3204. Prints a one-line summary of each device that was
  3205. declared using @command{flash bank}, numbered from zero.
  3206. Note that this is the @emph{plural} form;
  3207. the @emph{singular} form is a very different command.
  3208. @end deffn
  3209. @deffn Command {flash list}
  3210. Retrieves a list of associative arrays for each device that was
  3211. declared using @command{flash bank}, numbered from zero.
  3212. This returned list can be manipulated easily from within scripts.
  3213. @end deffn
  3214. @deffn Command {flash probe} num
  3215. Identify the flash, or validate the parameters of the configured flash. Operation
  3216. depends on the flash type.
  3217. The @var{num} parameter is a value shown by @command{flash banks}.
  3218. Most flash commands will implicitly @emph{autoprobe} the bank;
  3219. flash drivers can distinguish between probing and autoprobing,
  3220. but most don't bother.
  3221. @end deffn
  3222. @section Erasing, Reading, Writing to Flash
  3223. @cindex flash erasing
  3224. @cindex flash reading
  3225. @cindex flash writing
  3226. @cindex flash programming
  3227. One feature distinguishing NOR flash from NAND or serial flash technologies
  3228. is that for read access, it acts exactly like any other addressible memory.
  3229. This means you can use normal memory read commands like @command{mdw} or
  3230. @command{dump_image} with it, with no special @command{flash} subcommands.
  3231. @xref{Memory access}, and @ref{Image access}.
  3232. Write access works differently. Flash memory normally needs to be erased
  3233. before it's written. Erasing a sector turns all of its bits to ones, and
  3234. writing can turn ones into zeroes. This is why there are special commands
  3235. for interactive erasing and writing, and why GDB needs to know which parts
  3236. of the address space hold NOR flash memory.
  3237. @quotation Note
  3238. Most of these erase and write commands leverage the fact that NOR flash
  3239. chips consume target address space. They implicitly refer to the current
  3240. JTAG target, and map from an address in that target's address space
  3241. back to a flash bank.
  3242. @comment In May 2009, those mappings may fail if any bank associated
  3243. @comment with that target doesn't succesfuly autoprobe ... bug worth fixing?
  3244. A few commands use abstract addressing based on bank and sector numbers,
  3245. and don't depend on searching the current target and its address space.
  3246. Avoid confusing the two command models.
  3247. @end quotation
  3248. Some flash chips implement software protection against accidental writes,
  3249. since such buggy writes could in some cases ``brick'' a system.
  3250. For such systems, erasing and writing may require sector protection to be
  3251. disabled first.
  3252. Examples include CFI flash such as ``Intel Advanced Bootblock flash'',
  3253. and AT91SAM7 on-chip flash.
  3254. @xref{flash protect}.
  3255. @anchor{flash erase_sector}
  3256. @deffn Command {flash erase_sector} num first last
  3257. Erase sectors in bank @var{num}, starting at sector @var{first}
  3258. up to and including @var{last}.
  3259. Sector numbering starts at 0.
  3260. Providing a @var{last} sector of @option{last}
  3261. specifies "to the end of the flash bank".
  3262. The @var{num} parameter is a value shown by @command{flash banks}.
  3263. @end deffn
  3264. @deffn Command {flash erase_address} [@option{pad}] address length
  3265. Erase sectors starting at @var{address} for @var{length} bytes.
  3266. Unless @option{pad} is specified, @math{address} must begin a
  3267. flash sector, and @math{address + length - 1} must end a sector.
  3268. Specifying @option{pad} erases extra data at the beginning and/or
  3269. end of the specified region, as needed to erase only full sectors.
  3270. The flash bank to use is inferred from the @var{address}, and
  3271. the specified length must stay within that bank.
  3272. As a special case, when @var{length} is zero and @var{address} is
  3273. the start of the bank, the whole flash is erased.
  3274. @end deffn
  3275. @deffn Command {flash fillw} address word length
  3276. @deffnx Command {flash fillh} address halfword length
  3277. @deffnx Command {flash fillb} address byte length
  3278. Fills flash memory with the specified @var{word} (32 bits),
  3279. @var{halfword} (16 bits), or @var{byte} (8-bit) pattern,
  3280. starting at @var{address} and continuing
  3281. for @var{length} units (word/halfword/byte).
  3282. No erasure is done before writing; when needed, that must be done
  3283. before issuing this command.
  3284. Writes are done in blocks of up to 1024 bytes, and each write is
  3285. verified by reading back the data and comparing it to what was written.
  3286. The flash bank to use is inferred from the @var{address} of
  3287. each block, and the specified length must stay within that bank.
  3288. @end deffn
  3289. @comment no current checks for errors if fill blocks touch multiple banks!
  3290. @anchor{flash write_bank}
  3291. @deffn Command {flash write_bank} num filename offset
  3292. Write the binary @file{filename} to flash bank @var{num},
  3293. starting at @var{offset} bytes from the beginning of the bank.
  3294. The @var{num} parameter is a value shown by @command{flash banks}.
  3295. @end deffn
  3296. @anchor{flash write_image}
  3297. @deffn Command {flash write_image} [erase] [unlock] filename [offset] [type]
  3298. Write the image @file{filename} to the current target's flash bank(s).
  3299. A relocation @var{offset} may be specified, in which case it is added
  3300. to the base address for each section in the image.
  3301. The file [@var{type}] can be specified
  3302. explicitly as @option{bin} (binary), @option{ihex} (Intel hex),
  3303. @option{elf} (ELF file), @option{s19} (Motorola s19).
  3304. @option{mem}, or @option{builder}.
  3305. The relevant flash sectors will be erased prior to programming
  3306. if the @option{erase} parameter is given. If @option{unlock} is
  3307. provided, then the flash banks are unlocked before erase and
  3308. program. The flash bank to use is inferred from the address of
  3309. each image section.
  3310. @quotation Warning
  3311. Be careful using the @option{erase} flag when the flash is holding
  3312. data you want to preserve.
  3313. Portions of the flash outside those described in the image's
  3314. sections might be erased with no notice.
  3315. @itemize
  3316. @item
  3317. When a section of the image being written does not fill out all the
  3318. sectors it uses, the unwritten parts of those sectors are necessarily
  3319. also erased, because sectors can't be partially erased.
  3320. @item
  3321. Data stored in sector "holes" between image sections are also affected.
  3322. For example, "@command{flash write_image erase ...}" of an image with
  3323. one byte at the beginning of a flash bank and one byte at the end
  3324. erases the entire bank -- not just the two sectors being written.
  3325. @end itemize
  3326. Also, when flash protection is important, you must re-apply it after
  3327. it has been removed by the @option{unlock} flag.
  3328. @end quotation
  3329. @end deffn
  3330. @section Other Flash commands
  3331. @cindex flash protection
  3332. @deffn Command {flash erase_check} num
  3333. Check erase state of sectors in flash bank @var{num},
  3334. and display that status.
  3335. The @var{num} parameter is a value shown by @command{flash banks}.
  3336. This is the only operation that
  3337. updates the erase state information displayed by @option{flash info}. That means you have
  3338. to issue a @command{flash erase_check} command after erasing or programming the device
  3339. to get updated information.
  3340. (Code execution may have invalidated any state records kept by OpenOCD.)
  3341. @end deffn
  3342. @deffn Command {flash info} num
  3343. Print info about flash bank @var{num}
  3344. The @var{num} parameter is a value shown by @command{flash banks}.
  3345. The information includes per-sector protect status.
  3346. @end deffn
  3347. @anchor{flash protect}
  3348. @deffn Command {flash protect} num first last (@option{on}|@option{off})
  3349. Enable (@option{on}) or disable (@option{off}) protection of flash sectors
  3350. in flash bank @var{num}, starting at sector @var{first}
  3351. and continuing up to and including @var{last}.
  3352. Providing a @var{last} sector of @option{last}
  3353. specifies "to the end of the flash bank".
  3354. The @var{num} parameter is a value shown by @command{flash banks}.
  3355. @end deffn
  3356. @deffn Command {flash protect_check} num
  3357. Check protection state of sectors in flash bank @var{num}.
  3358. The @var{num} parameter is a value shown by @command{flash banks}.
  3359. @comment @option{flash erase_sector} using the same syntax.
  3360. @end deffn
  3361. @anchor{Flash Driver List}
  3362. @section Flash Driver List
  3363. As noted above, the @command{flash bank} command requires a driver name,
  3364. and allows driver-specific options and behaviors.
  3365. Some drivers also activate driver-specific commands.
  3366. @subsection External Flash
  3367. @deffn {Flash Driver} cfi
  3368. @cindex Common Flash Interface
  3369. @cindex CFI
  3370. The ``Common Flash Interface'' (CFI) is the main standard for
  3371. external NOR flash chips, each of which connects to a
  3372. specific external chip select on the CPU.
  3373. Frequently the first such chip is used to boot the system.
  3374. Your board's @code{reset-init} handler might need to
  3375. configure additional chip selects using other commands (like: @command{mww} to
  3376. configure a bus and its timings), or
  3377. perhaps configure a GPIO pin that controls the ``write protect'' pin
  3378. on the flash chip.
  3379. The CFI driver can use a target-specific working area to significantly
  3380. speed up operation.
  3381. The CFI driver can accept the following optional parameters, in any order:
  3382. @itemize
  3383. @item @var{jedec_probe} ... is used to detect certain non-CFI flash ROMs,
  3384. like AM29LV010 and similar types.
  3385. @item @var{x16_as_x8} ... when a 16-bit flash is hooked up to an 8-bit bus.
  3386. @end itemize
  3387. To configure two adjacent banks of 16 MBytes each, both sixteen bits (two bytes)
  3388. wide on a sixteen bit bus:
  3389. @example
  3390. flash bank cfi 0x00000000 0x01000000 2 2 $_TARGETNAME
  3391. flash bank cfi 0x01000000 0x01000000 2 2 $_TARGETNAME
  3392. @end example
  3393. To configure one bank of 32 MBytes
  3394. built from two sixteen bit (two byte) wide parts wired in parallel
  3395. to create a thirty-two bit (four byte) bus with doubled throughput:
  3396. @example
  3397. flash bank cfi 0x00000000 0x02000000 2 4 $_TARGETNAME
  3398. @end example
  3399. @c "cfi part_id" disabled
  3400. @end deffn
  3401. @subsection Internal Flash (Microcontrollers)
  3402. @deffn {Flash Driver} aduc702x
  3403. The ADUC702x analog microcontrollers from Analog Devices
  3404. include internal flash and use ARM7TDMI cores.
  3405. The aduc702x flash driver works with models ADUC7019 through ADUC7028.
  3406. The setup command only requires the @var{target} argument
  3407. since all devices in this family have the same memory layout.
  3408. @example
  3409. flash bank aduc702x 0 0 0 0 $_TARGETNAME
  3410. @end example
  3411. @end deffn
  3412. @deffn {Flash Driver} at91sam3
  3413. @cindex at91sam3
  3414. All members of the AT91SAM3 microcontroller family from
  3415. Atmel include internal flash and use ARM's Cortex-M3 core. The driver
  3416. currently (6/22/09) recognizes the AT91SAM3U[1/2/4][C/E] chips. Note
  3417. that the driver was orginaly developed and tested using the
  3418. AT91SAM3U4E, using a SAM3U-EK eval board. Support for other chips in
  3419. the family was cribbed from the data sheet. @emph{Note to future
  3420. readers/updaters: Please remove this worrysome comment after other
  3421. chips are confirmed.}
  3422. The AT91SAM3U4[E/C] (256K) chips have two flash banks; most other chips
  3423. have one flash bank. In all cases the flash banks are at
  3424. the following fixed locations:
  3425. @example
  3426. # Flash bank 0 - all chips
  3427. flash bank at91sam3 0x00080000 0 1 1 $_TARGETNAME
  3428. # Flash bank 1 - only 256K chips
  3429. flash bank at91sam3 0x00100000 0 1 1 $_TARGETNAME
  3430. @end example
  3431. Internally, the AT91SAM3 flash memory is organized as follows.
  3432. Unlike the AT91SAM7 chips, these are not used as parameters
  3433. to the @command{flash bank} command:
  3434. @itemize
  3435. @item @emph{N-Banks:} 256K chips have 2 banks, others have 1 bank.
  3436. @item @emph{Bank Size:} 128K/64K Per flash bank
  3437. @item @emph{Sectors:} 16 or 8 per bank
  3438. @item @emph{SectorSize:} 8K Per Sector
  3439. @item @emph{PageSize:} 256 bytes per page. Note that OpenOCD operates on 'sector' sizes, not page sizes.
  3440. @end itemize
  3441. The AT91SAM3 driver adds some additional commands:
  3442. @deffn Command {at91sam3 gpnvm}
  3443. @deffnx Command {at91sam3 gpnvm clear} number
  3444. @deffnx Command {at91sam3 gpnvm set} number
  3445. @deffnx Command {at91sam3 gpnvm show} [@option{all}|number]
  3446. With no parameters, @command{show} or @command{show all},
  3447. shows the status of all GPNVM bits.
  3448. With @command{show} @var{number}, displays that bit.
  3449. With @command{set} @var{number} or @command{clear} @var{number},
  3450. modifies that GPNVM bit.
  3451. @end deffn
  3452. @deffn Command {at91sam3 info}
  3453. This command attempts to display information about the AT91SAM3
  3454. chip. @emph{First} it read the @code{CHIPID_CIDR} [address 0x400e0740, see
  3455. Section 28.2.1, page 505 of the AT91SAM3U 29/may/2009 datasheet,
  3456. document id: doc6430A] and decodes the values. @emph{Second} it reads the
  3457. various clock configuration registers and attempts to display how it
  3458. believes the chip is configured. By default, the SLOWCLK is assumed to
  3459. be 32768 Hz, see the command @command{at91sam3 slowclk}.
  3460. @end deffn
  3461. @deffn Command {at91sam3 slowclk} [value]
  3462. This command shows/sets the slow clock frequency used in the
  3463. @command{at91sam3 info} command calculations above.
  3464. @end deffn
  3465. @end deffn
  3466. @deffn {Flash Driver} at91sam7
  3467. All members of the AT91SAM7 microcontroller family from Atmel include
  3468. internal flash and use ARM7TDMI cores. The driver automatically
  3469. recognizes a number of these chips using the chip identification
  3470. register, and autoconfigures itself.
  3471. @example
  3472. flash bank at91sam7 0 0 0 0 $_TARGETNAME
  3473. @end example
  3474. For chips which are not recognized by the controller driver, you must
  3475. provide additional parameters in the following order:
  3476. @itemize
  3477. @item @var{chip_model} ... label used with @command{flash info}
  3478. @item @var{banks}
  3479. @item @var{sectors_per_bank}
  3480. @item @var{pages_per_sector}
  3481. @item @var{pages_size}
  3482. @item @var{num_nvm_bits}
  3483. @item @var{freq_khz} ... required if an external clock is provided,
  3484. optional (but recommended) when the oscillator frequency is known
  3485. @end itemize
  3486. It is recommended that you provide zeroes for all of those values
  3487. except the clock frequency, so that everything except that frequency
  3488. will be autoconfigured.
  3489. Knowing the frequency helps ensure correct timings for flash access.
  3490. The flash controller handles erases automatically on a page (128/256 byte)
  3491. basis, so explicit erase commands are not necessary for flash programming.
  3492. However, there is an ``EraseAll`` command that can erase an entire flash
  3493. plane (of up to 256KB), and it will be used automatically when you issue
  3494. @command{flash erase_sector} or @command{flash erase_address} commands.
  3495. @deffn Command {at91sam7 gpnvm} bitnum (@option{set}|@option{clear})
  3496. Set or clear a ``General Purpose Non-Volatile Memory'' (GPNVM)
  3497. bit for the processor. Each processor has a number of such bits,
  3498. used for controlling features such as brownout detection (so they
  3499. are not truly general purpose).
  3500. @quotation Note
  3501. This assumes that the first flash bank (number 0) is associated with
  3502. the appropriate at91sam7 target.
  3503. @end quotation
  3504. @end deffn
  3505. @end deffn
  3506. @deffn {Flash Driver} avr
  3507. The AVR 8-bit microcontrollers from Atmel integrate flash memory.
  3508. @emph{The current implementation is incomplete.}
  3509. @comment - defines mass_erase ... pointless given flash_erase_address
  3510. @end deffn
  3511. @deffn {Flash Driver} ecosflash
  3512. @emph{No idea what this is...}
  3513. The @var{ecosflash} driver defines one mandatory parameter,
  3514. the name of a modules of target code which is downloaded
  3515. and executed.
  3516. @end deffn
  3517. @deffn {Flash Driver} lpc2000
  3518. Most members of the LPC1700 and LPC2000 microcontroller families from NXP
  3519. include internal flash and use Cortex-M3 (LPC1700) or ARM7TDMI (LPC2000) cores.
  3520. @quotation Note
  3521. There are LPC2000 devices which are not supported by the @var{lpc2000}
  3522. driver:
  3523. The LPC2888 is supported by the @var{lpc288x} driver.
  3524. The LPC29xx family is supported by the @var{lpc2900} driver.
  3525. @end quotation
  3526. The @var{lpc2000} driver defines two mandatory and one optional parameters,
  3527. which must appear in the following order:
  3528. @itemize
  3529. @item @var{variant} ... required, may be
  3530. @option{lpc2000_v1} (older LPC21xx and LPC22xx)
  3531. @option{lpc2000_v2} (LPC213x, LPC214x, LPC210[123], LPC23xx and LPC24xx)
  3532. or @option{lpc1700} (LPC175x and LPC176x)
  3533. @item @var{clock_kHz} ... the frequency, in kiloHertz,
  3534. at which the core is running
  3535. @item @option{calc_checksum} ... optional (but you probably want to provide this!),
  3536. telling the driver to calculate a valid checksum for the exception vector table.
  3537. @quotation Note
  3538. If you don't provide @option{calc_checksum} when you're writing the vector
  3539. table, the boot ROM will almost certainly ignore your flash image.
  3540. However, if you do provide it,
  3541. with most tool chains @command{verify_image} will fail.
  3542. @end quotation
  3543. @end itemize
  3544. LPC flashes don't require the chip and bus width to be specified.
  3545. @example
  3546. flash bank lpc2000 0x0 0x7d000 0 0 $_TARGETNAME \
  3547. lpc2000_v2 14765 calc_checksum
  3548. @end example
  3549. @deffn {Command} {lpc2000 part_id} bank
  3550. Displays the four byte part identifier associated with
  3551. the specified flash @var{bank}.
  3552. @end deffn
  3553. @end deffn
  3554. @deffn {Flash Driver} lpc288x
  3555. The LPC2888 microcontroller from NXP needs slightly different flash
  3556. support from its lpc2000 siblings.
  3557. The @var{lpc288x} driver defines one mandatory parameter,
  3558. the programming clock rate in Hz.
  3559. LPC flashes don't require the chip and bus width to be specified.
  3560. @example
  3561. flash bank lpc288x 0 0 0 0 $_TARGETNAME 12000000
  3562. @end example
  3563. @end deffn
  3564. @deffn {Flash Driver} lpc2900
  3565. This driver supports the LPC29xx ARM968E based microcontroller family
  3566. from NXP.
  3567. The predefined parameters @var{base}, @var{size}, @var{chip_width} and
  3568. @var{bus_width} of the @code{flash bank} command are ignored. Flash size and
  3569. sector layout are auto-configured by the driver.
  3570. The driver has one additional mandatory parameter: The CPU clock rate
  3571. (in kHz) at the time the flash operations will take place. Most of the time this
  3572. will not be the crystal frequency, but a higher PLL frequency. The
  3573. @code{reset-init} event handler in the board script is usually the place where
  3574. you start the PLL.
  3575. The driver rejects flashless devices (currently the LPC2930).
  3576. The EEPROM in LPC2900 devices is not mapped directly into the address space.
  3577. It must be handled much more like NAND flash memory, and will therefore be
  3578. handled by a separate @code{lpc2900_eeprom} driver (not yet available).
  3579. Sector protection in terms of the LPC2900 is handled transparently. Every time a
  3580. sector needs to be erased or programmed, it is automatically unprotected.
  3581. What is shown as protection status in the @code{flash info} command, is
  3582. actually the LPC2900 @emph{sector security}. This is a mechanism to prevent a
  3583. sector from ever being erased or programmed again. As this is an irreversible
  3584. mechanism, it is handled by a special command (@code{lpc2900 secure_sector}),
  3585. and not by the standard @code{flash protect} command.
  3586. Example for a 125 MHz clock frequency:
  3587. @example
  3588. flash bank lpc2900 0 0 0 0 $_TARGETNAME 125000
  3589. @end example
  3590. Some @code{lpc2900}-specific commands are defined. In the following command list,
  3591. the @var{bank} parameter is the bank number as obtained by the
  3592. @code{flash banks} command.
  3593. @deffn Command {lpc2900 signature} bank
  3594. Calculates a 128-bit hash value, the @emph{signature}, from the whole flash
  3595. content. This is a hardware feature of the flash block, hence the calculation is
  3596. very fast. You may use this to verify the content of a programmed device against
  3597. a known signature.
  3598. Example:
  3599. @example
  3600. lpc2900 signature 0
  3601. signature: 0x5f40cdc8:0xc64e592e:0x10490f89:0x32a0f317
  3602. @end example
  3603. @end deffn
  3604. @deffn Command {lpc2900 read_custom} bank filename
  3605. Reads the 912 bytes of customer information from the flash index sector, and
  3606. saves it to a file in binary format.
  3607. Example:
  3608. @example
  3609. lpc2900 read_custom 0 /path_to/customer_info.bin
  3610. @end example
  3611. @end deffn
  3612. The index sector of the flash is a @emph{write-only} sector. It cannot be
  3613. erased! In order to guard against unintentional write access, all following
  3614. commands need to be preceeded by a successful call to the @code{password}
  3615. command:
  3616. @deffn Command {lpc2900 password} bank password
  3617. You need to use this command right before each of the following commands:
  3618. @code{lpc2900 write_custom}, @code{lpc2900 secure_sector},
  3619. @code{lpc2900 secure_jtag}.
  3620. The password string is fixed to "I_know_what_I_am_doing".
  3621. Example:
  3622. @example
  3623. lpc2900 password 0 I_know_what_I_am_doing
  3624. Potentially dangerous operation allowed in next command!
  3625. @end example
  3626. @end deffn
  3627. @deffn Command {lpc2900 write_custom} bank filename type
  3628. Writes the content of the file into the customer info space of the flash index
  3629. sector. The filetype can be specified with the @var{type} field. Possible values
  3630. for @var{type} are: @var{bin} (binary), @var{ihex} (Intel hex format),
  3631. @var{elf} (ELF binary) or @var{s19} (Motorola S-records). The file must
  3632. contain a single section, and the contained data length must be exactly
  3633. 912 bytes.
  3634. @quotation Attention
  3635. This cannot be reverted! Be careful!
  3636. @end quotation
  3637. Example:
  3638. @example
  3639. lpc2900 write_custom 0 /path_to/customer_info.bin bin
  3640. @end example
  3641. @end deffn
  3642. @deffn Command {lpc2900 secure_sector} bank first last
  3643. Secures the sector range from @var{first} to @var{last} (including) against
  3644. further program and erase operations. The sector security will be effective
  3645. after the next power cycle.
  3646. @quotation Attention
  3647. This cannot be reverted! Be careful!
  3648. @end quotation
  3649. Secured sectors appear as @emph{protected} in the @code{flash info} command.
  3650. Example:
  3651. @example
  3652. lpc2900 secure_sector 0 1 1
  3653. flash info 0
  3654. #0 : lpc2900 at 0x20000000, size 0x000c0000, (...)
  3655. # 0: 0x00000000 (0x2000 8kB) not protected
  3656. # 1: 0x00002000 (0x2000 8kB) protected
  3657. # 2: 0x00004000 (0x2000 8kB) not protected
  3658. @end example
  3659. @end deffn
  3660. @deffn Command {lpc2900 secure_jtag} bank
  3661. Irreversibly disable the JTAG port. The new JTAG security setting will be
  3662. effective after the next power cycle.
  3663. @quotation Attention
  3664. This cannot be reverted! Be careful!
  3665. @end quotation
  3666. Examples:
  3667. @example
  3668. lpc2900 secure_jtag 0
  3669. @end example
  3670. @end deffn
  3671. @end deffn
  3672. @deffn {Flash Driver} ocl
  3673. @emph{No idea what this is, other than using some arm7/arm9 core.}
  3674. @example
  3675. flash bank ocl 0 0 0 0 $_TARGETNAME
  3676. @end example
  3677. @end deffn
  3678. @deffn {Flash Driver} pic32mx
  3679. The PIC32MX microcontrollers are based on the MIPS 4K cores,
  3680. and integrate flash memory.
  3681. @emph{The current implementation is incomplete.}
  3682. @example
  3683. flash bank pix32mx 0 0 0 0 $_TARGETNAME
  3684. @end example
  3685. @comment numerous *disabled* commands are defined:
  3686. @comment - chip_erase ... pointless given flash_erase_address
  3687. @comment - lock, unlock ... pointless given protect on/off (yes?)
  3688. @comment - pgm_word ... shouldn't bank be deduced from address??
  3689. Some pic32mx-specific commands are defined:
  3690. @deffn Command {pic32mx pgm_word} address value bank
  3691. Programs the specified 32-bit @var{value} at the given @var{address}
  3692. in the specified chip @var{bank}.
  3693. @end deffn
  3694. @end deffn
  3695. @deffn {Flash Driver} stellaris
  3696. All members of the Stellaris LM3Sxxx microcontroller family from
  3697. Texas Instruments
  3698. include internal flash and use ARM Cortex M3 cores.
  3699. The driver automatically recognizes a number of these chips using
  3700. the chip identification register, and autoconfigures itself.
  3701. @footnote{Currently there is a @command{stellaris mass_erase} command.
  3702. That seems pointless since the same effect can be had using the
  3703. standard @command{flash erase_address} command.}
  3704. @example
  3705. flash bank stellaris 0 0 0 0 $_TARGETNAME
  3706. @end example
  3707. @end deffn
  3708. @deffn {Flash Driver} stm32x
  3709. All members of the STM32 microcontroller family from ST Microelectronics
  3710. include internal flash and use ARM Cortex M3 cores.
  3711. The driver automatically recognizes a number of these chips using
  3712. the chip identification register, and autoconfigures itself.
  3713. @example
  3714. flash bank stm32x 0 0 0 0 $_TARGETNAME
  3715. @end example
  3716. Some stm32x-specific commands
  3717. @footnote{Currently there is a @command{stm32x mass_erase} command.
  3718. That seems pointless since the same effect can be had using the
  3719. standard @command{flash erase_address} command.}
  3720. are defined:
  3721. @deffn Command {stm32x lock} num
  3722. Locks the entire stm32 device.
  3723. The @var{num} parameter is a value shown by @command{flash banks}.
  3724. @end deffn
  3725. @deffn Command {stm32x unlock} num
  3726. Unlocks the entire stm32 device.
  3727. The @var{num} parameter is a value shown by @command{flash banks}.
  3728. @end deffn
  3729. @deffn Command {stm32x options_read} num
  3730. Read and display the stm32 option bytes written by
  3731. the @command{stm32x options_write} command.
  3732. The @var{num} parameter is a value shown by @command{flash banks}.
  3733. @end deffn
  3734. @deffn Command {stm32x options_write} num (@option{SWWDG}|@option{HWWDG}) (@option{RSTSTNDBY}|@option{NORSTSTNDBY}) (@option{RSTSTOP}|@option{NORSTSTOP})
  3735. Writes the stm32 option byte with the specified values.
  3736. The @var{num} parameter is a value shown by @command{flash banks}.
  3737. @end deffn
  3738. @end deffn
  3739. @deffn {Flash Driver} str7x
  3740. All members of the STR7 microcontroller family from ST Microelectronics
  3741. include internal flash and use ARM7TDMI cores.
  3742. The @var{str7x} driver defines one mandatory parameter, @var{variant},
  3743. which is either @code{STR71x}, @code{STR73x} or @code{STR75x}.
  3744. @example
  3745. flash bank str7x 0x40000000 0x00040000 0 0 $_TARGETNAME STR71x
  3746. @end example
  3747. @deffn Command {str7x disable_jtag} bank
  3748. Activate the Debug/Readout protection mechanism
  3749. for the specified flash bank.
  3750. @end deffn
  3751. @end deffn
  3752. @deffn {Flash Driver} str9x
  3753. Most members of the STR9 microcontroller family from ST Microelectronics
  3754. include internal flash and use ARM966E cores.
  3755. The str9 needs the flash controller to be configured using
  3756. the @command{str9x flash_config} command prior to Flash programming.
  3757. @example
  3758. flash bank str9x 0x40000000 0x00040000 0 0 $_TARGETNAME
  3759. str9x flash_config 0 4 2 0 0x80000
  3760. @end example
  3761. @deffn Command {str9x flash_config} num bbsr nbbsr bbadr nbbadr
  3762. Configures the str9 flash controller.
  3763. The @var{num} parameter is a value shown by @command{flash banks}.
  3764. @itemize @bullet
  3765. @item @var{bbsr} - Boot Bank Size register
  3766. @item @var{nbbsr} - Non Boot Bank Size register
  3767. @item @var{bbadr} - Boot Bank Start Address register
  3768. @item @var{nbbadr} - Boot Bank Start Address register
  3769. @end itemize
  3770. @end deffn
  3771. @end deffn
  3772. @deffn {Flash Driver} tms470
  3773. Most members of the TMS470 microcontroller family from Texas Instruments
  3774. include internal flash and use ARM7TDMI cores.
  3775. This driver doesn't require the chip and bus width to be specified.
  3776. Some tms470-specific commands are defined:
  3777. @deffn Command {tms470 flash_keyset} key0 key1 key2 key3
  3778. Saves programming keys in a register, to enable flash erase and write commands.
  3779. @end deffn
  3780. @deffn Command {tms470 osc_mhz} clock_mhz
  3781. Reports the clock speed, which is used to calculate timings.
  3782. @end deffn
  3783. @deffn Command {tms470 plldis} (0|1)
  3784. Disables (@var{1}) or enables (@var{0}) use of the PLL to speed up
  3785. the flash clock.
  3786. @end deffn
  3787. @end deffn
  3788. @subsection str9xpec driver
  3789. @cindex str9xpec
  3790. Here is some background info to help
  3791. you better understand how this driver works. OpenOCD has two flash drivers for
  3792. the str9:
  3793. @enumerate
  3794. @item
  3795. Standard driver @option{str9x} programmed via the str9 core. Normally used for
  3796. flash programming as it is faster than the @option{str9xpec} driver.
  3797. @item
  3798. Direct programming @option{str9xpec} using the flash controller. This is an
  3799. ISC compilant (IEEE 1532) tap connected in series with the str9 core. The str9
  3800. core does not need to be running to program using this flash driver. Typical use
  3801. for this driver is locking/unlocking the target and programming the option bytes.
  3802. @end enumerate
  3803. Before we run any commands using the @option{str9xpec} driver we must first disable
  3804. the str9 core. This example assumes the @option{str9xpec} driver has been
  3805. configured for flash bank 0.
  3806. @example
  3807. # assert srst, we do not want core running
  3808. # while accessing str9xpec flash driver
  3809. jtag_reset 0 1
  3810. # turn off target polling
  3811. poll off
  3812. # disable str9 core
  3813. str9xpec enable_turbo 0
  3814. # read option bytes
  3815. str9xpec options_read 0
  3816. # re-enable str9 core
  3817. str9xpec disable_turbo 0
  3818. poll on
  3819. reset halt
  3820. @end example
  3821. The above example will read the str9 option bytes.
  3822. When performing a unlock remember that you will not be able to halt the str9 - it
  3823. has been locked. Halting the core is not required for the @option{str9xpec} driver
  3824. as mentioned above, just issue the commands above manually or from a telnet prompt.
  3825. @deffn {Flash Driver} str9xpec
  3826. Only use this driver for locking/unlocking the device or configuring the option bytes.
  3827. Use the standard str9 driver for programming.
  3828. Before using the flash commands the turbo mode must be enabled using the
  3829. @command{str9xpec enable_turbo} command.
  3830. Several str9xpec-specific commands are defined:
  3831. @deffn Command {str9xpec disable_turbo} num
  3832. Restore the str9 into JTAG chain.
  3833. @end deffn
  3834. @deffn Command {str9xpec enable_turbo} num
  3835. Enable turbo mode, will simply remove the str9 from the chain and talk
  3836. directly to the embedded flash controller.
  3837. @end deffn
  3838. @deffn Command {str9xpec lock} num
  3839. Lock str9 device. The str9 will only respond to an unlock command that will
  3840. erase the device.
  3841. @end deffn
  3842. @deffn Command {str9xpec part_id} num
  3843. Prints the part identifier for bank @var{num}.
  3844. @end deffn
  3845. @deffn Command {str9xpec options_cmap} num (@option{bank0}|@option{bank1})
  3846. Configure str9 boot bank.
  3847. @end deffn
  3848. @deffn Command {str9xpec options_lvdsel} num (@option{vdd}|@option{vdd_vddq})
  3849. Configure str9 lvd source.
  3850. @end deffn
  3851. @deffn Command {str9xpec options_lvdthd} num (@option{2.4v}|@option{2.7v})
  3852. Configure str9 lvd threshold.
  3853. @end deffn
  3854. @deffn Command {str9xpec options_lvdwarn} bank (@option{vdd}|@option{vdd_vddq})
  3855. Configure str9 lvd reset warning source.
  3856. @end deffn
  3857. @deffn Command {str9xpec options_read} num
  3858. Read str9 option bytes.
  3859. @end deffn
  3860. @deffn Command {str9xpec options_write} num
  3861. Write str9 option bytes.
  3862. @end deffn
  3863. @deffn Command {str9xpec unlock} num
  3864. unlock str9 device.
  3865. @end deffn
  3866. @end deffn
  3867. @section mFlash
  3868. @subsection mFlash Configuration
  3869. @cindex mFlash Configuration
  3870. @deffn {Config Command} {mflash bank} soc base RST_pin target
  3871. Configures a mflash for @var{soc} host bank at
  3872. address @var{base}.
  3873. The pin number format depends on the host GPIO naming convention.
  3874. Currently, the mflash driver supports s3c2440 and pxa270.
  3875. Example for s3c2440 mflash where @var{RST pin} is GPIO B1:
  3876. @example
  3877. mflash bank s3c2440 0x10000000 1b 0
  3878. @end example
  3879. Example for pxa270 mflash where @var{RST pin} is GPIO 43:
  3880. @example
  3881. mflash bank pxa270 0x08000000 43 0
  3882. @end example
  3883. @end deffn
  3884. @subsection mFlash commands
  3885. @cindex mFlash commands
  3886. @deffn Command {mflash config pll} frequency
  3887. Configure mflash PLL.
  3888. The @var{frequency} is the mflash input frequency, in Hz.
  3889. Issuing this command will erase mflash's whole internal nand and write new pll.
  3890. After this command, mflash needs power-on-reset for normal operation.
  3891. If pll was newly configured, storage and boot(optional) info also need to be update.
  3892. @end deffn
  3893. @deffn Command {mflash config boot}
  3894. Configure bootable option.
  3895. If bootable option is set, mflash offer the first 8 sectors
  3896. (4kB) for boot.
  3897. @end deffn
  3898. @deffn Command {mflash config storage}
  3899. Configure storage information.
  3900. For the normal storage operation, this information must be
  3901. written.
  3902. @end deffn
  3903. @deffn Command {mflash dump} num filename offset size
  3904. Dump @var{size} bytes, starting at @var{offset} bytes from the
  3905. beginning of the bank @var{num}, to the file named @var{filename}.
  3906. @end deffn
  3907. @deffn Command {mflash probe}
  3908. Probe mflash.
  3909. @end deffn
  3910. @deffn Command {mflash write} num filename offset
  3911. Write the binary file @var{filename} to mflash bank @var{num}, starting at
  3912. @var{offset} bytes from the beginning of the bank.
  3913. @end deffn
  3914. @node NAND Flash Commands
  3915. @chapter NAND Flash Commands
  3916. @cindex NAND
  3917. Compared to NOR or SPI flash, NAND devices are inexpensive
  3918. and high density. Today's NAND chips, and multi-chip modules,
  3919. commonly hold multiple GigaBytes of data.
  3920. NAND chips consist of a number of ``erase blocks'' of a given
  3921. size (such as 128 KBytes), each of which is divided into a
  3922. number of pages (of perhaps 512 or 2048 bytes each). Each
  3923. page of a NAND flash has an ``out of band'' (OOB) area to hold
  3924. Error Correcting Code (ECC) and other metadata, usually 16 bytes
  3925. of OOB for every 512 bytes of page data.
  3926. One key characteristic of NAND flash is that its error rate
  3927. is higher than that of NOR flash. In normal operation, that
  3928. ECC is used to correct and detect errors. However, NAND
  3929. blocks can also wear out and become unusable; those blocks
  3930. are then marked "bad". NAND chips are even shipped from the
  3931. manufacturer with a few bad blocks. The highest density chips
  3932. use a technology (MLC) that wears out more quickly, so ECC
  3933. support is increasingly important as a way to detect blocks
  3934. that have begun to fail, and help to preserve data integrity
  3935. with techniques such as wear leveling.
  3936. Software is used to manage the ECC. Some controllers don't
  3937. support ECC directly; in those cases, software ECC is used.
  3938. Other controllers speed up the ECC calculations with hardware.
  3939. Single-bit error correction hardware is routine. Controllers
  3940. geared for newer MLC chips may correct 4 or more errors for
  3941. every 512 bytes of data.
  3942. You will need to make sure that any data you write using
  3943. OpenOCD includes the apppropriate kind of ECC. For example,
  3944. that may mean passing the @code{oob_softecc} flag when
  3945. writing NAND data, or ensuring that the correct hardware
  3946. ECC mode is used.
  3947. The basic steps for using NAND devices include:
  3948. @enumerate
  3949. @item Declare via the command @command{nand device}
  3950. @* Do this in a board-specific configuration file,
  3951. passing parameters as needed by the controller.
  3952. @item Configure each device using @command{nand probe}.
  3953. @* Do this only after the associated target is set up,
  3954. such as in its reset-init script or in procures defined
  3955. to access that device.
  3956. @item Operate on the flash via @command{nand subcommand}
  3957. @* Often commands to manipulate the flash are typed by a human, or run
  3958. via a script in some automated way. Common task include writing a
  3959. boot loader, operating system, or other data needed to initialize or
  3960. de-brick a board.
  3961. @end enumerate
  3962. @b{NOTE:} At the time this text was written, the largest NAND
  3963. flash fully supported by OpenOCD is 2 GiBytes (16 GiBits).
  3964. This is because the variables used to hold offsets and lengths
  3965. are only 32 bits wide.
  3966. (Larger chips may work in some cases, unless an offset or length
  3967. is larger than 0xffffffff, the largest 32-bit unsigned integer.)
  3968. Some larger devices will work, since they are actually multi-chip
  3969. modules with two smaller chips and individual chipselect lines.
  3970. @anchor{NAND Configuration}
  3971. @section NAND Configuration Commands
  3972. @cindex NAND configuration
  3973. NAND chips must be declared in configuration scripts,
  3974. plus some additional configuration that's done after
  3975. OpenOCD has initialized.
  3976. @deffn {Config Command} {nand device} name driver target [configparams...]
  3977. Declares a NAND device, which can be read and written to
  3978. after it has been configured through @command{nand probe}.
  3979. In OpenOCD, devices are single chips; this is unlike some
  3980. operating systems, which may manage multiple chips as if
  3981. they were a single (larger) device.
  3982. In some cases, configuring a device will activate extra
  3983. commands; see the controller-specific documentation.
  3984. @b{NOTE:} This command is not available after OpenOCD
  3985. initialization has completed. Use it in board specific
  3986. configuration files, not interactively.
  3987. @itemize @bullet
  3988. @item @var{name} ... may be used to reference the NAND bank
  3989. in most other NAND commands. A number is also available.
  3990. @item @var{driver} ... identifies the NAND controller driver
  3991. associated with the NAND device being declared.
  3992. @xref{NAND Driver List}.
  3993. @item @var{target} ... names the target used when issuing
  3994. commands to the NAND controller.
  3995. @comment Actually, it's currently a controller-specific parameter...
  3996. @item @var{configparams} ... controllers may support, or require,
  3997. additional parameters. See the controller-specific documentation
  3998. for more information.
  3999. @end itemize
  4000. @end deffn
  4001. @deffn Command {nand list}
  4002. Prints a summary of each device declared
  4003. using @command{nand device}, numbered from zero.
  4004. Note that un-probed devices show no details.
  4005. @example
  4006. > nand list
  4007. #0: NAND 1GiB 3,3V 8-bit (Micron) pagesize: 2048, buswidth: 8,
  4008. blocksize: 131072, blocks: 8192
  4009. #1: NAND 1GiB 3,3V 8-bit (Micron) pagesize: 2048, buswidth: 8,
  4010. blocksize: 131072, blocks: 8192
  4011. >
  4012. @end example
  4013. @end deffn
  4014. @deffn Command {nand probe} num
  4015. Probes the specified device to determine key characteristics
  4016. like its page and block sizes, and how many blocks it has.
  4017. The @var{num} parameter is the value shown by @command{nand list}.
  4018. You must (successfully) probe a device before you can use
  4019. it with most other NAND commands.
  4020. @end deffn
  4021. @section Erasing, Reading, Writing to NAND Flash
  4022. @deffn Command {nand dump} num filename offset length [oob_option]
  4023. @cindex NAND reading
  4024. Reads binary data from the NAND device and writes it to the file,
  4025. starting at the specified offset.
  4026. The @var{num} parameter is the value shown by @command{nand list}.
  4027. Use a complete path name for @var{filename}, so you don't depend
  4028. on the directory used to start the OpenOCD server.
  4029. The @var{offset} and @var{length} must be exact multiples of the
  4030. device's page size. They describe a data region; the OOB data
  4031. associated with each such page may also be accessed.
  4032. @b{NOTE:} At the time this text was written, no error correction
  4033. was done on the data that's read, unless raw access was disabled
  4034. and the underlying NAND controller driver had a @code{read_page}
  4035. method which handled that error correction.
  4036. By default, only page data is saved to the specified file.
  4037. Use an @var{oob_option} parameter to save OOB data:
  4038. @itemize @bullet
  4039. @item no oob_* parameter
  4040. @*Output file holds only page data; OOB is discarded.
  4041. @item @code{oob_raw}
  4042. @*Output file interleaves page data and OOB data;
  4043. the file will be longer than "length" by the size of the
  4044. spare areas associated with each data page.
  4045. Note that this kind of "raw" access is different from
  4046. what's implied by @command{nand raw_access}, which just
  4047. controls whether a hardware-aware access method is used.
  4048. @item @code{oob_only}
  4049. @*Output file has only raw OOB data, and will
  4050. be smaller than "length" since it will contain only the
  4051. spare areas associated with each data page.
  4052. @end itemize
  4053. @end deffn
  4054. @deffn Command {nand erase} num [offset length]
  4055. @cindex NAND erasing
  4056. @cindex NAND programming
  4057. Erases blocks on the specified NAND device, starting at the
  4058. specified @var{offset} and continuing for @var{length} bytes.
  4059. Both of those values must be exact multiples of the device's
  4060. block size, and the region they specify must fit entirely in the chip.
  4061. If those parameters are not specified,
  4062. the whole NAND chip will be erased.
  4063. The @var{num} parameter is the value shown by @command{nand list}.
  4064. @b{NOTE:} This command will try to erase bad blocks, when told
  4065. to do so, which will probably invalidate the manufacturer's bad
  4066. block marker.
  4067. For the remainder of the current server session, @command{nand info}
  4068. will still report that the block ``is'' bad.
  4069. @end deffn
  4070. @deffn Command {nand write} num filename offset [option...]
  4071. @cindex NAND writing
  4072. @cindex NAND programming
  4073. Writes binary data from the file into the specified NAND device,
  4074. starting at the specified offset. Those pages should already
  4075. have been erased; you can't change zero bits to one bits.
  4076. The @var{num} parameter is the value shown by @command{nand list}.
  4077. Use a complete path name for @var{filename}, so you don't depend
  4078. on the directory used to start the OpenOCD server.
  4079. The @var{offset} must be an exact multiple of the device's page size.
  4080. All data in the file will be written, assuming it doesn't run
  4081. past the end of the device.
  4082. Only full pages are written, and any extra space in the last
  4083. page will be filled with 0xff bytes. (That includes OOB data,
  4084. if that's being written.)
  4085. @b{NOTE:} At the time this text was written, bad blocks are
  4086. ignored. That is, this routine will not skip bad blocks,
  4087. but will instead try to write them. This can cause problems.
  4088. Provide at most one @var{option} parameter. With some
  4089. NAND drivers, the meanings of these parameters may change
  4090. if @command{nand raw_access} was used to disable hardware ECC.
  4091. @itemize @bullet
  4092. @item no oob_* parameter
  4093. @*File has only page data, which is written.
  4094. If raw acccess is in use, the OOB area will not be written.
  4095. Otherwise, if the underlying NAND controller driver has
  4096. a @code{write_page} routine, that routine may write the OOB
  4097. with hardware-computed ECC data.
  4098. @item @code{oob_only}
  4099. @*File has only raw OOB data, which is written to the OOB area.
  4100. Each page's data area stays untouched. @i{This can be a dangerous
  4101. option}, since it can invalidate the ECC data.
  4102. You may need to force raw access to use this mode.
  4103. @item @code{oob_raw}
  4104. @*File interleaves data and OOB data, both of which are written
  4105. If raw access is enabled, the data is written first, then the
  4106. un-altered OOB.
  4107. Otherwise, if the underlying NAND controller driver has
  4108. a @code{write_page} routine, that routine may modify the OOB
  4109. before it's written, to include hardware-computed ECC data.
  4110. @item @code{oob_softecc}
  4111. @*File has only page data, which is written.
  4112. The OOB area is filled with 0xff, except for a standard 1-bit
  4113. software ECC code stored in conventional locations.
  4114. You might need to force raw access to use this mode, to prevent
  4115. the underlying driver from applying hardware ECC.
  4116. @item @code{oob_softecc_kw}
  4117. @*File has only page data, which is written.
  4118. The OOB area is filled with 0xff, except for a 4-bit software ECC
  4119. specific to the boot ROM in Marvell Kirkwood SoCs.
  4120. You might need to force raw access to use this mode, to prevent
  4121. the underlying driver from applying hardware ECC.
  4122. @end itemize
  4123. @end deffn
  4124. @deffn Command {nand verify} num filename offset [option...]
  4125. @cindex NAND verification
  4126. @cindex NAND programming
  4127. Verify the binary data in the file has been programmed to the
  4128. specified NAND device, starting at the specified offset.
  4129. The @var{num} parameter is the value shown by @command{nand list}.
  4130. Use a complete path name for @var{filename}, so you don't depend
  4131. on the directory used to start the OpenOCD server.
  4132. The @var{offset} must be an exact multiple of the device's page size.
  4133. All data in the file will be read and compared to the contents of the
  4134. flash, assuming it doesn't run past the end of the device.
  4135. As with @command{nand write}, only full pages are verified, so any extra
  4136. space in the last page will be filled with 0xff bytes.
  4137. The same @var{options} accepted by @command{nand write},
  4138. and the file will be processed similarly to produce the buffers that
  4139. can be compared against the contents produced from @command{nand dump}.
  4140. @b{NOTE:} This will not work when the underlying NAND controller
  4141. driver's @code{write_page} routine must update the OOB with a
  4142. hardward-computed ECC before the data is written. This limitation may
  4143. be removed in a future release.
  4144. @end deffn
  4145. @section Other NAND commands
  4146. @cindex NAND other commands
  4147. @deffn Command {nand check_bad_blocks} [offset length]
  4148. Checks for manufacturer bad block markers on the specified NAND
  4149. device. If no parameters are provided, checks the whole
  4150. device; otherwise, starts at the specified @var{offset} and
  4151. continues for @var{length} bytes.
  4152. Both of those values must be exact multiples of the device's
  4153. block size, and the region they specify must fit entirely in the chip.
  4154. The @var{num} parameter is the value shown by @command{nand list}.
  4155. @b{NOTE:} Before using this command you should force raw access
  4156. with @command{nand raw_access enable} to ensure that the underlying
  4157. driver will not try to apply hardware ECC.
  4158. @end deffn
  4159. @deffn Command {nand info} num
  4160. The @var{num} parameter is the value shown by @command{nand list}.
  4161. This prints the one-line summary from "nand list", plus for
  4162. devices which have been probed this also prints any known
  4163. status for each block.
  4164. @end deffn
  4165. @deffn Command {nand raw_access} num (@option{enable}|@option{disable})
  4166. Sets or clears an flag affecting how page I/O is done.
  4167. The @var{num} parameter is the value shown by @command{nand list}.
  4168. This flag is cleared (disabled) by default, but changing that
  4169. value won't affect all NAND devices. The key factor is whether
  4170. the underlying driver provides @code{read_page} or @code{write_page}
  4171. methods. If it doesn't provide those methods, the setting of
  4172. this flag is irrelevant; all access is effectively ``raw''.
  4173. When those methods exist, they are normally used when reading
  4174. data (@command{nand dump} or reading bad block markers) or
  4175. writing it (@command{nand write}). However, enabling
  4176. raw access (setting the flag) prevents use of those methods,
  4177. bypassing hardware ECC logic.
  4178. @i{This can be a dangerous option}, since writing blocks
  4179. with the wrong ECC data can cause them to be marked as bad.
  4180. @end deffn
  4181. @anchor{NAND Driver List}
  4182. @section NAND Driver List
  4183. As noted above, the @command{nand device} command allows
  4184. driver-specific options and behaviors.
  4185. Some controllers also activate controller-specific commands.
  4186. @deffn {NAND Driver} at91sam9
  4187. This driver handles the NAND controllers found on AT91SAM9 family chips from
  4188. Atmel. It takes two extra parameters: address of the NAND chip;
  4189. address of the ECC controller.
  4190. @example
  4191. nand device $NANDFLASH at91sam9 $CHIPNAME 0x40000000 0xfffffe800
  4192. @end example
  4193. AT91SAM9 chips support single-bit ECC hardware. The @code{write_page} and
  4194. @code{read_page} methods are used to utilize the ECC hardware unless they are
  4195. disabled by using the @command{nand raw_access} command. There are four
  4196. additional commands that are needed to fully configure the AT91SAM9 NAND
  4197. controller. Two are optional; most boards use the same wiring for ALE/CLE:
  4198. @deffn Command {at91sam9 cle} num addr_line
  4199. Configure the address line used for latching commands. The @var{num}
  4200. parameter is the value shown by @command{nand list}.
  4201. @end deffn
  4202. @deffn Command {at91sam9 ale} num addr_line
  4203. Configure the address line used for latching addresses. The @var{num}
  4204. parameter is the value shown by @command{nand list}.
  4205. @end deffn
  4206. For the next two commands, it is assumed that the pins have already been
  4207. properly configured for input or output.
  4208. @deffn Command {at91sam9 rdy_busy} num pio_base_addr pin
  4209. Configure the RDY/nBUSY input from the NAND device. The @var{num}
  4210. parameter is the value shown by @command{nand list}. @var{pio_base_addr}
  4211. is the base address of the PIO controller and @var{pin} is the pin number.
  4212. @end deffn
  4213. @deffn Command {at91sam9 ce} num pio_base_addr pin
  4214. Configure the chip enable input to the NAND device. The @var{num}
  4215. parameter is the value shown by @command{nand list}. @var{pio_base_addr}
  4216. is the base address of the PIO controller and @var{pin} is the pin number.
  4217. @end deffn
  4218. @end deffn
  4219. @deffn {NAND Driver} davinci
  4220. This driver handles the NAND controllers found on DaVinci family
  4221. chips from Texas Instruments.
  4222. It takes three extra parameters:
  4223. address of the NAND chip;
  4224. hardware ECC mode to use (@option{hwecc1},
  4225. @option{hwecc4}, @option{hwecc4_infix});
  4226. address of the AEMIF controller on this processor.
  4227. @example
  4228. nand device davinci dm355.arm 0x02000000 hwecc4 0x01e10000
  4229. @end example
  4230. All DaVinci processors support the single-bit ECC hardware,
  4231. and newer ones also support the four-bit ECC hardware.
  4232. The @code{write_page} and @code{read_page} methods are used
  4233. to implement those ECC modes, unless they are disabled using
  4234. the @command{nand raw_access} command.
  4235. @end deffn
  4236. @deffn {NAND Driver} lpc3180
  4237. These controllers require an extra @command{nand device}
  4238. parameter: the clock rate used by the controller.
  4239. @deffn Command {lpc3180 select} num [mlc|slc]
  4240. Configures use of the MLC or SLC controller mode.
  4241. MLC implies use of hardware ECC.
  4242. The @var{num} parameter is the value shown by @command{nand list}.
  4243. @end deffn
  4244. At this writing, this driver includes @code{write_page}
  4245. and @code{read_page} methods. Using @command{nand raw_access}
  4246. to disable those methods will prevent use of hardware ECC
  4247. in the MLC controller mode, but won't change SLC behavior.
  4248. @end deffn
  4249. @comment current lpc3180 code won't issue 5-byte address cycles
  4250. @deffn {NAND Driver} orion
  4251. These controllers require an extra @command{nand device}
  4252. parameter: the address of the controller.
  4253. @example
  4254. nand device orion 0xd8000000
  4255. @end example
  4256. These controllers don't define any specialized commands.
  4257. At this writing, their drivers don't include @code{write_page}
  4258. or @code{read_page} methods, so @command{nand raw_access} won't
  4259. change any behavior.
  4260. @end deffn
  4261. @deffn {NAND Driver} s3c2410
  4262. @deffnx {NAND Driver} s3c2412
  4263. @deffnx {NAND Driver} s3c2440
  4264. @deffnx {NAND Driver} s3c2443
  4265. @deffnx {NAND Driver} s3c6400
  4266. These S3C family controllers don't have any special
  4267. @command{nand device} options, and don't define any
  4268. specialized commands.
  4269. At this writing, their drivers don't include @code{write_page}
  4270. or @code{read_page} methods, so @command{nand raw_access} won't
  4271. change any behavior.
  4272. @end deffn
  4273. @node PLD/FPGA Commands
  4274. @chapter PLD/FPGA Commands
  4275. @cindex PLD
  4276. @cindex FPGA
  4277. Programmable Logic Devices (PLDs) and the more flexible
  4278. Field Programmable Gate Arrays (FPGAs) are both types of programmable hardware.
  4279. OpenOCD can support programming them.
  4280. Although PLDs are generally restrictive (cells are less functional, and
  4281. there are no special purpose cells for memory or computational tasks),
  4282. they share the same OpenOCD infrastructure.
  4283. Accordingly, both are called PLDs here.
  4284. @section PLD/FPGA Configuration and Commands
  4285. As it does for JTAG TAPs, debug targets, and flash chips (both NOR and NAND),
  4286. OpenOCD maintains a list of PLDs available for use in various commands.
  4287. Also, each such PLD requires a driver.
  4288. They are referenced by the number shown by the @command{pld devices} command,
  4289. and new PLDs are defined by @command{pld device driver_name}.
  4290. @deffn {Config Command} {pld device} driver_name tap_name [driver_options]
  4291. Defines a new PLD device, supported by driver @var{driver_name},
  4292. using the TAP named @var{tap_name}.
  4293. The driver may make use of any @var{driver_options} to configure its
  4294. behavior.
  4295. @end deffn
  4296. @deffn {Command} {pld devices}
  4297. Lists the PLDs and their numbers.
  4298. @end deffn
  4299. @deffn {Command} {pld load} num filename
  4300. Loads the file @file{filename} into the PLD identified by @var{num}.
  4301. The file format must be inferred by the driver.
  4302. @end deffn
  4303. @section PLD/FPGA Drivers, Options, and Commands
  4304. Drivers may support PLD-specific options to the @command{pld device}
  4305. definition command, and may also define commands usable only with
  4306. that particular type of PLD.
  4307. @deffn {FPGA Driver} virtex2
  4308. Virtex-II is a family of FPGAs sold by Xilinx.
  4309. It supports the IEEE 1532 standard for In-System Configuration (ISC).
  4310. No driver-specific PLD definition options are used,
  4311. and one driver-specific command is defined.
  4312. @deffn {Command} {virtex2 read_stat} num
  4313. Reads and displays the Virtex-II status register (STAT)
  4314. for FPGA @var{num}.
  4315. @end deffn
  4316. @end deffn
  4317. @node General Commands
  4318. @chapter General Commands
  4319. @cindex commands
  4320. The commands documented in this chapter here are common commands that
  4321. you, as a human, may want to type and see the output of. Configuration type
  4322. commands are documented elsewhere.
  4323. Intent:
  4324. @itemize @bullet
  4325. @item @b{Source Of Commands}
  4326. @* OpenOCD commands can occur in a configuration script (discussed
  4327. elsewhere) or typed manually by a human or supplied programatically,
  4328. or via one of several TCP/IP Ports.
  4329. @item @b{From the human}
  4330. @* A human should interact with the telnet interface (default port: 4444)
  4331. or via GDB (default port 3333).
  4332. To issue commands from within a GDB session, use the @option{monitor}
  4333. command, e.g. use @option{monitor poll} to issue the @option{poll}
  4334. command. All output is relayed through the GDB session.
  4335. @item @b{Machine Interface}
  4336. The Tcl interface's intent is to be a machine interface. The default Tcl
  4337. port is 5555.
  4338. @end itemize
  4339. @section Daemon Commands
  4340. @deffn {Command} exit
  4341. Exits the current telnet session.
  4342. @end deffn
  4343. @deffn {Command} help [string]
  4344. With no parameters, prints help text for all commands.
  4345. Otherwise, prints each helptext containing @var{string}.
  4346. Not every command provides helptext.
  4347. Configuration commands, and commands valid at any time, are
  4348. explicitly noted in parenthesis.
  4349. In most cases, no such restriction is listed; this indicates commands
  4350. which are only available after the configuration stage has completed.
  4351. @end deffn
  4352. @deffn Command sleep msec [@option{busy}]
  4353. Wait for at least @var{msec} milliseconds before resuming.
  4354. If @option{busy} is passed, busy-wait instead of sleeping.
  4355. (This option is strongly discouraged.)
  4356. Useful in connection with script files
  4357. (@command{script} command and @command{target_name} configuration).
  4358. @end deffn
  4359. @deffn Command shutdown
  4360. Close the OpenOCD daemon, disconnecting all clients (GDB, telnet, other).
  4361. @end deffn
  4362. @anchor{debug_level}
  4363. @deffn Command debug_level [n]
  4364. @cindex message level
  4365. Display debug level.
  4366. If @var{n} (from 0..3) is provided, then set it to that level.
  4367. This affects the kind of messages sent to the server log.
  4368. Level 0 is error messages only;
  4369. level 1 adds warnings;
  4370. level 2 adds informational messages;
  4371. and level 3 adds debugging messages.
  4372. The default is level 2, but that can be overridden on
  4373. the command line along with the location of that log
  4374. file (which is normally the server's standard output).
  4375. @xref{Running}.
  4376. @end deffn
  4377. @deffn Command fast (@option{enable}|@option{disable})
  4378. Default disabled.
  4379. Set default behaviour of OpenOCD to be "fast and dangerous".
  4380. At this writing, this only affects the defaults for two ARM7/ARM9 parameters:
  4381. fast memory access, and DCC downloads. Those parameters may still be
  4382. individually overridden.
  4383. The target specific "dangerous" optimisation tweaking options may come and go
  4384. as more robust and user friendly ways are found to ensure maximum throughput
  4385. and robustness with a minimum of configuration.
  4386. Typically the "fast enable" is specified first on the command line:
  4387. @example
  4388. openocd -c "fast enable" -c "interface dummy" -f target/str710.cfg
  4389. @end example
  4390. @end deffn
  4391. @deffn Command echo message
  4392. Logs a message at "user" priority.
  4393. Output @var{message} to stdout.
  4394. @example
  4395. echo "Downloading kernel -- please wait"
  4396. @end example
  4397. @end deffn
  4398. @deffn Command log_output [filename]
  4399. Redirect logging to @var{filename};
  4400. the initial log output channel is stderr.
  4401. @end deffn
  4402. @anchor{Target State handling}
  4403. @section Target State handling
  4404. @cindex reset
  4405. @cindex halt
  4406. @cindex target initialization
  4407. In this section ``target'' refers to a CPU configured as
  4408. shown earlier (@pxref{CPU Configuration}).
  4409. These commands, like many, implicitly refer to
  4410. a current target which is used to perform the
  4411. various operations. The current target may be changed
  4412. by using @command{targets} command with the name of the
  4413. target which should become current.
  4414. @deffn Command reg [(number|name) [value]]
  4415. Access a single register by @var{number} or by its @var{name}.
  4416. The target must generally be halted before access to CPU core
  4417. registers is allowed. Depending on the hardware, some other
  4418. registers may be accessible while the target is running.
  4419. @emph{With no arguments}:
  4420. list all available registers for the current target,
  4421. showing number, name, size, value, and cache status.
  4422. For valid entries, a value is shown; valid entries
  4423. which are also dirty (and will be written back later)
  4424. are flagged as such.
  4425. @emph{With number/name}: display that register's value.
  4426. @emph{With both number/name and value}: set register's value.
  4427. Writes may be held in a writeback cache internal to OpenOCD,
  4428. so that setting the value marks the register as dirty instead
  4429. of immediately flushing that value. Resuming CPU execution
  4430. (including by single stepping) or otherwise activating the
  4431. relevant module will flush such values.
  4432. Cores may have surprisingly many registers in their
  4433. Debug and trace infrastructure:
  4434. @example
  4435. > reg
  4436. ===== ARM registers
  4437. (0) r0 (/32): 0x0000D3C2 (dirty)
  4438. (1) r1 (/32): 0xFD61F31C
  4439. (2) r2 (/32)
  4440. ...
  4441. (164) ETM_contextid_comparator_mask (/32)
  4442. >
  4443. @end example
  4444. @end deffn
  4445. @deffn Command halt [ms]
  4446. @deffnx Command wait_halt [ms]
  4447. The @command{halt} command first sends a halt request to the target,
  4448. which @command{wait_halt} doesn't.
  4449. Otherwise these behave the same: wait up to @var{ms} milliseconds,
  4450. or 5 seconds if there is no parameter, for the target to halt
  4451. (and enter debug mode).
  4452. Using 0 as the @var{ms} parameter prevents OpenOCD from waiting.
  4453. @quotation Warning
  4454. On ARM cores, software using the @emph{wait for interrupt} operation
  4455. often blocks the JTAG access needed by a @command{halt} command.
  4456. This is because that operation also puts the core into a low
  4457. power mode by gating the core clock;
  4458. but the core clock is needed to detect JTAG clock transitions.
  4459. One partial workaround uses adaptive clocking: when the core is
  4460. interrupted the operation completes, then JTAG clocks are accepted
  4461. at least until the interrupt handler completes.
  4462. However, this workaround is often unusable since the processor, board,
  4463. and JTAG adapter must all support adaptive JTAG clocking.
  4464. Also, it can't work until an interrupt is issued.
  4465. A more complete workaround is to not use that operation while you
  4466. work with a JTAG debugger.
  4467. Tasking environments generaly have idle loops where the body is the
  4468. @emph{wait for interrupt} operation.
  4469. (On older cores, it is a coprocessor action;
  4470. newer cores have a @option{wfi} instruction.)
  4471. Such loops can just remove that operation, at the cost of higher
  4472. power consumption (because the CPU is needlessly clocked).
  4473. @end quotation
  4474. @end deffn
  4475. @deffn Command resume [address]
  4476. Resume the target at its current code position,
  4477. or the optional @var{address} if it is provided.
  4478. OpenOCD will wait 5 seconds for the target to resume.
  4479. @end deffn
  4480. @deffn Command step [address]
  4481. Single-step the target at its current code position,
  4482. or the optional @var{address} if it is provided.
  4483. @end deffn
  4484. @anchor{Reset Command}
  4485. @deffn Command reset
  4486. @deffnx Command {reset run}
  4487. @deffnx Command {reset halt}
  4488. @deffnx Command {reset init}
  4489. Perform as hard a reset as possible, using SRST if possible.
  4490. @emph{All defined targets will be reset, and target
  4491. events will fire during the reset sequence.}
  4492. The optional parameter specifies what should
  4493. happen after the reset.
  4494. If there is no parameter, a @command{reset run} is executed.
  4495. The other options will not work on all systems.
  4496. @xref{Reset Configuration}.
  4497. @itemize @minus
  4498. @item @b{run} Let the target run
  4499. @item @b{halt} Immediately halt the target
  4500. @item @b{init} Immediately halt the target, and execute the reset-init script
  4501. @end itemize
  4502. @end deffn
  4503. @deffn Command soft_reset_halt
  4504. Requesting target halt and executing a soft reset. This is often used
  4505. when a target cannot be reset and halted. The target, after reset is
  4506. released begins to execute code. OpenOCD attempts to stop the CPU and
  4507. then sets the program counter back to the reset vector. Unfortunately
  4508. the code that was executed may have left the hardware in an unknown
  4509. state.
  4510. @end deffn
  4511. @section I/O Utilities
  4512. These commands are available when
  4513. OpenOCD is built with @option{--enable-ioutil}.
  4514. They are mainly useful on embedded targets,
  4515. notably the ZY1000.
  4516. Hosts with operating systems have complementary tools.
  4517. @emph{Note:} there are several more such commands.
  4518. @deffn Command append_file filename [string]*
  4519. Appends the @var{string} parameters to
  4520. the text file @file{filename}.
  4521. Each string except the last one is followed by one space.
  4522. The last string is followed by a newline.
  4523. @end deffn
  4524. @deffn Command cat filename
  4525. Reads and displays the text file @file{filename}.
  4526. @end deffn
  4527. @deffn Command cp src_filename dest_filename
  4528. Copies contents from the file @file{src_filename}
  4529. into @file{dest_filename}.
  4530. @end deffn
  4531. @deffn Command ip
  4532. @emph{No description provided.}
  4533. @end deffn
  4534. @deffn Command ls
  4535. @emph{No description provided.}
  4536. @end deffn
  4537. @deffn Command mac
  4538. @emph{No description provided.}
  4539. @end deffn
  4540. @deffn Command meminfo
  4541. Display available RAM memory on OpenOCD host.
  4542. Used in OpenOCD regression testing scripts.
  4543. @end deffn
  4544. @deffn Command peek
  4545. @emph{No description provided.}
  4546. @end deffn
  4547. @deffn Command poke
  4548. @emph{No description provided.}
  4549. @end deffn
  4550. @deffn Command rm filename
  4551. @c "rm" has both normal and Jim-level versions??
  4552. Unlinks the file @file{filename}.
  4553. @end deffn
  4554. @deffn Command trunc filename
  4555. Removes all data in the file @file{filename}.
  4556. @end deffn
  4557. @anchor{Memory access}
  4558. @section Memory access commands
  4559. @cindex memory access
  4560. These commands allow accesses of a specific size to the memory
  4561. system. Often these are used to configure the current target in some
  4562. special way. For example - one may need to write certain values to the
  4563. SDRAM controller to enable SDRAM.
  4564. @enumerate
  4565. @item Use the @command{targets} (plural) command
  4566. to change the current target.
  4567. @item In system level scripts these commands are deprecated.
  4568. Please use their TARGET object siblings to avoid making assumptions
  4569. about what TAP is the current target, or about MMU configuration.
  4570. @end enumerate
  4571. @deffn Command mdw [phys] addr [count]
  4572. @deffnx Command mdh [phys] addr [count]
  4573. @deffnx Command mdb [phys] addr [count]
  4574. Display contents of address @var{addr}, as
  4575. 32-bit words (@command{mdw}), 16-bit halfwords (@command{mdh}),
  4576. or 8-bit bytes (@command{mdb}).
  4577. When the current target has an MMU which is present and active,
  4578. @var{addr} is interpreted as a virtual address.
  4579. Otherwise, or if the optional @var{phys} flag is specified,
  4580. @var{addr} is interpreted as a physical address.
  4581. If @var{count} is specified, displays that many units.
  4582. (If you want to manipulate the data instead of displaying it,
  4583. see the @code{mem2array} primitives.)
  4584. @end deffn
  4585. @deffn Command mww [phys] addr word
  4586. @deffnx Command mwh [phys] addr halfword
  4587. @deffnx Command mwb [phys] addr byte
  4588. Writes the specified @var{word} (32 bits),
  4589. @var{halfword} (16 bits), or @var{byte} (8-bit) value,
  4590. at the specified address @var{addr}.
  4591. When the current target has an MMU which is present and active,
  4592. @var{addr} is interpreted as a virtual address.
  4593. Otherwise, or if the optional @var{phys} flag is specified,
  4594. @var{addr} is interpreted as a physical address.
  4595. @end deffn
  4596. @anchor{Image access}
  4597. @section Image loading commands
  4598. @cindex image loading
  4599. @cindex image dumping
  4600. @anchor{dump_image}
  4601. @deffn Command {dump_image} filename address size
  4602. Dump @var{size} bytes of target memory starting at @var{address} to the
  4603. binary file named @var{filename}.
  4604. @end deffn
  4605. @deffn Command {fast_load}
  4606. Loads an image stored in memory by @command{fast_load_image} to the
  4607. current target. Must be preceeded by fast_load_image.
  4608. @end deffn
  4609. @deffn Command {fast_load_image} filename address [@option{bin}|@option{ihex}|@option{elf}]
  4610. Normally you should be using @command{load_image} or GDB load. However, for
  4611. testing purposes or when I/O overhead is significant(OpenOCD running on an embedded
  4612. host), storing the image in memory and uploading the image to the target
  4613. can be a way to upload e.g. multiple debug sessions when the binary does not change.
  4614. Arguments are the same as @command{load_image}, but the image is stored in OpenOCD host
  4615. memory, i.e. does not affect target. This approach is also useful when profiling
  4616. target programming performance as I/O and target programming can easily be profiled
  4617. separately.
  4618. @end deffn
  4619. @anchor{load_image}
  4620. @deffn Command {load_image} filename address [@option{bin}|@option{ihex}|@option{elf}]
  4621. Load image from file @var{filename} to target memory at @var{address}.
  4622. The file format may optionally be specified
  4623. (@option{bin}, @option{ihex}, or @option{elf})
  4624. @end deffn
  4625. @deffn Command {test_image} filename [address [@option{bin}|@option{ihex}|@option{elf}]]
  4626. Displays image section sizes and addresses
  4627. as if @var{filename} were loaded into target memory
  4628. starting at @var{address} (defaults to zero).
  4629. The file format may optionally be specified
  4630. (@option{bin}, @option{ihex}, or @option{elf})
  4631. @end deffn
  4632. @deffn Command {verify_image} filename address [@option{bin}|@option{ihex}|@option{elf}]
  4633. Verify @var{filename} against target memory starting at @var{address}.
  4634. The file format may optionally be specified
  4635. (@option{bin}, @option{ihex}, or @option{elf})
  4636. This will first attempt a comparison using a CRC checksum, if this fails it will try a binary compare.
  4637. @end deffn
  4638. @section Breakpoint and Watchpoint commands
  4639. @cindex breakpoint
  4640. @cindex watchpoint
  4641. CPUs often make debug modules accessible through JTAG, with
  4642. hardware support for a handful of code breakpoints and data
  4643. watchpoints.
  4644. In addition, CPUs almost always support software breakpoints.
  4645. @deffn Command {bp} [address len [@option{hw}]]
  4646. With no parameters, lists all active breakpoints.
  4647. Else sets a breakpoint on code execution starting
  4648. at @var{address} for @var{length} bytes.
  4649. This is a software breakpoint, unless @option{hw} is specified
  4650. in which case it will be a hardware breakpoint.
  4651. (@xref{arm9 vector_catch}, or @pxref{xscale vector_catch},
  4652. for similar mechanisms that do not consume hardware breakpoints.)
  4653. @end deffn
  4654. @deffn Command {rbp} address
  4655. Remove the breakpoint at @var{address}.
  4656. @end deffn
  4657. @deffn Command {rwp} address
  4658. Remove data watchpoint on @var{address}
  4659. @end deffn
  4660. @deffn Command {wp} [address len [(@option{r}|@option{w}|@option{a}) [value [mask]]]]
  4661. With no parameters, lists all active watchpoints.
  4662. Else sets a data watchpoint on data from @var{address} for @var{length} bytes.
  4663. The watch point is an "access" watchpoint unless
  4664. the @option{r} or @option{w} parameter is provided,
  4665. defining it as respectively a read or write watchpoint.
  4666. If a @var{value} is provided, that value is used when determining if
  4667. the watchpoint should trigger. The value may be first be masked
  4668. using @var{mask} to mark ``don't care'' fields.
  4669. @end deffn
  4670. @section Misc Commands
  4671. @cindex profiling
  4672. @deffn Command {profile} seconds filename
  4673. Profiling samples the CPU's program counter as quickly as possible,
  4674. which is useful for non-intrusive stochastic profiling.
  4675. Saves up to 10000 sampines in @file{filename} using ``gmon.out'' format.
  4676. @end deffn
  4677. @deffn Command {version}
  4678. Displays a string identifying the version of this OpenOCD server.
  4679. @end deffn
  4680. @deffn Command {virt2phys} virtual_address
  4681. Requests the current target to map the specified @var{virtual_address}
  4682. to its corresponding physical address, and displays the result.
  4683. @end deffn
  4684. @node Architecture and Core Commands
  4685. @chapter Architecture and Core Commands
  4686. @cindex Architecture Specific Commands
  4687. @cindex Core Specific Commands
  4688. Most CPUs have specialized JTAG operations to support debugging.
  4689. OpenOCD packages most such operations in its standard command framework.
  4690. Some of those operations don't fit well in that framework, so they are
  4691. exposed here as architecture or implementation (core) specific commands.
  4692. @anchor{ARM Hardware Tracing}
  4693. @section ARM Hardware Tracing
  4694. @cindex tracing
  4695. @cindex ETM
  4696. @cindex ETB
  4697. CPUs based on ARM cores may include standard tracing interfaces,
  4698. based on an ``Embedded Trace Module'' (ETM) which sends voluminous
  4699. address and data bus trace records to a ``Trace Port''.
  4700. @itemize
  4701. @item
  4702. Development-oriented boards will sometimes provide a high speed
  4703. trace connector for collecting that data, when the particular CPU
  4704. supports such an interface.
  4705. (The standard connector is a 38-pin Mictor, with both JTAG
  4706. and trace port support.)
  4707. Those trace connectors are supported by higher end JTAG adapters
  4708. and some logic analyzer modules; frequently those modules can
  4709. buffer several megabytes of trace data.
  4710. Configuring an ETM coupled to such an external trace port belongs
  4711. in the board-specific configuration file.
  4712. @item
  4713. If the CPU doesn't provide an external interface, it probably
  4714. has an ``Embedded Trace Buffer'' (ETB) on the chip, which is a
  4715. dedicated SRAM. 4KBytes is one common ETB size.
  4716. Configuring an ETM coupled only to an ETB belongs in the CPU-specific
  4717. (target) configuration file, since it works the same on all boards.
  4718. @end itemize
  4719. ETM support in OpenOCD doesn't seem to be widely used yet.
  4720. @quotation Issues
  4721. ETM support may be buggy, and at least some @command{etm config}
  4722. parameters should be detected by asking the ETM for them.
  4723. ETM trigger events could also implement a kind of complex
  4724. hardware breakpoint, much more powerful than the simple
  4725. watchpoint hardware exported by EmbeddedICE modules.
  4726. @emph{Such breakpoints can be triggered even when using the
  4727. dummy trace port driver}.
  4728. It seems like a GDB hookup should be possible,
  4729. as well as tracing only during specific states
  4730. (perhaps @emph{handling IRQ 23} or @emph{calls foo()}).
  4731. There should be GUI tools to manipulate saved trace data and help
  4732. analyse it in conjunction with the source code.
  4733. It's unclear how much of a common interface is shared
  4734. with the current XScale trace support, or should be
  4735. shared with eventual Nexus-style trace module support.
  4736. At this writing (November 2009) only ARM7, ARM9, and ARM11 support
  4737. for ETM modules is available. The code should be able to
  4738. work with some newer cores; but not all of them support
  4739. this original style of JTAG access.
  4740. @end quotation
  4741. @subsection ETM Configuration
  4742. ETM setup is coupled with the trace port driver configuration.
  4743. @deffn {Config Command} {etm config} target width mode clocking driver
  4744. Declares the ETM associated with @var{target}, and associates it
  4745. with a given trace port @var{driver}. @xref{Trace Port Drivers}.
  4746. Several of the parameters must reflect the trace port capabilities,
  4747. which are a function of silicon capabilties (exposed later
  4748. using @command{etm info}) and of what hardware is connected to
  4749. that port (such as an external pod, or ETB).
  4750. The @var{width} must be either 4, 8, or 16,
  4751. except with ETMv3.0 and newer modules which may also
  4752. support 1, 2, 24, 32, 48, and 64 bit widths.
  4753. (With those versions, @command{etm info} also shows whether
  4754. the selected port width and mode are supported.)
  4755. The @var{mode} must be @option{normal}, @option{multiplexed},
  4756. or @option{demultiplexed}.
  4757. The @var{clocking} must be @option{half} or @option{full}.
  4758. @quotation Warning
  4759. With ETMv3.0 and newer, the bits set with the @var{mode} and
  4760. @var{clocking} parameters both control the mode.
  4761. This modified mode does not map to the values supported by
  4762. previous ETM modules, so this syntax is subject to change.
  4763. @end quotation
  4764. @quotation Note
  4765. You can see the ETM registers using the @command{reg} command.
  4766. Not all possible registers are present in every ETM.
  4767. Most of the registers are write-only, and are used to configure
  4768. what CPU activities are traced.
  4769. @end quotation
  4770. @end deffn
  4771. @deffn Command {etm info}
  4772. Displays information about the current target's ETM.
  4773. This includes resource counts from the @code{ETM_CONFIG} register,
  4774. as well as silicon capabilities (except on rather old modules).
  4775. from the @code{ETM_SYS_CONFIG} register.
  4776. @end deffn
  4777. @deffn Command {etm status}
  4778. Displays status of the current target's ETM and trace port driver:
  4779. is the ETM idle, or is it collecting data?
  4780. Did trace data overflow?
  4781. Was it triggered?
  4782. @end deffn
  4783. @deffn Command {etm tracemode} [type context_id_bits cycle_accurate branch_output]
  4784. Displays what data that ETM will collect.
  4785. If arguments are provided, first configures that data.
  4786. When the configuration changes, tracing is stopped
  4787. and any buffered trace data is invalidated.
  4788. @itemize
  4789. @item @var{type} ... describing how data accesses are traced,
  4790. when they pass any ViewData filtering that that was set up.
  4791. The value is one of
  4792. @option{none} (save nothing),
  4793. @option{data} (save data),
  4794. @option{address} (save addresses),
  4795. @option{all} (save data and addresses)
  4796. @item @var{context_id_bits} ... 0, 8, 16, or 32
  4797. @item @var{cycle_accurate} ... @option{enable} or @option{disable}
  4798. cycle-accurate instruction tracing.
  4799. Before ETMv3, enabling this causes much extra data to be recorded.
  4800. @item @var{branch_output} ... @option{enable} or @option{disable}.
  4801. Disable this unless you need to try reconstructing the instruction
  4802. trace stream without an image of the code.
  4803. @end itemize
  4804. @end deffn
  4805. @deffn Command {etm trigger_debug} (@option{enable}|@option{disable})
  4806. Displays whether ETM triggering debug entry (like a breakpoint) is
  4807. enabled or disabled, after optionally modifying that configuration.
  4808. The default behaviour is @option{disable}.
  4809. Any change takes effect after the next @command{etm start}.
  4810. By using script commands to configure ETM registers, you can make the
  4811. processor enter debug state automatically when certain conditions,
  4812. more complex than supported by the breakpoint hardware, happen.
  4813. @end deffn
  4814. @subsection ETM Trace Operation
  4815. After setting up the ETM, you can use it to collect data.
  4816. That data can be exported to files for later analysis.
  4817. It can also be parsed with OpenOCD, for basic sanity checking.
  4818. To configure what is being traced, you will need to write
  4819. various trace registers using @command{reg ETM_*} commands.
  4820. For the definitions of these registers, read ARM publication
  4821. @emph{IHI 0014, ``Embedded Trace Macrocell, Architecture Specification''}.
  4822. Be aware that most of the relevant registers are write-only,
  4823. and that ETM resources are limited. There are only a handful
  4824. of address comparators, data comparators, counters, and so on.
  4825. Examples of scenarios you might arrange to trace include:
  4826. @itemize
  4827. @item Code flow within a function, @emph{excluding} subroutines
  4828. it calls. Use address range comparators to enable tracing
  4829. for instruction access within that function's body.
  4830. @item Code flow within a function, @emph{including} subroutines
  4831. it calls. Use the sequencer and address comparators to activate
  4832. tracing on an ``entered function'' state, then deactivate it by
  4833. exiting that state when the function's exit code is invoked.
  4834. @item Code flow starting at the fifth invocation of a function,
  4835. combining one of the above models with a counter.
  4836. @item CPU data accesses to the registers for a particular device,
  4837. using address range comparators and the ViewData logic.
  4838. @item Such data accesses only during IRQ handling, combining the above
  4839. model with sequencer triggers which on entry and exit to the IRQ handler.
  4840. @item @emph{... more}
  4841. @end itemize
  4842. At this writing, September 2009, there are no Tcl utility
  4843. procedures to help set up any common tracing scenarios.
  4844. @deffn Command {etm analyze}
  4845. Reads trace data into memory, if it wasn't already present.
  4846. Decodes and prints the data that was collected.
  4847. @end deffn
  4848. @deffn Command {etm dump} filename
  4849. Stores the captured trace data in @file{filename}.
  4850. @end deffn
  4851. @deffn Command {etm image} filename [base_address] [type]
  4852. Opens an image file.
  4853. @end deffn
  4854. @deffn Command {etm load} filename
  4855. Loads captured trace data from @file{filename}.
  4856. @end deffn
  4857. @deffn Command {etm start}
  4858. Starts trace data collection.
  4859. @end deffn
  4860. @deffn Command {etm stop}
  4861. Stops trace data collection.
  4862. @end deffn
  4863. @anchor{Trace Port Drivers}
  4864. @subsection Trace Port Drivers
  4865. To use an ETM trace port it must be associated with a driver.
  4866. @deffn {Trace Port Driver} dummy
  4867. Use the @option{dummy} driver if you are configuring an ETM that's
  4868. not connected to anything (on-chip ETB or off-chip trace connector).
  4869. @emph{This driver lets OpenOCD talk to the ETM, but it does not expose
  4870. any trace data collection.}
  4871. @deffn {Config Command} {etm_dummy config} target
  4872. Associates the ETM for @var{target} with a dummy driver.
  4873. @end deffn
  4874. @end deffn
  4875. @deffn {Trace Port Driver} etb
  4876. Use the @option{etb} driver if you are configuring an ETM
  4877. to use on-chip ETB memory.
  4878. @deffn {Config Command} {etb config} target etb_tap
  4879. Associates the ETM for @var{target} with the ETB at @var{etb_tap}.
  4880. You can see the ETB registers using the @command{reg} command.
  4881. @end deffn
  4882. @deffn Command {etb trigger_percent} [percent]
  4883. This displays, or optionally changes, ETB behavior after the
  4884. ETM's configured @emph{trigger} event fires.
  4885. It controls how much more trace data is saved after the (single)
  4886. trace trigger becomes active.
  4887. @itemize
  4888. @item The default corresponds to @emph{trace around} usage,
  4889. recording 50 percent data before the event and the rest
  4890. afterwards.
  4891. @item The minimum value of @var{percent} is 2 percent,
  4892. recording almost exclusively data before the trigger.
  4893. Such extreme @emph{trace before} usage can help figure out
  4894. what caused that event to happen.
  4895. @item The maximum value of @var{percent} is 100 percent,
  4896. recording data almost exclusively after the event.
  4897. This extreme @emph{trace after} usage might help sort out
  4898. how the event caused trouble.
  4899. @end itemize
  4900. @c REVISIT allow "break" too -- enter debug mode.
  4901. @end deffn
  4902. @end deffn
  4903. @deffn {Trace Port Driver} oocd_trace
  4904. This driver isn't available unless OpenOCD was explicitly configured
  4905. with the @option{--enable-oocd_trace} option. You probably don't want
  4906. to configure it unless you've built the appropriate prototype hardware;
  4907. it's @emph{proof-of-concept} software.
  4908. Use the @option{oocd_trace} driver if you are configuring an ETM that's
  4909. connected to an off-chip trace connector.
  4910. @deffn {Config Command} {oocd_trace config} target tty
  4911. Associates the ETM for @var{target} with a trace driver which
  4912. collects data through the serial port @var{tty}.
  4913. @end deffn
  4914. @deffn Command {oocd_trace resync}
  4915. Re-synchronizes with the capture clock.
  4916. @end deffn
  4917. @deffn Command {oocd_trace status}
  4918. Reports whether the capture clock is locked or not.
  4919. @end deffn
  4920. @end deffn
  4921. @section Generic ARM
  4922. @cindex ARM
  4923. These commands should be available on all ARM processors.
  4924. They are available in addition to other core-specific
  4925. commands that may be available.
  4926. @deffn Command {arm core_state} [@option{arm}|@option{thumb}]
  4927. Displays the core_state, optionally changing it to process
  4928. either @option{arm} or @option{thumb} instructions.
  4929. The target may later be resumed in the currently set core_state.
  4930. (Processors may also support the Jazelle state, but
  4931. that is not currently supported in OpenOCD.)
  4932. @end deffn
  4933. @deffn Command {arm disassemble} address [count [@option{thumb}]]
  4934. @cindex disassemble
  4935. Disassembles @var{count} instructions starting at @var{address}.
  4936. If @var{count} is not specified, a single instruction is disassembled.
  4937. If @option{thumb} is specified, or the low bit of the address is set,
  4938. Thumb2 (mixed 16/32-bit) instructions are used;
  4939. else ARM (32-bit) instructions are used.
  4940. (Processors may also support the Jazelle state, but
  4941. those instructions are not currently understood by OpenOCD.)
  4942. Note that all Thumb instructions are Thumb2 instructions,
  4943. so older processors (without Thumb2 support) will still
  4944. see correct disassembly of Thumb code.
  4945. Also, ThumbEE opcodes are the same as Thumb2,
  4946. with a handful of exceptions.
  4947. ThumbEE disassembly currently has no explicit support.
  4948. @end deffn
  4949. @deffn Command {arm mcr} pX op1 CRn CRm op2 value
  4950. Write @var{value} to a coprocessor @var{pX} register
  4951. passing parameters @var{CRn},
  4952. @var{CRm}, opcodes @var{opc1} and @var{opc2},
  4953. and using the MCR instruction.
  4954. (Parameter sequence matches the ARM instruction, but omits
  4955. an ARM register.)
  4956. @end deffn
  4957. @deffn Command {arm mrc} pX coproc op1 CRn CRm op2
  4958. Read a coprocessor @var{pX} register passing parameters @var{CRn},
  4959. @var{CRm}, opcodes @var{opc1} and @var{opc2},
  4960. and the MRC instruction.
  4961. Returns the result so it can be manipulated by Jim scripts.
  4962. (Parameter sequence matches the ARM instruction, but omits
  4963. an ARM register.)
  4964. @end deffn
  4965. @deffn Command {arm reg}
  4966. Display a table of all banked core registers, fetching the current value from every
  4967. core mode if necessary.
  4968. @end deffn
  4969. @section ARMv4 and ARMv5 Architecture
  4970. @cindex ARMv4
  4971. @cindex ARMv5
  4972. The ARMv4 and ARMv5 architectures are widely used in embedded systems,
  4973. and introduced core parts of the instruction set in use today.
  4974. That includes the Thumb instruction set, introduced in the ARMv4T
  4975. variant.
  4976. @subsection ARM7 and ARM9 specific commands
  4977. @cindex ARM7
  4978. @cindex ARM9
  4979. These commands are specific to ARM7 and ARM9 cores, like ARM7TDMI, ARM720T,
  4980. ARM9TDMI, ARM920T or ARM926EJ-S.
  4981. They are available in addition to the ARM commands,
  4982. and any other core-specific commands that may be available.
  4983. @deffn Command {arm7_9 dbgrq} [@option{enable}|@option{disable}]
  4984. Displays the value of the flag controlling use of the
  4985. the EmbeddedIce DBGRQ signal to force entry into debug mode,
  4986. instead of breakpoints.
  4987. If a boolean parameter is provided, first assigns that flag.
  4988. This should be
  4989. safe for all but ARM7TDMI-S cores (like NXP LPC).
  4990. This feature is enabled by default on most ARM9 cores,
  4991. including ARM9TDMI, ARM920T, and ARM926EJ-S.
  4992. @end deffn
  4993. @deffn Command {arm7_9 dcc_downloads} [@option{enable}|@option{disable}]
  4994. @cindex DCC
  4995. Displays the value of the flag controlling use of the debug communications
  4996. channel (DCC) to write larger (>128 byte) amounts of memory.
  4997. If a boolean parameter is provided, first assigns that flag.
  4998. DCC downloads offer a huge speed increase, but might be
  4999. unsafe, especially with targets running at very low speeds. This command was introduced
  5000. with OpenOCD rev. 60, and requires a few bytes of working area.
  5001. @end deffn
  5002. @anchor{arm7_9 fast_memory_access}
  5003. @deffn Command {arm7_9 fast_memory_access} [@option{enable}|@option{disable}]
  5004. Displays the value of the flag controlling use of memory writes and reads
  5005. that don't check completion of the operation.
  5006. If a boolean parameter is provided, first assigns that flag.
  5007. This provides a huge speed increase, especially with USB JTAG
  5008. cables (FT2232), but might be unsafe if used with targets running at very low
  5009. speeds, like the 32kHz startup clock of an AT91RM9200.
  5010. @end deffn
  5011. @deffn Command {arm7_9 semihosting} [@option{enable}|@option{disable}]
  5012. @cindex ARM semihosting
  5013. Display status of semihosting, after optionally changing that status.
  5014. Semihosting allows for code executing on an ARM target to use the
  5015. I/O facilities on the host computer i.e. the system where OpenOCD
  5016. is running. The target application must be linked against a library
  5017. implementing the ARM semihosting convention that forwards operation
  5018. requests by using a special SVC instruction that is trapped at the
  5019. Supervisor Call vector by OpenOCD.
  5020. @end deffn
  5021. @subsection ARM720T specific commands
  5022. @cindex ARM720T
  5023. These commands are available to ARM720T based CPUs,
  5024. which are implementations of the ARMv4T architecture
  5025. based on the ARM7TDMI-S integer core.
  5026. They are available in addition to the ARM and ARM7/ARM9 commands.
  5027. @deffn Command {arm720t cp15} opcode [value]
  5028. @emph{DEPRECATED -- avoid using this.
  5029. Use the @command{arm mrc} or @command{arm mcr} commands instead.}
  5030. Display cp15 register returned by the ARM instruction @var{opcode};
  5031. else if a @var{value} is provided, that value is written to that register.
  5032. The @var{opcode} should be the value of either an MRC or MCR instruction.
  5033. @end deffn
  5034. @subsection ARM9 specific commands
  5035. @cindex ARM9
  5036. ARM9-family cores are built around ARM9TDMI or ARM9E (including ARM9EJS)
  5037. integer processors.
  5038. Such cores include the ARM920T, ARM926EJ-S, and ARM966.
  5039. @c 9-june-2009: tried this on arm920t, it didn't work.
  5040. @c no-params always lists nothing caught, and that's how it acts.
  5041. @c 23-oct-2009: doesn't work _consistently_ ... as if the ICE
  5042. @c versions have different rules about when they commit writes.
  5043. @anchor{arm9 vector_catch}
  5044. @deffn Command {arm9 vector_catch} [@option{all}|@option{none}|list]
  5045. @cindex vector_catch
  5046. Vector Catch hardware provides a sort of dedicated breakpoint
  5047. for hardware events such as reset, interrupt, and abort.
  5048. You can use this to conserve normal breakpoint resources,
  5049. so long as you're not concerned with code that branches directly
  5050. to those hardware vectors.
  5051. This always finishes by listing the current configuration.
  5052. If parameters are provided, it first reconfigures the
  5053. vector catch hardware to intercept
  5054. @option{all} of the hardware vectors,
  5055. @option{none} of them,
  5056. or a list with one or more of the following:
  5057. @option{reset} @option{undef} @option{swi} @option{pabt} @option{dabt}
  5058. @option{irq} @option{fiq}.
  5059. @end deffn
  5060. @subsection ARM920T specific commands
  5061. @cindex ARM920T
  5062. These commands are available to ARM920T based CPUs,
  5063. which are implementations of the ARMv4T architecture
  5064. built using the ARM9TDMI integer core.
  5065. They are available in addition to the ARM, ARM7/ARM9,
  5066. and ARM9 commands.
  5067. @deffn Command {arm920t cache_info}
  5068. Print information about the caches found. This allows to see whether your target
  5069. is an ARM920T (2x16kByte cache) or ARM922T (2x8kByte cache).
  5070. @end deffn
  5071. @deffn Command {arm920t cp15} regnum [value]
  5072. Display cp15 register @var{regnum};
  5073. else if a @var{value} is provided, that value is written to that register.
  5074. This uses "physical access" and the register number is as
  5075. shown in bits 38..33 of table 9-9 in the ARM920T TRM.
  5076. (Not all registers can be written.)
  5077. @end deffn
  5078. @deffn Command {arm920t cp15i} opcode [value [address]]
  5079. @emph{DEPRECATED -- avoid using this.
  5080. Use the @command{arm mrc} or @command{arm mcr} commands instead.}
  5081. Interpreted access using ARM instruction @var{opcode}, which should
  5082. be the value of either an MRC or MCR instruction
  5083. (as shown tables 9-11, 9-12, and 9-13 in the ARM920T TRM).
  5084. If no @var{value} is provided, the result is displayed.
  5085. Else if that value is written using the specified @var{address},
  5086. or using zero if no other address is provided.
  5087. @end deffn
  5088. @deffn Command {arm920t read_cache} filename
  5089. Dump the content of ICache and DCache to a file named @file{filename}.
  5090. @end deffn
  5091. @deffn Command {arm920t read_mmu} filename
  5092. Dump the content of the ITLB and DTLB to a file named @file{filename}.
  5093. @end deffn
  5094. @subsection ARM926ej-s specific commands
  5095. @cindex ARM926ej-s
  5096. These commands are available to ARM926ej-s based CPUs,
  5097. which are implementations of the ARMv5TEJ architecture
  5098. based on the ARM9EJ-S integer core.
  5099. They are available in addition to the ARM, ARM7/ARM9,
  5100. and ARM9 commands.
  5101. The Feroceon cores also support these commands, although
  5102. they are not built from ARM926ej-s designs.
  5103. @deffn Command {arm926ejs cache_info}
  5104. Print information about the caches found.
  5105. @end deffn
  5106. @subsection ARM966E specific commands
  5107. @cindex ARM966E
  5108. These commands are available to ARM966 based CPUs,
  5109. which are implementations of the ARMv5TE architecture.
  5110. They are available in addition to the ARM, ARM7/ARM9,
  5111. and ARM9 commands.
  5112. @deffn Command {arm966e cp15} regnum [value]
  5113. Display cp15 register @var{regnum};
  5114. else if a @var{value} is provided, that value is written to that register.
  5115. The six bit @var{regnum} values are bits 37..32 from table 7-2 of the
  5116. ARM966E-S TRM.
  5117. There is no current control over bits 31..30 from that table,
  5118. as required for BIST support.
  5119. @end deffn
  5120. @subsection XScale specific commands
  5121. @cindex XScale
  5122. Some notes about the debug implementation on the XScale CPUs:
  5123. The XScale CPU provides a special debug-only mini-instruction cache
  5124. (mini-IC) in which exception vectors and target-resident debug handler
  5125. code are placed by OpenOCD. In order to get access to the CPU, OpenOCD
  5126. must point vector 0 (the reset vector) to the entry of the debug
  5127. handler. However, this means that the complete first cacheline in the
  5128. mini-IC is marked valid, which makes the CPU fetch all exception
  5129. handlers from the mini-IC, ignoring the code in RAM.
  5130. OpenOCD currently does not sync the mini-IC entries with the RAM
  5131. contents (which would fail anyway while the target is running), so
  5132. the user must provide appropriate values using the @code{xscale
  5133. vector_table} command.
  5134. It is recommended to place a pc-relative indirect branch in the vector
  5135. table, and put the branch destination somewhere in memory. Doing so
  5136. makes sure the code in the vector table stays constant regardless of
  5137. code layout in memory:
  5138. @example
  5139. _vectors:
  5140. ldr pc,[pc,#0x100-8]
  5141. ldr pc,[pc,#0x100-8]
  5142. ldr pc,[pc,#0x100-8]
  5143. ldr pc,[pc,#0x100-8]
  5144. ldr pc,[pc,#0x100-8]
  5145. ldr pc,[pc,#0x100-8]
  5146. ldr pc,[pc,#0x100-8]
  5147. ldr pc,[pc,#0x100-8]
  5148. .org 0x100
  5149. .long real_reset_vector
  5150. .long real_ui_handler
  5151. .long real_swi_handler
  5152. .long real_pf_abort
  5153. .long real_data_abort
  5154. .long 0 /* unused */
  5155. .long real_irq_handler
  5156. .long real_fiq_handler
  5157. @end example
  5158. The debug handler must be placed somewhere in the address space using
  5159. the @code{xscale debug_handler} command. The allowed locations for the
  5160. debug handler are either (0x800 - 0x1fef800) or (0xfe000800 -
  5161. 0xfffff800). The default value is 0xfe000800.
  5162. These commands are available to XScale based CPUs,
  5163. which are implementations of the ARMv5TE architecture.
  5164. @deffn Command {xscale analyze_trace}
  5165. Displays the contents of the trace buffer.
  5166. @end deffn
  5167. @deffn Command {xscale cache_clean_address} address
  5168. Changes the address used when cleaning the data cache.
  5169. @end deffn
  5170. @deffn Command {xscale cache_info}
  5171. Displays information about the CPU caches.
  5172. @end deffn
  5173. @deffn Command {xscale cp15} regnum [value]
  5174. Display cp15 register @var{regnum};
  5175. else if a @var{value} is provided, that value is written to that register.
  5176. @end deffn
  5177. @deffn Command {xscale debug_handler} target address
  5178. Changes the address used for the specified target's debug handler.
  5179. @end deffn
  5180. @deffn Command {xscale dcache} [@option{enable}|@option{disable}]
  5181. Enables or disable the CPU's data cache.
  5182. @end deffn
  5183. @deffn Command {xscale dump_trace} filename
  5184. Dumps the raw contents of the trace buffer to @file{filename}.
  5185. @end deffn
  5186. @deffn Command {xscale icache} [@option{enable}|@option{disable}]
  5187. Enables or disable the CPU's instruction cache.
  5188. @end deffn
  5189. @deffn Command {xscale mmu} [@option{enable}|@option{disable}]
  5190. Enables or disable the CPU's memory management unit.
  5191. @end deffn
  5192. @deffn Command {xscale trace_buffer} [@option{enable}|@option{disable} [@option{fill} [n] | @option{wrap}]]
  5193. Displays the trace buffer status, after optionally
  5194. enabling or disabling the trace buffer
  5195. and modifying how it is emptied.
  5196. @end deffn
  5197. @deffn Command {xscale trace_image} filename [offset [type]]
  5198. Opens a trace image from @file{filename}, optionally rebasing
  5199. its segment addresses by @var{offset}.
  5200. The image @var{type} may be one of
  5201. @option{bin} (binary), @option{ihex} (Intel hex),
  5202. @option{elf} (ELF file), @option{s19} (Motorola s19),
  5203. @option{mem}, or @option{builder}.
  5204. @end deffn
  5205. @anchor{xscale vector_catch}
  5206. @deffn Command {xscale vector_catch} [mask]
  5207. @cindex vector_catch
  5208. Display a bitmask showing the hardware vectors to catch.
  5209. If the optional parameter is provided, first set the bitmask to that value.
  5210. The mask bits correspond with bit 16..23 in the DCSR:
  5211. @example
  5212. 0x01 Trap Reset
  5213. 0x02 Trap Undefined Instructions
  5214. 0x04 Trap Software Interrupt
  5215. 0x08 Trap Prefetch Abort
  5216. 0x10 Trap Data Abort
  5217. 0x20 reserved
  5218. 0x40 Trap IRQ
  5219. 0x80 Trap FIQ
  5220. @end example
  5221. @end deffn
  5222. @anchor{xscale vector_table}
  5223. @deffn Command {xscale vector_table} [(@option{low}|@option{high}) index value]
  5224. @cindex vector_table
  5225. Set an entry in the mini-IC vector table. There are two tables: one for
  5226. low vectors (at 0x00000000), and one for high vectors (0xFFFF0000), each
  5227. holding the 8 exception vectors. @var{index} can be 1-7, because vector 0
  5228. points to the debug handler entry and can not be overwritten.
  5229. @var{value} holds the 32-bit opcode that is placed in the mini-IC.
  5230. Without arguments, the current settings are displayed.
  5231. @end deffn
  5232. @section ARMv6 Architecture
  5233. @cindex ARMv6
  5234. @subsection ARM11 specific commands
  5235. @cindex ARM11
  5236. @deffn Command {arm11 memwrite burst} [@option{enable}|@option{disable}]
  5237. Displays the value of the memwrite burst-enable flag,
  5238. which is enabled by default.
  5239. If a boolean parameter is provided, first assigns that flag.
  5240. Burst writes are only used for memory writes larger than 1 word.
  5241. They improve performance by assuming that the CPU has read each data
  5242. word over JTAG and completed its write before the next word arrives,
  5243. instead of polling for a status flag to verify that completion.
  5244. This is usually safe, because JTAG runs much slower than the CPU.
  5245. @end deffn
  5246. @deffn Command {arm11 memwrite error_fatal} [@option{enable}|@option{disable}]
  5247. Displays the value of the memwrite error_fatal flag,
  5248. which is enabled by default.
  5249. If a boolean parameter is provided, first assigns that flag.
  5250. When set, certain memory write errors cause earlier transfer termination.
  5251. @end deffn
  5252. @deffn Command {arm11 step_irq_enable} [@option{enable}|@option{disable}]
  5253. Displays the value of the flag controlling whether
  5254. IRQs are enabled during single stepping;
  5255. they are disabled by default.
  5256. If a boolean parameter is provided, first assigns that.
  5257. @end deffn
  5258. @deffn Command {arm11 vcr} [value]
  5259. @cindex vector_catch
  5260. Displays the value of the @emph{Vector Catch Register (VCR)},
  5261. coprocessor 14 register 7.
  5262. If @var{value} is defined, first assigns that.
  5263. Vector Catch hardware provides dedicated breakpoints
  5264. for certain hardware events.
  5265. The specific bit values are core-specific (as in fact is using
  5266. coprocessor 14 register 7 itself) but all current ARM11
  5267. cores @emph{except the ARM1176} use the same six bits.
  5268. @end deffn
  5269. @section ARMv7 Architecture
  5270. @cindex ARMv7
  5271. @subsection ARMv7 Debug Access Port (DAP) specific commands
  5272. @cindex Debug Access Port
  5273. @cindex DAP
  5274. These commands are specific to ARM architecture v7 Debug Access Port (DAP),
  5275. included on Cortex-M3 and Cortex-A8 systems.
  5276. They are available in addition to other core-specific commands that may be available.
  5277. @deffn Command {dap apid} [num]
  5278. Displays ID register from AP @var{num},
  5279. defaulting to the currently selected AP.
  5280. @end deffn
  5281. @deffn Command {dap apsel} [num]
  5282. Select AP @var{num}, defaulting to 0.
  5283. @end deffn
  5284. @deffn Command {dap baseaddr} [num]
  5285. Displays debug base address from MEM-AP @var{num},
  5286. defaulting to the currently selected AP.
  5287. @end deffn
  5288. @deffn Command {dap info} [num]
  5289. Displays the ROM table for MEM-AP @var{num},
  5290. defaulting to the currently selected AP.
  5291. @end deffn
  5292. @deffn Command {dap memaccess} [value]
  5293. Displays the number of extra tck cycles in the JTAG idle to use for MEM-AP
  5294. memory bus access [0-255], giving additional time to respond to reads.
  5295. If @var{value} is defined, first assigns that.
  5296. @end deffn
  5297. @subsection Cortex-M3 specific commands
  5298. @cindex Cortex-M3
  5299. @deffn Command {cortex_m3 disassemble} address [count]
  5300. @cindex disassemble
  5301. Disassembles @var{count} Thumb2 instructions starting at @var{address}.
  5302. If @var{count} is not specified, a single instruction is disassembled.
  5303. @end deffn
  5304. @deffn Command {cortex_m3 maskisr} (@option{on}|@option{off})
  5305. Control masking (disabling) interrupts during target step/resume.
  5306. @end deffn
  5307. @deffn Command {cortex_m3 vector_catch} [@option{all}|@option{none}|list]
  5308. @cindex vector_catch
  5309. Vector Catch hardware provides dedicated breakpoints
  5310. for certain hardware events.
  5311. Parameters request interception of
  5312. @option{all} of these hardware event vectors,
  5313. @option{none} of them,
  5314. or one or more of the following:
  5315. @option{hard_err} for a HardFault exception;
  5316. @option{mm_err} for a MemManage exception;
  5317. @option{bus_err} for a BusFault exception;
  5318. @option{irq_err},
  5319. @option{state_err},
  5320. @option{chk_err}, or
  5321. @option{nocp_err} for various UsageFault exceptions; or
  5322. @option{reset}.
  5323. If NVIC setup code does not enable them,
  5324. MemManage, BusFault, and UsageFault exceptions
  5325. are mapped to HardFault.
  5326. UsageFault checks for
  5327. divide-by-zero and unaligned access
  5328. must also be explicitly enabled.
  5329. This finishes by listing the current vector catch configuration.
  5330. @end deffn
  5331. @anchor{Software Debug Messages and Tracing}
  5332. @section Software Debug Messages and Tracing
  5333. @cindex Linux-ARM DCC support
  5334. @cindex tracing
  5335. @cindex libdcc
  5336. @cindex DCC
  5337. OpenOCD can process certain requests from target software, when
  5338. the target uses appropriate libraries.
  5339. The most powerful mechanism is semihosting, but there is also
  5340. a lighter weight mechanism using only the DCC channel.
  5341. Currently @command{target_request debugmsgs}
  5342. is supported only for @option{arm7_9} and @option{cortex_m3} cores.
  5343. These messages are received as part of target polling, so
  5344. you need to have @command{poll on} active to receive them.
  5345. They are intrusive in that they will affect program execution
  5346. times. If that is a problem, @pxref{ARM Hardware Tracing}.
  5347. See @file{libdcc} in the contrib dir for more details.
  5348. In addition to sending strings, characters, and
  5349. arrays of various size integers from the target,
  5350. @file{libdcc} also exports a software trace point mechanism.
  5351. The target being debugged may
  5352. issue trace messages which include a 24-bit @dfn{trace point} number.
  5353. Trace point support includes two distinct mechanisms,
  5354. each supported by a command:
  5355. @itemize
  5356. @item @emph{History} ... A circular buffer of trace points
  5357. can be set up, and then displayed at any time.
  5358. This tracks where code has been, which can be invaluable in
  5359. finding out how some fault was triggered.
  5360. The buffer may overflow, since it collects records continuously.
  5361. It may be useful to use some of the 24 bits to represent a
  5362. particular event, and other bits to hold data.
  5363. @item @emph{Counting} ... An array of counters can be set up,
  5364. and then displayed at any time.
  5365. This can help establish code coverage and identify hot spots.
  5366. The array of counters is directly indexed by the trace point
  5367. number, so trace points with higher numbers are not counted.
  5368. @end itemize
  5369. Linux-ARM kernels have a ``Kernel low-level debugging
  5370. via EmbeddedICE DCC channel'' option (CONFIG_DEBUG_ICEDCC,
  5371. depends on CONFIG_DEBUG_LL) which uses this mechanism to
  5372. deliver messages before a serial console can be activated.
  5373. This is not the same format used by @file{libdcc}.
  5374. Other software, such as the U-Boot boot loader, sometimes
  5375. does the same thing.
  5376. @deffn Command {target_request debugmsgs} [@option{enable}|@option{disable}|@option{charmsg}]
  5377. Displays current handling of target DCC message requests.
  5378. These messages may be sent to the debugger while the target is running.
  5379. The optional @option{enable} and @option{charmsg} parameters
  5380. both enable the messages, while @option{disable} disables them.
  5381. With @option{charmsg} the DCC words each contain one character,
  5382. as used by Linux with CONFIG_DEBUG_ICEDCC;
  5383. otherwise the libdcc format is used.
  5384. @end deffn
  5385. @deffn Command {trace history} [@option{clear}|count]
  5386. With no parameter, displays all the trace points that have triggered
  5387. in the order they triggered.
  5388. With the parameter @option{clear}, erases all current trace history records.
  5389. With a @var{count} parameter, allocates space for that many
  5390. history records.
  5391. @end deffn
  5392. @deffn Command {trace point} [@option{clear}|identifier]
  5393. With no parameter, displays all trace point identifiers and how many times
  5394. they have been triggered.
  5395. With the parameter @option{clear}, erases all current trace point counters.
  5396. With a numeric @var{identifier} parameter, creates a new a trace point counter
  5397. and associates it with that identifier.
  5398. @emph{Important:} The identifier and the trace point number
  5399. are not related except by this command.
  5400. These trace point numbers always start at zero (from server startup,
  5401. or after @command{trace point clear}) and count up from there.
  5402. @end deffn
  5403. @node JTAG Commands
  5404. @chapter JTAG Commands
  5405. @cindex JTAG Commands
  5406. Most general purpose JTAG commands have been presented earlier.
  5407. (@xref{JTAG Speed}, @ref{Reset Configuration}, and @ref{TAP Declaration}.)
  5408. Lower level JTAG commands, as presented here,
  5409. may be needed to work with targets which require special
  5410. attention during operations such as reset or initialization.
  5411. To use these commands you will need to understand some
  5412. of the basics of JTAG, including:
  5413. @itemize @bullet
  5414. @item A JTAG scan chain consists of a sequence of individual TAP
  5415. devices such as a CPUs.
  5416. @item Control operations involve moving each TAP through the same
  5417. standard state machine (in parallel)
  5418. using their shared TMS and clock signals.
  5419. @item Data transfer involves shifting data through the chain of
  5420. instruction or data registers of each TAP, writing new register values
  5421. while the reading previous ones.
  5422. @item Data register sizes are a function of the instruction active in
  5423. a given TAP, while instruction register sizes are fixed for each TAP.
  5424. All TAPs support a BYPASS instruction with a single bit data register.
  5425. @item The way OpenOCD differentiates between TAP devices is by
  5426. shifting different instructions into (and out of) their instruction
  5427. registers.
  5428. @end itemize
  5429. @section Low Level JTAG Commands
  5430. These commands are used by developers who need to access
  5431. JTAG instruction or data registers, possibly controlling
  5432. the order of TAP state transitions.
  5433. If you're not debugging OpenOCD internals, or bringing up a
  5434. new JTAG adapter or a new type of TAP device (like a CPU or
  5435. JTAG router), you probably won't need to use these commands.
  5436. @deffn Command {drscan} tap [numbits value]+ [@option{-endstate} tap_state]
  5437. Loads the data register of @var{tap} with a series of bit fields
  5438. that specify the entire register.
  5439. Each field is @var{numbits} bits long with
  5440. a numeric @var{value} (hexadecimal encouraged).
  5441. The return value holds the original value of each
  5442. of those fields.
  5443. For example, a 38 bit number might be specified as one
  5444. field of 32 bits then one of 6 bits.
  5445. @emph{For portability, never pass fields which are more
  5446. than 32 bits long. Many OpenOCD implementations do not
  5447. support 64-bit (or larger) integer values.}
  5448. All TAPs other than @var{tap} must be in BYPASS mode.
  5449. The single bit in their data registers does not matter.
  5450. When @var{tap_state} is specified, the JTAG state machine is left
  5451. in that state.
  5452. For example @sc{drpause} might be specified, so that more
  5453. instructions can be issued before re-entering the @sc{run/idle} state.
  5454. If the end state is not specified, the @sc{run/idle} state is entered.
  5455. @quotation Warning
  5456. OpenOCD does not record information about data register lengths,
  5457. so @emph{it is important that you get the bit field lengths right}.
  5458. Remember that different JTAG instructions refer to different
  5459. data registers, which may have different lengths.
  5460. Moreover, those lengths may not be fixed;
  5461. the SCAN_N instruction can change the length of
  5462. the register accessed by the INTEST instruction
  5463. (by connecting a different scan chain).
  5464. @end quotation
  5465. @end deffn
  5466. @deffn Command {flush_count}
  5467. Returns the number of times the JTAG queue has been flushed.
  5468. This may be used for performance tuning.
  5469. For example, flushing a queue over USB involves a
  5470. minimum latency, often several milliseconds, which does
  5471. not change with the amount of data which is written.
  5472. You may be able to identify performance problems by finding
  5473. tasks which waste bandwidth by flushing small transfers too often,
  5474. instead of batching them into larger operations.
  5475. @end deffn
  5476. @deffn Command {irscan} [tap instruction]+ [@option{-endstate} tap_state]
  5477. For each @var{tap} listed, loads the instruction register
  5478. with its associated numeric @var{instruction}.
  5479. (The number of bits in that instruction may be displayed
  5480. using the @command{scan_chain} command.)
  5481. For other TAPs, a BYPASS instruction is loaded.
  5482. When @var{tap_state} is specified, the JTAG state machine is left
  5483. in that state.
  5484. For example @sc{irpause} might be specified, so the data register
  5485. can be loaded before re-entering the @sc{run/idle} state.
  5486. If the end state is not specified, the @sc{run/idle} state is entered.
  5487. @quotation Note
  5488. OpenOCD currently supports only a single field for instruction
  5489. register values, unlike data register values.
  5490. For TAPs where the instruction register length is more than 32 bits,
  5491. portable scripts currently must issue only BYPASS instructions.
  5492. @end quotation
  5493. @end deffn
  5494. @deffn Command {jtag_reset} trst srst
  5495. Set values of reset signals.
  5496. The @var{trst} and @var{srst} parameter values may be
  5497. @option{0}, indicating that reset is inactive (pulled or driven high),
  5498. or @option{1}, indicating it is active (pulled or driven low).
  5499. The @command{reset_config} command should already have been used
  5500. to configure how the board and JTAG adapter treat these two
  5501. signals, and to say if either signal is even present.
  5502. @xref{Reset Configuration}.
  5503. Note that TRST is specially handled.
  5504. It actually signifies JTAG's @sc{reset} state.
  5505. So if the board doesn't support the optional TRST signal,
  5506. or it doesn't support it along with the specified SRST value,
  5507. JTAG reset is triggered with TMS and TCK signals
  5508. instead of the TRST signal.
  5509. And no matter how that JTAG reset is triggered, once
  5510. the scan chain enters @sc{reset} with TRST inactive,
  5511. TAP @code{post-reset} events are delivered to all TAPs
  5512. with handlers for that event.
  5513. @end deffn
  5514. @deffn Command {pathmove} start_state [next_state ...]
  5515. Start by moving to @var{start_state}, which
  5516. must be one of the @emph{stable} states.
  5517. Unless it is the only state given, this will often be the
  5518. current state, so that no TCK transitions are needed.
  5519. Then, in a series of single state transitions
  5520. (conforming to the JTAG state machine) shift to
  5521. each @var{next_state} in sequence, one per TCK cycle.
  5522. The final state must also be stable.
  5523. @end deffn
  5524. @deffn Command {runtest} @var{num_cycles}
  5525. Move to the @sc{run/idle} state, and execute at least
  5526. @var{num_cycles} of the JTAG clock (TCK).
  5527. Instructions often need some time
  5528. to execute before they take effect.
  5529. @end deffn
  5530. @c tms_sequence (short|long)
  5531. @c ... temporary, debug-only, other than USBprog bug workaround...
  5532. @deffn Command {verify_ircapture} (@option{enable}|@option{disable})
  5533. Verify values captured during @sc{ircapture} and returned
  5534. during IR scans. Default is enabled, but this can be
  5535. overridden by @command{verify_jtag}.
  5536. This flag is ignored when validating JTAG chain configuration.
  5537. @end deffn
  5538. @deffn Command {verify_jtag} (@option{enable}|@option{disable})
  5539. Enables verification of DR and IR scans, to help detect
  5540. programming errors. For IR scans, @command{verify_ircapture}
  5541. must also be enabled.
  5542. Default is enabled.
  5543. @end deffn
  5544. @section TAP state names
  5545. @cindex TAP state names
  5546. The @var{tap_state} names used by OpenOCD in the @command{drscan},
  5547. @command{irscan}, and @command{pathmove} commands are the same
  5548. as those used in SVF boundary scan documents, except that
  5549. SVF uses @sc{idle} instead of @sc{run/idle}.
  5550. @itemize @bullet
  5551. @item @b{RESET} ... @emph{stable} (with TMS high);
  5552. acts as if TRST were pulsed
  5553. @item @b{RUN/IDLE} ... @emph{stable}; don't assume this always means IDLE
  5554. @item @b{DRSELECT}
  5555. @item @b{DRCAPTURE}
  5556. @item @b{DRSHIFT} ... @emph{stable}; TDI/TDO shifting
  5557. through the data register
  5558. @item @b{DREXIT1}
  5559. @item @b{DRPAUSE} ... @emph{stable}; data register ready
  5560. for update or more shifting
  5561. @item @b{DREXIT2}
  5562. @item @b{DRUPDATE}
  5563. @item @b{IRSELECT}
  5564. @item @b{IRCAPTURE}
  5565. @item @b{IRSHIFT} ... @emph{stable}; TDI/TDO shifting
  5566. through the instruction register
  5567. @item @b{IREXIT1}
  5568. @item @b{IRPAUSE} ... @emph{stable}; instruction register ready
  5569. for update or more shifting
  5570. @item @b{IREXIT2}
  5571. @item @b{IRUPDATE}
  5572. @end itemize
  5573. Note that only six of those states are fully ``stable'' in the
  5574. face of TMS fixed (low except for @sc{reset})
  5575. and a free-running JTAG clock. For all the
  5576. others, the next TCK transition changes to a new state.
  5577. @itemize @bullet
  5578. @item From @sc{drshift} and @sc{irshift}, clock transitions will
  5579. produce side effects by changing register contents. The values
  5580. to be latched in upcoming @sc{drupdate} or @sc{irupdate} states
  5581. may not be as expected.
  5582. @item @sc{run/idle}, @sc{drpause}, and @sc{irpause} are reasonable
  5583. choices after @command{drscan} or @command{irscan} commands,
  5584. since they are free of JTAG side effects.
  5585. @item @sc{run/idle} may have side effects that appear at non-JTAG
  5586. levels, such as advancing the ARM9E-S instruction pipeline.
  5587. Consult the documentation for the TAP(s) you are working with.
  5588. @end itemize
  5589. @node Boundary Scan Commands
  5590. @chapter Boundary Scan Commands
  5591. One of the original purposes of JTAG was to support
  5592. boundary scan based hardware testing.
  5593. Although its primary focus is to support On-Chip Debugging,
  5594. OpenOCD also includes some boundary scan commands.
  5595. @section SVF: Serial Vector Format
  5596. @cindex Serial Vector Format
  5597. @cindex SVF
  5598. The Serial Vector Format, better known as @dfn{SVF}, is a
  5599. way to represent JTAG test patterns in text files.
  5600. OpenOCD supports running such test files.
  5601. @deffn Command {svf} filename [@option{quiet}]
  5602. This issues a JTAG reset (Test-Logic-Reset) and then
  5603. runs the SVF script from @file{filename}.
  5604. Unless the @option{quiet} option is specified,
  5605. each command is logged before it is executed.
  5606. @end deffn
  5607. @section XSVF: Xilinx Serial Vector Format
  5608. @cindex Xilinx Serial Vector Format
  5609. @cindex XSVF
  5610. The Xilinx Serial Vector Format, better known as @dfn{XSVF}, is a
  5611. binary representation of SVF which is optimized for use with
  5612. Xilinx devices.
  5613. OpenOCD supports running such test files.
  5614. @quotation Important
  5615. Not all XSVF commands are supported.
  5616. @end quotation
  5617. @deffn Command {xsvf} (tapname|@option{plain}) filename [@option{virt2}] [@option{quiet}]
  5618. This issues a JTAG reset (Test-Logic-Reset) and then
  5619. runs the XSVF script from @file{filename}.
  5620. When a @var{tapname} is specified, the commands are directed at
  5621. that TAP.
  5622. When @option{virt2} is specified, the @sc{xruntest} command counts
  5623. are interpreted as TCK cycles instead of microseconds.
  5624. Unless the @option{quiet} option is specified,
  5625. messages are logged for comments and some retries.
  5626. @end deffn
  5627. The OpenOCD sources also include two utility scripts
  5628. for working with XSVF; they are not currently installed
  5629. after building the software.
  5630. You may find them useful:
  5631. @itemize
  5632. @item @emph{svf2xsvf} ... converts SVF files into the extended XSVF
  5633. syntax understood by the @command{xsvf} command; see notes below.
  5634. @item @emph{xsvfdump} ... converts XSVF files into a text output format;
  5635. understands the OpenOCD extensions.
  5636. @end itemize
  5637. The input format accepts a handful of non-standard extensions.
  5638. These include three opcodes corresponding to SVF extensions
  5639. from Lattice Semiconductor (LCOUNT, LDELAY, LDSR), and
  5640. two opcodes supporting a more accurate translation of SVF
  5641. (XTRST, XWAITSTATE).
  5642. If @emph{xsvfdump} shows a file is using those opcodes, it
  5643. probably will not be usable with other XSVF tools.
  5644. @node TFTP
  5645. @chapter TFTP
  5646. @cindex TFTP
  5647. If OpenOCD runs on an embedded host(as ZY1000 does), then TFTP can
  5648. be used to access files on PCs (either the developer's PC or some other PC).
  5649. The way this works on the ZY1000 is to prefix a filename by
  5650. "/tftp/ip/" and append the TFTP path on the TFTP
  5651. server (tftpd). For example,
  5652. @example
  5653. load_image /tftp/10.0.0.96/c:\temp\abc.elf
  5654. @end example
  5655. will load c:\temp\abc.elf from the developer pc (10.0.0.96) into memory as
  5656. if the file was hosted on the embedded host.
  5657. In order to achieve decent performance, you must choose a TFTP server
  5658. that supports a packet size bigger than the default packet size (512 bytes). There
  5659. are numerous TFTP servers out there (free and commercial) and you will have to do
  5660. a bit of googling to find something that fits your requirements.
  5661. @node GDB and OpenOCD
  5662. @chapter GDB and OpenOCD
  5663. @cindex GDB
  5664. OpenOCD complies with the remote gdbserver protocol, and as such can be used
  5665. to debug remote targets.
  5666. Setting up GDB to work with OpenOCD can involve several components:
  5667. @itemize
  5668. @item The OpenOCD server support for GDB may need to be configured.
  5669. @xref{GDB Configuration}.
  5670. @item GDB's support for OpenOCD may need configuration,
  5671. as shown in this chapter.
  5672. @item If you have a GUI environment like Eclipse,
  5673. that also will probably need to be configured.
  5674. @end itemize
  5675. Of course, the version of GDB you use will need to be one which has
  5676. been built to know about the target CPU you're using. It's probably
  5677. part of the tool chain you're using. For example, if you are doing
  5678. cross-development for ARM on an x86 PC, instead of using the native
  5679. x86 @command{gdb} command you might use @command{arm-none-eabi-gdb}
  5680. if that's the tool chain used to compile your code.
  5681. @anchor{Connecting to GDB}
  5682. @section Connecting to GDB
  5683. @cindex Connecting to GDB
  5684. Use GDB 6.7 or newer with OpenOCD if you run into trouble. For
  5685. instance GDB 6.3 has a known bug that produces bogus memory access
  5686. errors, which has since been fixed; see
  5687. @url{http://osdir.com/ml/gdb.bugs.discuss/2004-12/msg00018.html}
  5688. OpenOCD can communicate with GDB in two ways:
  5689. @enumerate
  5690. @item
  5691. A socket (TCP/IP) connection is typically started as follows:
  5692. @example
  5693. target remote localhost:3333
  5694. @end example
  5695. This would cause GDB to connect to the gdbserver on the local pc using port 3333.
  5696. @item
  5697. A pipe connection is typically started as follows:
  5698. @example
  5699. target remote | openocd --pipe
  5700. @end example
  5701. This would cause GDB to run OpenOCD and communicate using pipes (stdin/stdout).
  5702. Using this method has the advantage of GDB starting/stopping OpenOCD for the debug
  5703. session.
  5704. @end enumerate
  5705. To list the available OpenOCD commands type @command{monitor help} on the
  5706. GDB command line.
  5707. @section Sample GDB session startup
  5708. With the remote protocol, GDB sessions start a little differently
  5709. than they do when you're debugging locally.
  5710. Here's an examples showing how to start a debug session with a
  5711. small ARM program.
  5712. In this case the program was linked to be loaded into SRAM on a Cortex-M3.
  5713. Most programs would be written into flash (address 0) and run from there.
  5714. @example
  5715. $ arm-none-eabi-gdb example.elf
  5716. (gdb) target remote localhost:3333
  5717. Remote debugging using localhost:3333
  5718. ...
  5719. (gdb) monitor reset halt
  5720. ...
  5721. (gdb) load
  5722. Loading section .vectors, size 0x100 lma 0x20000000
  5723. Loading section .text, size 0x5a0 lma 0x20000100
  5724. Loading section .data, size 0x18 lma 0x200006a0
  5725. Start address 0x2000061c, load size 1720
  5726. Transfer rate: 22 KB/sec, 573 bytes/write.
  5727. (gdb) continue
  5728. Continuing.
  5729. ...
  5730. @end example
  5731. You could then interrupt the GDB session to make the program break,
  5732. type @command{where} to show the stack, @command{list} to show the
  5733. code around the program counter, @command{step} through code,
  5734. set breakpoints or watchpoints, and so on.
  5735. @section Configuring GDB for OpenOCD
  5736. OpenOCD supports the gdb @option{qSupported} packet, this enables information
  5737. to be sent by the GDB remote server (i.e. OpenOCD) to GDB. Typical information includes
  5738. packet size and the device's memory map.
  5739. You do not need to configure the packet size by hand,
  5740. and the relevant parts of the memory map should be automatically
  5741. set up when you declare (NOR) flash banks.
  5742. However, there are other things which GDB can't currently query.
  5743. You may need to set those up by hand.
  5744. As OpenOCD starts up, you will often see a line reporting
  5745. something like:
  5746. @example
  5747. Info : lm3s.cpu: hardware has 6 breakpoints, 4 watchpoints
  5748. @end example
  5749. You can pass that information to GDB with these commands:
  5750. @example
  5751. set remote hardware-breakpoint-limit 6
  5752. set remote hardware-watchpoint-limit 4
  5753. @end example
  5754. With that particular hardware (Cortex-M3) the hardware breakpoints
  5755. only work for code running from flash memory. Most other ARM systems
  5756. do not have such restrictions.
  5757. Another example of useful GDB configuration came from a user who
  5758. found that single stepping his Cortex-M3 didn't work well with IRQs
  5759. and an RTOS until he told GDB to disable the IRQs while stepping:
  5760. @example
  5761. define hook-step
  5762. mon cortex_m3 maskisr on
  5763. end
  5764. define hookpost-step
  5765. mon cortex_m3 maskisr off
  5766. end
  5767. @end example
  5768. Rather than typing such commands interactively, you may prefer to
  5769. save them in a file and have GDB execute them as it starts, perhaps
  5770. using a @file{.gdbinit} in your project directory or starting GDB
  5771. using @command{gdb -x filename}.
  5772. @section Programming using GDB
  5773. @cindex Programming using GDB
  5774. By default the target memory map is sent to GDB. This can be disabled by
  5775. the following OpenOCD configuration option:
  5776. @example
  5777. gdb_memory_map disable
  5778. @end example
  5779. For this to function correctly a valid flash configuration must also be set
  5780. in OpenOCD. For faster performance you should also configure a valid
  5781. working area.
  5782. Informing GDB of the memory map of the target will enable GDB to protect any
  5783. flash areas of the target and use hardware breakpoints by default. This means
  5784. that the OpenOCD option @command{gdb_breakpoint_override} is not required when
  5785. using a memory map. @xref{gdb_breakpoint_override}.
  5786. To view the configured memory map in GDB, use the GDB command @option{info mem}
  5787. All other unassigned addresses within GDB are treated as RAM.
  5788. GDB 6.8 and higher set any memory area not in the memory map as inaccessible.
  5789. This can be changed to the old behaviour by using the following GDB command
  5790. @example
  5791. set mem inaccessible-by-default off
  5792. @end example
  5793. If @command{gdb_flash_program enable} is also used, GDB will be able to
  5794. program any flash memory using the vFlash interface.
  5795. GDB will look at the target memory map when a load command is given, if any
  5796. areas to be programmed lie within the target flash area the vFlash packets
  5797. will be used.
  5798. If the target needs configuring before GDB programming, an event
  5799. script can be executed:
  5800. @example
  5801. $_TARGETNAME configure -event EVENTNAME BODY
  5802. @end example
  5803. To verify any flash programming the GDB command @option{compare-sections}
  5804. can be used.
  5805. @node Tcl Scripting API
  5806. @chapter Tcl Scripting API
  5807. @cindex Tcl Scripting API
  5808. @cindex Tcl scripts
  5809. @section API rules
  5810. The commands are stateless. E.g. the telnet command line has a concept
  5811. of currently active target, the Tcl API proc's take this sort of state
  5812. information as an argument to each proc.
  5813. There are three main types of return values: single value, name value
  5814. pair list and lists.
  5815. Name value pair. The proc 'foo' below returns a name/value pair
  5816. list.
  5817. @verbatim
  5818. > set foo(me) Duane
  5819. > set foo(you) Oyvind
  5820. > set foo(mouse) Micky
  5821. > set foo(duck) Donald
  5822. If one does this:
  5823. > set foo
  5824. The result is:
  5825. me Duane you Oyvind mouse Micky duck Donald
  5826. Thus, to get the names of the associative array is easy:
  5827. foreach { name value } [set foo] {
  5828. puts "Name: $name, Value: $value"
  5829. }
  5830. @end verbatim
  5831. Lists returned must be relatively small. Otherwise a range
  5832. should be passed in to the proc in question.
  5833. @section Internal low-level Commands
  5834. By low-level, the intent is a human would not directly use these commands.
  5835. Low-level commands are (should be) prefixed with "ocd_", e.g.
  5836. @command{ocd_flash_banks}
  5837. is the low level API upon which @command{flash banks} is implemented.
  5838. @itemize @bullet
  5839. @item @b{ocd_mem2array} <@var{varname}> <@var{width}> <@var{addr}> <@var{nelems}>
  5840. Read memory and return as a Tcl array for script processing
  5841. @item @b{ocd_array2mem} <@var{varname}> <@var{width}> <@var{addr}> <@var{nelems}>
  5842. Convert a Tcl array to memory locations and write the values
  5843. @item @b{ocd_flash_banks} <@var{driver}> <@var{base}> <@var{size}> <@var{chip_width}> <@var{bus_width}> <@var{target}> [@option{driver options} ...]
  5844. Return information about the flash banks
  5845. @end itemize
  5846. OpenOCD commands can consist of two words, e.g. "flash banks". The
  5847. @file{startup.tcl} "unknown" proc will translate this into a Tcl proc
  5848. called "flash_banks".
  5849. @section OpenOCD specific Global Variables
  5850. Real Tcl has ::tcl_platform(), and platform::identify, and many other
  5851. variables. JimTCL, as implemented in OpenOCD creates $ocd_HOSTOS which
  5852. holds one of the following values:
  5853. @itemize @bullet
  5854. @item @b{cygwin} Running under Cygwin
  5855. @item @b{darwin} Darwin (Mac-OS) is the underlying operating sytem.
  5856. @item @b{freebsd} Running under FreeBSD
  5857. @item @b{linux} Linux is the underlying operating sytem
  5858. @item @b{mingw32} Running under MingW32
  5859. @item @b{winxx} Built using Microsoft Visual Studio
  5860. @item @b{other} Unknown, none of the above.
  5861. @end itemize
  5862. Note: 'winxx' was choosen because today (March-2009) no distinction is made between Win32 and Win64.
  5863. @quotation Note
  5864. We should add support for a variable like Tcl variable
  5865. @code{tcl_platform(platform)}, it should be called
  5866. @code{jim_platform} (because it
  5867. is jim, not real tcl).
  5868. @end quotation
  5869. @node FAQ
  5870. @chapter FAQ
  5871. @cindex faq
  5872. @enumerate
  5873. @anchor{FAQ RTCK}
  5874. @item @b{RTCK, also known as: Adaptive Clocking - What is it?}
  5875. @cindex RTCK
  5876. @cindex adaptive clocking
  5877. @*
  5878. In digital circuit design it is often refered to as ``clock
  5879. synchronisation'' the JTAG interface uses one clock (TCK or TCLK)
  5880. operating at some speed, your CPU target is operating at another.
  5881. The two clocks are not synchronised, they are ``asynchronous''
  5882. In order for the two to work together they must be synchronised
  5883. well enough to work; JTAG can't go ten times faster than the CPU,
  5884. for example. There are 2 basic options:
  5885. @enumerate
  5886. @item
  5887. Use a special "adaptive clocking" circuit to change the JTAG
  5888. clock rate to match what the CPU currently supports.
  5889. @item
  5890. The JTAG clock must be fixed at some speed that's enough slower than
  5891. the CPU clock that all TMS and TDI transitions can be detected.
  5892. @end enumerate
  5893. @b{Does this really matter?} For some chips and some situations, this
  5894. is a non-issue, like a 500MHz ARM926 with a 5 MHz JTAG link;
  5895. the CPU has no difficulty keeping up with JTAG.
  5896. Startup sequences are often problematic though, as are other
  5897. situations where the CPU clock rate changes (perhaps to save
  5898. power).
  5899. For example, Atmel AT91SAM chips start operation from reset with
  5900. a 32kHz system clock. Boot firmware may activate the main oscillator
  5901. and PLL before switching to a faster clock (perhaps that 500 MHz
  5902. ARM926 scenario).
  5903. If you're using JTAG to debug that startup sequence, you must slow
  5904. the JTAG clock to sometimes 1 to 4kHz. After startup completes,
  5905. JTAG can use a faster clock.
  5906. Consider also debugging a 500MHz ARM926 hand held battery powered
  5907. device that enters a low power ``deep sleep'' mode, at 32kHz CPU
  5908. clock, between keystrokes unless it has work to do. When would
  5909. that 5 MHz JTAG clock be usable?
  5910. @b{Solution #1 - A special circuit}
  5911. In order to make use of this,
  5912. both your CPU and your JTAG dongle must support the RTCK
  5913. feature. Not all dongles support this - keep reading!
  5914. The RTCK ("Return TCK") signal in some ARM chips is used to help with
  5915. this problem. ARM has a good description of the problem described at
  5916. this link: @url{http://www.arm.com/support/faqdev/4170.html} [checked
  5917. 28/nov/2008]. Link title: ``How does the JTAG synchronisation logic
  5918. work? / how does adaptive clocking work?''.
  5919. The nice thing about adaptive clocking is that ``battery powered hand
  5920. held device example'' - the adaptiveness works perfectly all the
  5921. time. One can set a break point or halt the system in the deep power
  5922. down code, slow step out until the system speeds up.
  5923. Note that adaptive clocking may also need to work at the board level,
  5924. when a board-level scan chain has multiple chips.
  5925. Parallel clock voting schemes are good way to implement this,
  5926. both within and between chips, and can easily be implemented
  5927. with a CPLD.
  5928. It's not difficult to have logic fan a module's input TCK signal out
  5929. to each TAP in the scan chain, and then wait until each TAP's RTCK comes
  5930. back with the right polarity before changing the output RTCK signal.
  5931. Texas Instruments makes some clock voting logic available
  5932. for free (with no support) in VHDL form; see
  5933. @url{http://tiexpressdsp.com/index.php/Adaptive_Clocking}
  5934. @b{Solution #2 - Always works - but may be slower}
  5935. Often this is a perfectly acceptable solution.
  5936. In most simple terms: Often the JTAG clock must be 1/10 to 1/12 of
  5937. the target clock speed. But what that ``magic division'' is varies
  5938. depending on the chips on your board.
  5939. @b{ARM rule of thumb} Most ARM based systems require an 6:1 division;
  5940. ARM11 cores use an 8:1 division.
  5941. @b{Xilinx rule of thumb} is 1/12 the clock speed.
  5942. Note: Many FTDI2232C based JTAG dongles are limited to 6MHz.
  5943. You can still debug the 'low power' situations - you just need to
  5944. either use a fixed and very slow JTAG clock rate ... or else
  5945. manually adjust the clock speed at every step. (Adjusting is painful
  5946. and tedious, and is not always practical.)
  5947. It is however easy to ``code your way around it'' - i.e.: Cheat a little,
  5948. have a special debug mode in your application that does a ``high power
  5949. sleep''. If you are careful - 98% of your problems can be debugged
  5950. this way.
  5951. Note that on ARM you may need to avoid using the @emph{wait for interrupt}
  5952. operation in your idle loops even if you don't otherwise change the CPU
  5953. clock rate.
  5954. That operation gates the CPU clock, and thus the JTAG clock; which
  5955. prevents JTAG access. One consequence is not being able to @command{halt}
  5956. cores which are executing that @emph{wait for interrupt} operation.
  5957. To set the JTAG frequency use the command:
  5958. @example
  5959. # Example: 1.234MHz
  5960. jtag_khz 1234
  5961. @end example
  5962. @item @b{Win32 Pathnames} Why don't backslashes work in Windows paths?
  5963. OpenOCD uses Tcl and a backslash is an escape char. Use @{ and @}
  5964. around Windows filenames.
  5965. @example
  5966. > echo \a
  5967. > echo @{\a@}
  5968. \a
  5969. > echo "\a"
  5970. >
  5971. @end example
  5972. @item @b{Missing: cygwin1.dll} OpenOCD complains about a missing cygwin1.dll.
  5973. Make sure you have Cygwin installed, or at least a version of OpenOCD that
  5974. claims to come with all the necessary DLLs. When using Cygwin, try launching
  5975. OpenOCD from the Cygwin shell.
  5976. @item @b{Breakpoint Issue} I'm trying to set a breakpoint using GDB (or a frontend like Insight or
  5977. Eclipse), but OpenOCD complains that "Info: arm7_9_common.c:213
  5978. arm7_9_add_breakpoint(): sw breakpoint requested, but software breakpoints not enabled".
  5979. GDB issues software breakpoints when a normal breakpoint is requested, or to implement
  5980. source-line single-stepping. On ARMv4T systems, like ARM7TDMI, ARM720T or ARM920T,
  5981. software breakpoints consume one of the two available hardware breakpoints.
  5982. @item @b{LPC2000 Flash} When erasing or writing LPC2000 on-chip flash, the operation fails at random.
  5983. Make sure the core frequency specified in the @option{flash lpc2000} line matches the
  5984. clock at the time you're programming the flash. If you've specified the crystal's
  5985. frequency, make sure the PLL is disabled. If you've specified the full core speed
  5986. (e.g. 60MHz), make sure the PLL is enabled.
  5987. @item @b{Amontec Chameleon} When debugging using an Amontec Chameleon in its JTAG Accelerator configuration,
  5988. I keep getting "Error: amt_jtagaccel.c:184 amt_wait_scan_busy(): amt_jtagaccel timed
  5989. out while waiting for end of scan, rtck was disabled".
  5990. Make sure your PC's parallel port operates in EPP mode. You might have to try several
  5991. settings in your PC BIOS (ECP, EPP, and different versions of those).
  5992. @item @b{Data Aborts} When debugging with OpenOCD and GDB (plain GDB, Insight, or Eclipse),
  5993. I get lots of "Error: arm7_9_common.c:1771 arm7_9_read_memory():
  5994. memory read caused data abort".
  5995. The errors are non-fatal, and are the result of GDB trying to trace stack frames
  5996. beyond the last valid frame. It might be possible to prevent this by setting up
  5997. a proper "initial" stack frame, if you happen to know what exactly has to
  5998. be done, feel free to add this here.
  5999. @b{Simple:} In your startup code - push 8 registers of zeros onto the
  6000. stack before calling main(). What GDB is doing is ``climbing'' the run
  6001. time stack by reading various values on the stack using the standard
  6002. call frame for the target. GDB keeps going - until one of 2 things
  6003. happen @b{#1} an invalid frame is found, or @b{#2} some huge number of
  6004. stackframes have been processed. By pushing zeros on the stack, GDB
  6005. gracefully stops.
  6006. @b{Debugging Interrupt Service Routines} - In your ISR before you call
  6007. your C code, do the same - artifically push some zeros onto the stack,
  6008. remember to pop them off when the ISR is done.
  6009. @b{Also note:} If you have a multi-threaded operating system, they
  6010. often do not @b{in the intrest of saving memory} waste these few
  6011. bytes. Painful...
  6012. @item @b{JTAG Reset Config} I get the following message in the OpenOCD console (or log file):
  6013. "Warning: arm7_9_common.c:679 arm7_9_assert_reset(): srst resets test logic, too".
  6014. This warning doesn't indicate any serious problem, as long as you don't want to
  6015. debug your core right out of reset. Your .cfg file specified @option{jtag_reset
  6016. trst_and_srst srst_pulls_trst} to tell OpenOCD that either your board,
  6017. your debugger or your target uC (e.g. LPC2000) can't assert the two reset signals
  6018. independently. With this setup, it's not possible to halt the core right out of
  6019. reset, everything else should work fine.
  6020. @item @b{USB Power} When using OpenOCD in conjunction with Amontec JTAGkey and the Yagarto
  6021. toolchain (Eclipse, arm-elf-gcc, arm-elf-gdb), the debugging seems to be
  6022. unstable. When single-stepping over large blocks of code, GDB and OpenOCD
  6023. quit with an error message. Is there a stability issue with OpenOCD?
  6024. No, this is not a stability issue concerning OpenOCD. Most users have solved
  6025. this issue by simply using a self-powered USB hub, which they connect their
  6026. Amontec JTAGkey to. Apparently, some computers do not provide a USB power
  6027. supply stable enough for the Amontec JTAGkey to be operated.
  6028. @b{Laptops running on battery have this problem too...}
  6029. @item @b{USB Power} When using the Amontec JTAGkey, sometimes OpenOCD crashes with the
  6030. following error messages: "Error: ft2232.c:201 ft2232_read(): FT_Read returned:
  6031. 4" and "Error: ft2232.c:365 ft2232_send_and_recv(): couldn't read from FT2232".
  6032. What does that mean and what might be the reason for this?
  6033. First of all, the reason might be the USB power supply. Try using a self-powered
  6034. hub instead of a direct connection to your computer. Secondly, the error code 4
  6035. corresponds to an FT_IO_ERROR, which means that the driver for the FTDI USB
  6036. chip ran into some sort of error - this points us to a USB problem.
  6037. @item @b{GDB Disconnects} When using the Amontec JTAGkey, sometimes OpenOCD crashes with the following
  6038. error message: "Error: gdb_server.c:101 gdb_get_char(): read: 10054".
  6039. What does that mean and what might be the reason for this?
  6040. Error code 10054 corresponds to WSAECONNRESET, which means that the debugger (GDB)
  6041. has closed the connection to OpenOCD. This might be a GDB issue.
  6042. @item @b{LPC2000 Flash} In the configuration file in the section where flash device configurations
  6043. are described, there is a parameter for specifying the clock frequency
  6044. for LPC2000 internal flash devices (e.g. @option{flash bank lpc2000
  6045. 0x0 0x40000 0 0 0 lpc2000_v1 14746 calc_checksum}), which must be
  6046. specified in kilohertz. However, I do have a quartz crystal of a
  6047. frequency that contains fractions of kilohertz (e.g. 14,745,600 Hz,
  6048. i.e. 14,745.600 kHz). Is it possible to specify real numbers for the
  6049. clock frequency?
  6050. No. The clock frequency specified here must be given as an integral number.
  6051. However, this clock frequency is used by the In-Application-Programming (IAP)
  6052. routines of the LPC2000 family only, which seems to be very tolerant concerning
  6053. the given clock frequency, so a slight difference between the specified clock
  6054. frequency and the actual clock frequency will not cause any trouble.
  6055. @item @b{Command Order} Do I have to keep a specific order for the commands in the configuration file?
  6056. Well, yes and no. Commands can be given in arbitrary order, yet the
  6057. devices listed for the JTAG scan chain must be given in the right
  6058. order (jtag newdevice), with the device closest to the TDO-Pin being
  6059. listed first. In general, whenever objects of the same type exist
  6060. which require an index number, then these objects must be given in the
  6061. right order (jtag newtap, targets and flash banks - a target
  6062. references a jtag newtap and a flash bank references a target).
  6063. You can use the ``scan_chain'' command to verify and display the tap order.
  6064. Also, some commands can't execute until after @command{init} has been
  6065. processed. Such commands include @command{nand probe} and everything
  6066. else that needs to write to controller registers, perhaps for setting
  6067. up DRAM and loading it with code.
  6068. @anchor{FAQ TAP Order}
  6069. @item @b{JTAG TAP Order} Do I have to declare the TAPS in some
  6070. particular order?
  6071. Yes; whenever you have more than one, you must declare them in
  6072. the same order used by the hardware.
  6073. Many newer devices have multiple JTAG TAPs. For example: ST
  6074. Microsystems STM32 chips have two TAPs, a ``boundary scan TAP'' and
  6075. ``Cortex-M3'' TAP. Example: The STM32 reference manual, Document ID:
  6076. RM0008, Section 26.5, Figure 259, page 651/681, the ``TDI'' pin is
  6077. connected to the boundary scan TAP, which then connects to the
  6078. Cortex-M3 TAP, which then connects to the TDO pin.
  6079. Thus, the proper order for the STM32 chip is: (1) The Cortex-M3, then
  6080. (2) The boundary scan TAP. If your board includes an additional JTAG
  6081. chip in the scan chain (for example a Xilinx CPLD or FPGA) you could
  6082. place it before or after the STM32 chip in the chain. For example:
  6083. @itemize @bullet
  6084. @item OpenOCD_TDI(output) -> STM32 TDI Pin (BS Input)
  6085. @item STM32 BS TDO (output) -> STM32 Cortex-M3 TDI (input)
  6086. @item STM32 Cortex-M3 TDO (output) -> SM32 TDO Pin
  6087. @item STM32 TDO Pin (output) -> Xilinx TDI Pin (input)
  6088. @item Xilinx TDO Pin -> OpenOCD TDO (input)
  6089. @end itemize
  6090. The ``jtag device'' commands would thus be in the order shown below. Note:
  6091. @itemize @bullet
  6092. @item jtag newtap Xilinx tap -irlen ...
  6093. @item jtag newtap stm32 cpu -irlen ...
  6094. @item jtag newtap stm32 bs -irlen ...
  6095. @item # Create the debug target and say where it is
  6096. @item target create stm32.cpu -chain-position stm32.cpu ...
  6097. @end itemize
  6098. @item @b{SYSCOMP} Sometimes my debugging session terminates with an error. When I look into the
  6099. log file, I can see these error messages: Error: arm7_9_common.c:561
  6100. arm7_9_execute_sys_speed(): timeout waiting for SYSCOMP
  6101. TODO.
  6102. @end enumerate
  6103. @node Tcl Crash Course
  6104. @chapter Tcl Crash Course
  6105. @cindex Tcl
  6106. Not everyone knows Tcl - this is not intended to be a replacement for
  6107. learning Tcl, the intent of this chapter is to give you some idea of
  6108. how the Tcl scripts work.
  6109. This chapter is written with two audiences in mind. (1) OpenOCD users
  6110. who need to understand a bit more of how JIM-Tcl works so they can do
  6111. something useful, and (2) those that want to add a new command to
  6112. OpenOCD.
  6113. @section Tcl Rule #1
  6114. There is a famous joke, it goes like this:
  6115. @enumerate
  6116. @item Rule #1: The wife is always correct
  6117. @item Rule #2: If you think otherwise, See Rule #1
  6118. @end enumerate
  6119. The Tcl equal is this:
  6120. @enumerate
  6121. @item Rule #1: Everything is a string
  6122. @item Rule #2: If you think otherwise, See Rule #1
  6123. @end enumerate
  6124. As in the famous joke, the consequences of Rule #1 are profound. Once
  6125. you understand Rule #1, you will understand Tcl.
  6126. @section Tcl Rule #1b
  6127. There is a second pair of rules.
  6128. @enumerate
  6129. @item Rule #1: Control flow does not exist. Only commands
  6130. @* For example: the classic FOR loop or IF statement is not a control
  6131. flow item, they are commands, there is no such thing as control flow
  6132. in Tcl.
  6133. @item Rule #2: If you think otherwise, See Rule #1
  6134. @* Actually what happens is this: There are commands that by
  6135. convention, act like control flow key words in other languages. One of
  6136. those commands is the word ``for'', another command is ``if''.
  6137. @end enumerate
  6138. @section Per Rule #1 - All Results are strings
  6139. Every Tcl command results in a string. The word ``result'' is used
  6140. deliberatly. No result is just an empty string. Remember: @i{Rule #1 -
  6141. Everything is a string}
  6142. @section Tcl Quoting Operators
  6143. In life of a Tcl script, there are two important periods of time, the
  6144. difference is subtle.
  6145. @enumerate
  6146. @item Parse Time
  6147. @item Evaluation Time
  6148. @end enumerate
  6149. The two key items here are how ``quoted things'' work in Tcl. Tcl has
  6150. three primary quoting constructs, the [square-brackets] the
  6151. @{curly-braces@} and ``double-quotes''
  6152. By now you should know $VARIABLES always start with a $DOLLAR
  6153. sign. BTW: To set a variable, you actually use the command ``set'', as
  6154. in ``set VARNAME VALUE'' much like the ancient BASIC langauge ``let x
  6155. = 1'' statement, but without the equal sign.
  6156. @itemize @bullet
  6157. @item @b{[square-brackets]}
  6158. @* @b{[square-brackets]} are command substitutions. It operates much
  6159. like Unix Shell `back-ticks`. The result of a [square-bracket]
  6160. operation is exactly 1 string. @i{Remember Rule #1 - Everything is a
  6161. string}. These two statements are roughly identical:
  6162. @example
  6163. # bash example
  6164. X=`date`
  6165. echo "The Date is: $X"
  6166. # Tcl example
  6167. set X [date]
  6168. puts "The Date is: $X"
  6169. @end example
  6170. @item @b{``double-quoted-things''}
  6171. @* @b{``double-quoted-things''} are just simply quoted
  6172. text. $VARIABLES and [square-brackets] are expanded in place - the
  6173. result however is exactly 1 string. @i{Remember Rule #1 - Everything
  6174. is a string}
  6175. @example
  6176. set x "Dinner"
  6177. puts "It is now \"[date]\", $x is in 1 hour"
  6178. @end example
  6179. @item @b{@{Curly-Braces@}}
  6180. @*@b{@{Curly-Braces@}} are magic: $VARIABLES and [square-brackets] are
  6181. parsed, but are NOT expanded or executed. @{Curly-Braces@} are like
  6182. 'single-quote' operators in BASH shell scripts, with the added
  6183. feature: @{curly-braces@} can be nested, single quotes can not. @{@{@{this is
  6184. nested 3 times@}@}@} NOTE: [date] is a bad example;
  6185. at this writing, Jim/OpenOCD does not have a date command.
  6186. @end itemize
  6187. @section Consequences of Rule 1/2/3/4
  6188. The consequences of Rule 1 are profound.
  6189. @subsection Tokenisation & Execution.
  6190. Of course, whitespace, blank lines and #comment lines are handled in
  6191. the normal way.
  6192. As a script is parsed, each (multi) line in the script file is
  6193. tokenised and according to the quoting rules. After tokenisation, that
  6194. line is immedatly executed.
  6195. Multi line statements end with one or more ``still-open''
  6196. @{curly-braces@} which - eventually - closes a few lines later.
  6197. @subsection Command Execution
  6198. Remember earlier: There are no ``control flow''
  6199. statements in Tcl. Instead there are COMMANDS that simply act like
  6200. control flow operators.
  6201. Commands are executed like this:
  6202. @enumerate
  6203. @item Parse the next line into (argc) and (argv[]).
  6204. @item Look up (argv[0]) in a table and call its function.
  6205. @item Repeat until End Of File.
  6206. @end enumerate
  6207. It sort of works like this:
  6208. @example
  6209. for(;;)@{
  6210. ReadAndParse( &argc, &argv );
  6211. cmdPtr = LookupCommand( argv[0] );
  6212. (*cmdPtr->Execute)( argc, argv );
  6213. @}
  6214. @end example
  6215. When the command ``proc'' is parsed (which creates a procedure
  6216. function) it gets 3 parameters on the command line. @b{1} the name of
  6217. the proc (function), @b{2} the list of parameters, and @b{3} the body
  6218. of the function. Not the choice of words: LIST and BODY. The PROC
  6219. command stores these items in a table somewhere so it can be found by
  6220. ``LookupCommand()''
  6221. @subsection The FOR command
  6222. The most interesting command to look at is the FOR command. In Tcl,
  6223. the FOR command is normally implemented in C. Remember, FOR is a
  6224. command just like any other command.
  6225. When the ascii text containing the FOR command is parsed, the parser
  6226. produces 5 parameter strings, @i{(If in doubt: Refer to Rule #1)} they
  6227. are:
  6228. @enumerate 0
  6229. @item The ascii text 'for'
  6230. @item The start text
  6231. @item The test expression
  6232. @item The next text
  6233. @item The body text
  6234. @end enumerate
  6235. Sort of reminds you of ``main( int argc, char **argv )'' does it not?
  6236. Remember @i{Rule #1 - Everything is a string.} The key point is this:
  6237. Often many of those parameters are in @{curly-braces@} - thus the
  6238. variables inside are not expanded or replaced until later.
  6239. Remember that every Tcl command looks like the classic ``main( argc,
  6240. argv )'' function in C. In JimTCL - they actually look like this:
  6241. @example
  6242. int
  6243. MyCommand( Jim_Interp *interp,
  6244. int *argc,
  6245. Jim_Obj * const *argvs );
  6246. @end example
  6247. Real Tcl is nearly identical. Although the newer versions have
  6248. introduced a byte-code parser and intepreter, but at the core, it
  6249. still operates in the same basic way.
  6250. @subsection FOR command implementation
  6251. To understand Tcl it is perhaps most helpful to see the FOR
  6252. command. Remember, it is a COMMAND not a control flow structure.
  6253. In Tcl there are two underlying C helper functions.
  6254. Remember Rule #1 - You are a string.
  6255. The @b{first} helper parses and executes commands found in an ascii
  6256. string. Commands can be seperated by semicolons, or newlines. While
  6257. parsing, variables are expanded via the quoting rules.
  6258. The @b{second} helper evaluates an ascii string as a numerical
  6259. expression and returns a value.
  6260. Here is an example of how the @b{FOR} command could be
  6261. implemented. The pseudo code below does not show error handling.
  6262. @example
  6263. void Execute_AsciiString( void *interp, const char *string );
  6264. int Evaluate_AsciiExpression( void *interp, const char *string );
  6265. int
  6266. MyForCommand( void *interp,
  6267. int argc,
  6268. char **argv )
  6269. @{
  6270. if( argc != 5 )@{
  6271. SetResult( interp, "WRONG number of parameters");
  6272. return ERROR;
  6273. @}
  6274. // argv[0] = the ascii string just like C
  6275. // Execute the start statement.
  6276. Execute_AsciiString( interp, argv[1] );
  6277. // Top of loop test
  6278. for(;;)@{
  6279. i = Evaluate_AsciiExpression(interp, argv[2]);
  6280. if( i == 0 )
  6281. break;
  6282. // Execute the body
  6283. Execute_AsciiString( interp, argv[3] );
  6284. // Execute the LOOP part
  6285. Execute_AsciiString( interp, argv[4] );
  6286. @}
  6287. // Return no error
  6288. SetResult( interp, "" );
  6289. return SUCCESS;
  6290. @}
  6291. @end example
  6292. Every other command IF, WHILE, FORMAT, PUTS, EXPR, everything works
  6293. in the same basic way.
  6294. @section OpenOCD Tcl Usage
  6295. @subsection source and find commands
  6296. @b{Where:} In many configuration files
  6297. @* Example: @b{ source [find FILENAME] }
  6298. @*Remember the parsing rules
  6299. @enumerate
  6300. @item The FIND command is in square brackets.
  6301. @* The FIND command is executed with the parameter FILENAME. It should
  6302. find the full path to the named file. The RESULT is a string, which is
  6303. substituted on the orginal command line.
  6304. @item The command source is executed with the resulting filename.
  6305. @* SOURCE reads a file and executes as a script.
  6306. @end enumerate
  6307. @subsection format command
  6308. @b{Where:} Generally occurs in numerous places.
  6309. @* Tcl has no command like @b{printf()}, instead it has @b{format}, which is really more like
  6310. @b{sprintf()}.
  6311. @b{Example}
  6312. @example
  6313. set x 6
  6314. set y 7
  6315. puts [format "The answer: %d" [expr $x * $y]]
  6316. @end example
  6317. @enumerate
  6318. @item The SET command creates 2 variables, X and Y.
  6319. @item The double [nested] EXPR command performs math
  6320. @* The EXPR command produces numerical result as a string.
  6321. @* Refer to Rule #1
  6322. @item The format command is executed, producing a single string
  6323. @* Refer to Rule #1.
  6324. @item The PUTS command outputs the text.
  6325. @end enumerate
  6326. @subsection Body or Inlined Text
  6327. @b{Where:} Various TARGET scripts.
  6328. @example
  6329. #1 Good
  6330. proc someproc @{@} @{
  6331. ... multiple lines of stuff ...
  6332. @}
  6333. $_TARGETNAME configure -event FOO someproc
  6334. #2 Good - no variables
  6335. $_TARGETNAME confgure -event foo "this ; that;"
  6336. #3 Good Curly Braces
  6337. $_TARGETNAME configure -event FOO @{
  6338. puts "Time: [date]"
  6339. @}
  6340. #4 DANGER DANGER DANGER
  6341. $_TARGETNAME configure -event foo "puts \"Time: [date]\""
  6342. @end example
  6343. @enumerate
  6344. @item The $_TARGETNAME is an OpenOCD variable convention.
  6345. @*@b{$_TARGETNAME} represents the last target created, the value changes
  6346. each time a new target is created. Remember the parsing rules. When
  6347. the ascii text is parsed, the @b{$_TARGETNAME} becomes a simple string,
  6348. the name of the target which happens to be a TARGET (object)
  6349. command.
  6350. @item The 2nd parameter to the @option{-event} parameter is a TCBODY
  6351. @*There are 4 examples:
  6352. @enumerate
  6353. @item The TCLBODY is a simple string that happens to be a proc name
  6354. @item The TCLBODY is several simple commands seperated by semicolons
  6355. @item The TCLBODY is a multi-line @{curly-brace@} quoted string
  6356. @item The TCLBODY is a string with variables that get expanded.
  6357. @end enumerate
  6358. In the end, when the target event FOO occurs the TCLBODY is
  6359. evaluated. Method @b{#1} and @b{#2} are functionally identical. For
  6360. Method @b{#3} and @b{#4} it is more interesting. What is the TCLBODY?
  6361. Remember the parsing rules. In case #3, @{curly-braces@} mean the
  6362. $VARS and [square-brackets] are expanded later, when the EVENT occurs,
  6363. and the text is evaluated. In case #4, they are replaced before the
  6364. ``Target Object Command'' is executed. This occurs at the same time
  6365. $_TARGETNAME is replaced. In case #4 the date will never
  6366. change. @{BTW: [date] is a bad example; at this writing,
  6367. Jim/OpenOCD does not have a date command@}
  6368. @end enumerate
  6369. @subsection Global Variables
  6370. @b{Where:} You might discover this when writing your own procs @* In
  6371. simple terms: Inside a PROC, if you need to access a global variable
  6372. you must say so. See also ``upvar''. Example:
  6373. @example
  6374. proc myproc @{ @} @{
  6375. set y 0 #Local variable Y
  6376. global x #Global variable X
  6377. puts [format "X=%d, Y=%d" $x $y]
  6378. @}
  6379. @end example
  6380. @section Other Tcl Hacks
  6381. @b{Dynamic variable creation}
  6382. @example
  6383. # Dynamically create a bunch of variables.
  6384. for @{ set x 0 @} @{ $x < 32 @} @{ set x [expr $x + 1]@} @{
  6385. # Create var name
  6386. set vn [format "BIT%d" $x]
  6387. # Make it a global
  6388. global $vn
  6389. # Set it.
  6390. set $vn [expr (1 << $x)]
  6391. @}
  6392. @end example
  6393. @b{Dynamic proc/command creation}
  6394. @example
  6395. # One "X" function - 5 uart functions.
  6396. foreach who @{A B C D E@}
  6397. proc [format "show_uart%c" $who] @{ @} "show_UARTx $who"
  6398. @}
  6399. @end example
  6400. @include fdl.texi
  6401. @node OpenOCD Concept Index
  6402. @comment DO NOT use the plain word ``Index'', reason: CYGWIN filename
  6403. @comment case issue with ``Index.html'' and ``index.html''
  6404. @comment Occurs when creating ``--html --no-split'' output
  6405. @comment This fix is based on: http://sourceware.org/ml/binutils/2006-05/msg00215.html
  6406. @unnumbered OpenOCD Concept Index
  6407. @printindex cp
  6408. @node Command and Driver Index
  6409. @unnumbered Command and Driver Index
  6410. @printindex fn
  6411. @bye