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.
 
 
 
 
 
 

4469 lines
161 KiB

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