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.
 
 
 
 
 
 

5260 lines
186 KiB

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