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.

8774 lines
329 KiB

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