Commit Graph

1423 Commits

Author SHA1 Message Date
Andreas Fritiofson 1fa4c728aa jtag: Rewrite TAP verification/auto-probe logic
Enable auto-creating additional discovered TAPs even if some TAPs are
predefined, avoiding initialization failure when it's not necessary.

Also, drop the arbitrary limit on the number of predefined TAPs. Still,
don't auto-create any if there are more than 20 TAPs already, to stop
a noisy connection from creating unlimited TAPs.

Create auto-probed TAPs with less noise.

Reduce code duplication between verification and auto-probing.

Change-Id: I82a504d92dbcc0060206e71f10c5158256b5f561
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2236
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2015-01-28 08:01:43 +00:00
Jaakko Kukkohovi fe04314c2a jtag/drivers/cmsis-dap-usb: fix cmsis_dap_serial
Previously the serial wasn't actually used in hid_open() call,
which meant that the first device with matching vid:pid was opened
irrespective of the actual serial number.

Change-Id: I45216ae5d9e0798e97be693c30e2f03c89b9a02b
Signed-off-by: Jaakko Kukkohovi <jkukkohovi@gmail.com>
Reviewed-on: http://openocd.zylin.com/2487
Tested-by: jenkins
Reviewed-by: Jörg Wunsch <openocd@uriah.heep.sax.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-26 21:16:42 +00:00
Paul Fertser d940a3224b jtag/drivers/stlink: demote the output of available speeds to DEBUG
Change-Id: If0afb6fb1cb2f39619e4e614573065c145255c3e
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2469
Reviewed-by: Jens Bauer <jens@gpio.dk>
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-26 20:56:25 +00:00
Paul Fertser 9a160c6334 jtag/hla_interface: avoid segfault with adapters that do not have configurable speed
Change-Id: I0386cbfc85ba8b28d3819530f9950b31545d6821
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2468
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-26 20:56:18 +00:00
Spencer Oliver 145f8ed817 stlink: add reconfigurable speed support
The ability to change the speed has been added to firmware versions J22 and
above. Any attempt to change on earlier versions will be ignored without error,
as the existing code does.

For supported firmware versions the driver will attempt to get as close as
possible to supported speeds (never higher).

The default stlink speed on power up is 1.8MHz.
The driver will now also print supported clocl speeds during init.

Change-Id: Iee9bd018bb8b6f94672a12538912d41c23d48a7e
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2335
Tested-by: jenkins
2015-01-15 23:21:18 +00:00
Spencer Oliver ab0432176c hla: add ability to change adapter speed (if supported)
As a note we need to cache the requested speed setting, as the
hla interface may not be ready when the first adapter_khz is called.

Change-Id: I2fa6807d5f0bd3f0365cf178bd10a230c39415a7
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2334
Tested-by: jenkins
2015-01-15 23:21:01 +00:00
Paul Fertser 1f8518fef4 jtag/hla: output possible idcode candidates in case of mismatch
Output a similar message to what we have on low-level JTAG adapters to
avoid confusing users. Reported on IRC by chickensk.

Change-Id: I96d58410ef715b966e32d79c0aacf38596c5eb3f
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2451
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-15 23:17:29 +00:00
Evan Hunter d25b43b163 jtag: Avoid extra SRSTn resets when connecting
Previously the jtag_add_reset(1, 0) caused the processor to be released,
and if SRSTn existed then it would then be reset again two lines later.

Change-Id: I58b7a12607f46f83caa7ed3b3cebc4195eb51ef6
Signed-off-by: Evan Hunter <ehunter@broadcom.com>
Reviewed-on: http://openocd.zylin.com/2398
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-15 23:16:06 +00:00
Paul Fertser 9f6d4d1302 swd: handle various failure conditions
When communication with target fails for whatever reason, it makes
sense to do JTAG-to-SWD (in case the target got power-cycled or the
DAP method was reset anyhow), SWD line reset sequence (part of
JTAG-to-SWD already) and the mandatory IDCODE read. Schedule that to
be performed on the next poll.

Fix the return values for ftdi and jlink drivers to be consistent with
OpenOCD error codes and remove ad-hoc calls to perform DAP method
switching (as it's now done from the upper layer automatically).

Change-Id: Ie18797d4ce7ac43d8249f8f81f1064a2424e02be
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2371
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Mateusz Manowiecki <segmentation@fault.pl>
2015-01-09 08:36:52 +00:00
Andreas Fritiofson 1e23496f6e jtag: Remove unnecessary global variable
Change-Id: I96e5f13b12da2970eafc5fca24b7952d427eeca9
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2235
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-07 23:23:14 +00:00
Andreas Fritiofson 9330147fae jtag: Fix memory leaks in jtag_tap_free()
Change-Id: I953fbb346fbf168fb50b349d245f2aa64dbfdcb3
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2234
Tested-by: jenkins
2015-01-07 23:23:01 +00:00
Paul Fertser 921eb4213a jtag/drivers/jlink: implement register command to fix SWD
Some J-Link fw versions require registration to be performed before
SWD operation is possible. It doesn't harm anyway, vendor's utilities
do it unconditionally.

Thanks go to Segger for providing the necessary information.

Change-Id: Iabd76c743eca86e2c817a97cb93c969fec3f7ac6
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2331
Tested-by: jenkins
2014-11-24 22:18:30 +00:00
Spencer Oliver 885f438814 cmsis-dap: add serial number support
Change-Id: I66926d1013e2b3a43ce0d18d3599771428706b6a
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2329
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-10-16 12:30:50 +00:00
Spencer Oliver ef02315de3 cmsis-dap: refactor HID PID/VID check loop
In preparation for adding serial number support.

Change-Id: I3c9fb411b79d54a4d2de067039255436ba6708c7
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2328
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-10-16 12:30:45 +00:00
Paul Fertser 487c57d9a2 libusb: introduce jtag_libusb_choose_interface() and use it for JLink
This introduces a new common function that allows auto-discovery of a
suitable USB interface based on class, subclass and protocol
matching. It claims the interface and returns the corresponding
endpoints number to the caller.

The need for this arised due to nRF51822 USB dongle which comes with
an "on-board Segger J-link debugger" having 3 interfaces, so the
current code can't work at all with it (in this particular case the
last interface needs to be choosen). This also removes special
handling of JLink-OB endpoint numbers as it's now possible to
autodetect them as well as the standard JLink endpoints.

Change-Id: I4d990a7a3b373efdd2949a394b32d855a168e138
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2327
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 18:40:39 +00:00
Paul Fertser 1f6a66ab7f hla: add a way to pass arbitrary commands from user to layout and use for ICDI
TI's ICDI adapter supports some additional commands which a user might
want to run for debugging or other purposes, the most useful of them
being "debug unlock" that fully mass-erases the device and unprotects
the flash.

Change-Id: I26990e736094367f92106fa891e9bb8fb0382efb
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2263
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 12:03:30 +00:00
Anders 61d8b2cabf jtag/drivers/jlink.c: fix for LPC Link-2 running JLink firmware on Linux
Change 2288 fixed the extraneous reset caused by set_configuration that
crashed the LPC Link-2 running JLink firmware and works on windows platforms.
On Linux however, conditional code was still calling USB reset and caused
the adapter to crash on any non-windows platforms.

Change-Id: Ibf2a02d0dcdd91ccb71d86231cd8311dcadfee1e
Signed-off-by: anders@openpuma.org
Reviewed-on: http://openocd.zylin.com/2297
Tested-by: jenkins
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 11:58:57 +00:00
Anders ca8f8e7e77 jtag/drivers/libusb1_common: avoid device reset when reselecting configuration
According to [1], we shouldn't reselect an already active configuration to avoid needless device reset. This is known to cause issues with e.g. LPC Link2 with JLink firmware.

[1] http://libusb.sourceforge.net/api-1.0/caveats.html#configsel

Change-Id: I3568ada77780a521548c450090db7173f8d0b2dd
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Anders Oleson <anders@openpuma.org>
Reviewed-on: http://openocd.zylin.com/2288
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 11:58:32 +00:00
Spencer Oliver b675edcc95 jtag: constify driver arrays
Change-Id: I81574fa8ca3cc748526dc61b75a2c75d6335ef04
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2294
Tested-by: jenkins
2014-10-06 11:57:36 +00:00
Simon Qian b4f6338738 vsllink: improve the performance when using swd
Versaloon firmware has been updated for reporting
errors if fail on swd transactions.

Change-Id: I49ac0ad034cc9ad83cc4e43953579811d1243063
Signed-off-by: Simon Qian <openocd@versaloon.com>
Reviewed-on: http://openocd.zylin.com/2302
Reviewed-by: Fatih Aşıcı <fatih.asici@gmail.com>
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-29 20:06:20 +00:00
Joakim Gebart b2973be9cc mpsse: Display libusb error names instead of numbers
Added calls to libusb_error_name() where applicable in order to easier
understand the error messages.

Change-Id: I3fe3d4b5624ae0de37c36e54a371eba5535ccaa1
Signed-off-by: Joakim Gebart <joakim.gebart@eistec.se>
Reviewed-on: http://openocd.zylin.com/2289
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-22 19:39:09 +00:00
Austin Phillips 7568a91c8e Support hla_serial command for ST-LINK adapters.
The hla_serial command allows for a programming device serial number to be
specified in addition to USB VID/PID.  This allows for multiple ST-LINK/V2
programmers to be attached to a single machine and operated using openocd.

Change-Id: I350654bf676eb26ba3a90450acfa55d2a5d2d791
Signed-off-by: Austin Phillips <austin_phillips@hotmail.com>
Reviewed-on: http://openocd.zylin.com/2198
Tested-by: jenkins
Reviewed-by: Martin Glunz <mg@wunderkis.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-22 19:36:05 +00:00
Andrey Skvortsov 3a4ec66b24 jtag: drivers: stlink: remove unnecessary '\n' in LOG_* entries
Change-Id: Ia2dc3efc27b53334af4d85f9807abba0463c291b
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Reviewed-on: http://openocd.zylin.com/2220
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-09-15 08:39:16 +00:00
Paul Fertser 96549bf012 jtag/drivers/libusb0_common: fix FTBFS (libusb_device_descriptor error)
This struct and libusb_get_device_descriptor() method are not present
in libusb-0.1 API, so when libusb-1.0 is unavailable, this code breaks
the build. Fix by using the appropriate struct (which is apparently
filled automatically on device initialisation).

While at it, change return values for consistency with the callers.

Change-Id: I7d85ab9a70401a155a65122397008ae4d81382fe
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2252
Tested-by: jenkins
Reviewed-by: Austin Phillips <austin_phillips@hotmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-09-08 20:23:15 +00:00
Paul Fertser bd0409aa93 jtag: always configure enabled tap parameter appropriately
Commit f701c0cb seems to have introduced a regression for non-JTAG
transports as the newly created "tap" (DAP actually) ended up being
disabled, thus resulting in total lack of functionality.

This was exposed by a debug log demonstrating ftdi SWD transport
connection to mdr32f9q2i, the target wasn't examined on init and
couldn't be reset.

Change-Id: If53cbe800d4adc177aa3ac3219860e7fa15b3e49
Reported-by: Хайруллин Эльдар <eldar.khayrullin@mail.ru>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2261
Tested-by: jenkins
Reviewed-by: Angus Gratton <gus@projectgus.com>
Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-22 07:38:42 +00:00
Angus Gratton d50cc1bfea jtag/drivers/ftdi: Use adapter_khz value for initial clock speed (was default 1kHz)
nrf51822 doesn't like a 1kHz initial clock rate, puts the DAP into a bad state.

Mailing list discussion thread: http://sourceforge.net/p/openocd/mailman/openocd-devel/thread/20140718081528.GA5554%40ex2.lan/#msg32621853

Change-Id: I71aa75505cc1b41ee80c7b9db415f6ac738c2916
Signed-off-by: Angus Gratton <gus@projectgus.com>
Reviewed-on: http://openocd.zylin.com/2223
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-19 20:26:26 +00:00
Spencer Oliver 47eceaa229 jlink: Constantify string arrays
Change-Id: Ib63f4c32e6d5a7dad21567521d938142ea40b308
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2245
Tested-by: jenkins
2014-08-19 20:23:18 +00:00
Spencer Oliver 83265a4c70 jlink: add variant "J-Link Lite-ADI"
Fitted to various Analog Devices ADuCM36x dev boards.

Change-Id: Ib3691704c0ecd2f8cba1abba284aee695d6bc135
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2244
Tested-by: jenkins
2014-08-19 20:23:15 +00:00
Spencer Oliver c1c613bdbb jlink: fix typo
Change-Id: If495b819c0532a97447ec7208c13d8a66a3ad47d
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2243
Tested-by: jenkins
2014-08-19 20:23:12 +00:00
Robert Jarzmik 73123ccc57 jtag: usb_blaster: fix initialization regression
As Daniel pointed out, since the rewrite of the USB Blaster driver, the
initialization behaviour has change. The initial flush of the FIFOs is
not longer done with a specific USB setup packet, but with a write
filling up the blaster queues.

The problem is, quoting Daniel :

    When the CPLD is in bit banging mode (as is usually the case), the
    first 0x00 byte sets all pins to low and disables the output
    driver. Disabling the output drivers is a few nanoseconds slower
    than changing a pin from high to low, so I see a spike towards GND
    on my reset line when that byte is sent over USB. The spike is too
    short to have an effect on the board.

    When the 4096 0x00 bytes are processed and the TMS=1 is to be
    generated, all I see is several microseconds of low level on all
    pins, resetting my board.

This patch changes the way the initialization is done :
 - at driver init, nothing is sent towards the usb-blaster
   This gives time for init script to setup PIN6 and PIN8 (resets)
 - at the very first driver command, the initialization is done :
   - the output is in bit bigbang mode
   - the PIN6 and PIN8 are computed according to init script
   - the 4096 computed output is sent

Change-Id: If7ceee957f6b59bcb27c8f912f1cfdd0f94f75ed
Reported-by: Daniel Glöckner <daniel-gl@gmx.net>
Cc: Franck Jullien <franck.jullien@gmail.com>
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Reviewed-on: http://openocd.zylin.com/2229
Tested-by: jenkins
Reviewed-by: Franck Jullien <franck.jullien@gmail.com>
Reviewed-by: Daniel Glöckner <daniel-gl@gmx.net>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:21:02 +00:00
Angus Gratton 9fce8a21ca stlink_usb: Fix swallowed error on read/write operations, add retries on SWD WAIT, clean up error debug output.
- stlink_usb_get_rw_status() had a bug where FAULT or WAIT responses
  in read/write operations were ignored, leading to incomplete data.

- Added wrapper stlink_cmd_allow_retry to handle
  SWD_AP_WAIT/SWD_DP_WAIT statuses in most commands. These statuses
  appear if an SWD read or write received a WAIT ACK response from the
  target more than 4 times in a row. The driver retries the operation
  (with exponential backoff) before failing outright (in testing 1
  retry was always enough.)

- As part of the implementation of stlink_cmd_allow_retry a large
  number of lines of boilerplate were refactored.

- Fleshed out stlink_usb_error_check and added it to some more code
  paths so WAIT or FAULT responses are logged to debug. WAIT responses
  will be logged even if they are subsequently retried, which should
  help in case the retries have subtle side effects (none
  anticipated.)

Tested with two targets: STLINK F0 Discovery, Nordic NRF51822. Only
tested with STLINK V2 programmers.

Change-Id: I9af24e8f0121b035356dbb9978d6bbf4feb2e4d3
Signed-off-by: Angus Gratton <gus@projectgus.com>
Reviewed-on: http://openocd.zylin.com/2201
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-11 22:34:52 +00:00
Paul Fertser c7384117c6 Allow transports to override the selected target (hla configs unification)
This should allow to share common configs for both regular access and
high-level adapters.

Use the newly-added functionality in stlink and icdi drivers, amend
the configs accordingly.

Runtime-tested with a TI tm4c123g board.

Change-Id: Ibb88266a4ca25f06f6c073e916c963f017447bad
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
[gus@projectgus.com: context-specific deprecation warnings]
Signed-off-by: Angus Gratton <gus@projectgus.com>
[andrew.smirnov@gmail.com: additional nrf51.cfg mods]
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Tested-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Reviewed-on: http://openocd.zylin.com/1664
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-11 21:25:56 +00:00
Angus Gratton f701c0cbeb newdap: Ignore -irlen/-irmask/etc newdap params on SWD or CMSIS-DAP
Previously the -irlen parameter was required even though it is not
a part of the SWD or CMSIS-DAP transports.

This may eventually need to be changed for CMSIS-DAP once that
supports JTAG as well.

Change-Id: Ia02b67840c19c7cf1c7a75063648c0174176a311
Signed-off-by: Angus Gratton <gus@projectgus.com>
Reviewed-on: http://openocd.zylin.com/2226
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-11 20:49:05 +00:00
Andreas Fritiofson f75345b915 drivers/jlink: Revert old workaround
This workaround broke usage with at least the I.MX6Q.

The comment implies that talking to the J-Link dongle itself should
fail if the target isn't reset, which sounds really strange. I'm
guessing it just triggered another bug in OpenOCD or Segger FW which
might have been fixed since. Revert and wait and see if there are any
failure reports.

Tested with Kwikstik (J-Link + Kinetis K40), not with the mentioned
adapter.

Change-Id: I97f555efe079bd99c098bf483491d9509b2363ad
Signed-off-by: Roy Spliet <rspliet@mpi-sws.org>
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2147
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-08-02 13:54:39 +00:00
Paul Fertser 66e20117e8 drivers/jlink: fix SWD speed config, and set it before sending anything
During the initialisation a driver might need to communicate with the
target (e.g. sending jtag2swd sequence), so when doing so it should
honour the user-specified speed.

Change-Id: If84fea6057fda9edcf2c0a653edfbab2500e3cdd
[andrew.smirnov@gmail.com: fix khz/hz confusion]
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2224
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-02 13:53:59 +00:00
Paul Fertser 6733253219 drivers/jtag/jlink: support SWD mode
Quick attempt at SWD support, closely modelled after ftdi.

Change-Id: I25140d80c5be7b2f8f0e2ef722a4ba4df0da4cf3
Signed-off-by: Brian Campbell <Brian.Campbell@ed.ac.uk>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2141
Tested-by: jenkins
Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-02 13:53:33 +00:00
Masaki Muranaka 11274d2283 drivers/cmsis_dap_usb: Return with ERROR_FAIL if no CMSIS-DAP device is found.
Even if it does not return, the initialization will be failed.
But it is better to show why the error is caused.

Change-Id: I399c7c94a7156be22723a9715e594061bb414a7e
Signed-off-by: Masaki Muranaka <monaka@monami-ya.com>
Reviewed-on: http://openocd.zylin.com/2189
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-10 21:18:08 +00:00
Fatih Aşıcı 84281d711e vsllink: Port to libusb-1.0 API
Change-Id: I8a9a4dace8e7e8152947094b27b86f9a0d90fa61
Signed-off-by: Fatih Aşıcı <fatih.asici@gmail.com>
Reviewed-on: http://openocd.zylin.com/1952
Tested-by: jenkins
Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-07-03 19:43:16 +00:00
Fatih Aşıcı 5f9c59409b vsllink: Add SWD support
Tested with stm32f1x, stm32f4x and kl25 targets using SWD transport.

Change-Id: I118d07371b53f402ea9ac73f874460a309c05100
Signed-off-by: Fatih Aşıcı <fatih.asici@gmail.com>
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1947
Tested-by: jenkins
2014-07-03 19:43:01 +00:00
Paul Fertser d48b47e432 jtag/drivers/opendous: remove ftime() calls
ftime() is deprecated by POSIX.1-2008 and causes a warning on
FreeBSD.

The generic OpenOCD LOG_DEBUG implementation already outputs time of
an event with a millisecond precision.

Change-Id: Ic8e4ea27c268f07554ba519768b9bdfc4343f3e9
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2187
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-03 18:41:39 +00:00
Paul Fertser 3039f01aaf drivers/cmsis_dap_usb: restructure init sequence a bit
This fixes the issue of improper initialisation sequence and in
particular makes "cmsis_dap_vid_pid" config specification functional.

Not really elegant but it's in line with the ftdi driver and so can be
reworked in a uniform way later when the internal API is changed.

Change-Id: Ief9fc64ad0ac24e1c66727153f383e4f30a830c7
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2192
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-03 18:40:59 +00:00
Paul Fertser aa79f7b7e0 jtag/drivers/cmsis_dap: fix check for hardcoded vids/pids
This is intended to fix cmsis_dap_vid_pid command but it doesn't
because cmsis-dap has only one transport and it's auto-selected from
"interface" command handler (before any other commands are run) and as
the result cmsis_dap_usb_open() is called too early.

Change-Id: Idaade73797d8df67a6439d096f6abc9736495599
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2191
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-03 18:40:49 +00:00
Paul Fertser 52b80fbd82 jtag/drivers/ftdi: do not touch unavailable reset signals
If the current reset_config doesn't specify availability of nTRST or
nSRST, just leave them alone, do not try to deassert them ever
(asserting would be prevented by the upper layer).

Change-Id: I90123c666e05a1c26f1e164625e82d766a3e3744
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2186
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 16:52:08 +00:00
Paul Fertser bf96df255e jtag/drivers/ftdi: require defining SWD_EN signal for SWD mode
Use a special signal instead of a dedicated swd mask. Amend
jtag-lock-pick_tiny_2 config accordingly.

Change-Id: Ifb007a0b5434b590c52f936efd5f5458e913e2e4
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2183
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
2014-06-28 09:36:53 +00:00
Paul Fertser 64d02ccf82 jtag/drivers/ftdi: declare standard JTAG signals on SWD init
Unfortunately, this means they're available for config files only
after selecting swd transport.

Change-Id: Ia2afc1f3bfdba8d81efbb8ab964b174c0f7e2811
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2182
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 09:36:17 +00:00
Paul Fertser a87e699edf jtag/drivers/ftdi: add option to declare signal aliases
This adds -alias|-nalias options to ftdi_layout_signal command that
allow to declare a new signal based on an already defined one.

Change-Id: I552578ebcd12ae21957a1c0d3b7e878adeff6df0
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2181
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 09:36:02 +00:00
Paul Fertser 335bafbb25 Auto-select JTAG transport when appropriate
I looked through all the target configs after stripping comments and
such from them with sed to see what jtag-specific commands can appear
first, and it looks like all the meaningful combinations should be
covered.

Change-Id: I8d543407b7f4ac8aca7354ecd50e841c8a04d5f3
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2179
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 09:35:38 +00:00
Andreas Fritiofson 12e9f6292b Relax polling check if not in JTAG mode
Polling was disabled based on global variables jtag_trst and jtag_srst
which were never touched in non-JTAG mode. Modify the check and remove
the ugly workaround to avoid calls to a possibly uninitialized JTAG
subsystem.

Change-Id: I3b18c81e0fba7aaf35afe6f08c3fe8fa6f8443fd
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2143
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:34:55 +00:00
Andreas Fritiofson cdd8928a56 Add FTDI SWD driver
This is usable on most or all FTDI adapters using a small hardware tweak.

TCK goes to SWCLK as expected. TDO should be wired to SWDIO. For TDI there
are two options:

Either add a 74HC126 or similar tri-state buffer between TDI and SWDIO,
with OE controlled by a signal named SWDIO_OE. Or simply connect TDI and
SWDIO together via a suitable resistor (220-470 ohms or so depending on
the drive capability of the target and adapter).

nSRST (and of course Vcc, GND) may be connected too but all other signals
should be NC.

Change-Id: Id36cf4577439be96bd4e5955c3026236e1cabced
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1958
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:34:26 +00:00
Andreas Fritiofson cc99e57b0e transport: Constify the transports vector
Change-Id: I0c874b5d4c97cf781d83bd381d701f770e069f72
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2135
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:33:31 +00:00
Andreas Fritiofson ae3bcd05f8 swd: Add frequency setting and special/switching sequences to the API
Change-Id: I6f3950374f2525a18bbcb9cbd340c447c20fb704
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2134
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:33:12 +00:00
Andreas Fritiofson 5a7eae940b swd: Remove support for turnaround periods other than 1
ARM deprecated other trn periods in ADIv5.1 and one cycle is the only
setting that is guaranteed to be implemented, as well as being the reset
value in ADIv5.0.

Thus it makes no sense supporting anything else.

Change-Id: Iffa16bb0ce74788bca88fd3ace8a026148013d00
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2132
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:32:21 +00:00
Andreas Fritiofson bc91cdad3c swd: Fix park bit polarity according to ADIv5.1 Supplement
Change-Id: I27293defd3f3c3bf37c9662f88689e85ba593d86
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2131
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:31:55 +00:00
Andreas Fritiofson d2bb14e36a swd: Convert API to asynchronous
Change-Id: I859568dbb2ad4e92411980751c3f747bd70638b8
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1959
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:31:38 +00:00
Paul Fertser 6db70bc89b drivers/cmsis_dap_usb: remove jtag reset hacks
This should no longer be needed after tcl scripts are fixed to avoid
calling jtag subcommands when jtag is not used.

Barely tested with an frdm board.

Change-Id: I75f02b088e6134562ae634417d97c48e377df6e9
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2130
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 09:28:36 +00:00
Paul Fertser f8a6a07149 tcl: introduce using_(jtag|swd|hla) helpers and use them in reset handler
Barely tested with plain SWD transport.

Change-Id: I48b59136bf4294ffed737dba01f1b30ef83aa86b
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2003
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 09:28:12 +00:00
Andreas Fritiofson 36772a7ed0 swd: Improve parity calculation and move it to types.h
It could be reused by SWD drivers and in other places.

Change-Id: Ieed0cf70c111a73d3a42ed59f46a0cdd177a73d5
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1957
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:27:19 +00:00
Andreas Fritiofson 677b02b475 adi_v5: Remove unused features of the DAP and SWD interfaces
These features are not currently used so remove or disable them before
something starts to. Not having them around simplifies redesign of the
APIs.

Change-Id: Iad25cc71c48b68a1fa71558141bf14d5ab20d659
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1955
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:26:36 +00:00
Fatih Aşıcı 31138437c3 adi_v5_swd: Improve SWD support
Fix bug in parity calculation macro.

Cache and update the selected DP bank when necessary.

Add aborts when the Ack code signals a failure (we should really only
clear the sticky bits, but this will do for now).

Change-Id: I38a4da136ba1d9e989b33c1875a80c0b1b2be874
Signed-off-by: Fatih Aşıcı <fatih.asici@gmail.com>
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1950
Tested-by: jenkins
2014-06-28 09:25:06 +00:00
Paul Fertser 8ae66d0d6f jtag/drivers/jlink: better diagnostics for RCLK problems
The JLink protocol description doesn't really specify it for
JTAG-level commands but the real life evidence is that 0x01 error code
means "Adaptive clocking timeout" as it does for e.g. WRITE_MEM_ARM79.

Change-Id: I4e3b568742814271919f92d202713968c8fcccfb
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2169
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-06-22 09:25:15 +00:00
Paul Fertser 5375a9e1d8 jtag/drivers/osbdm: downgrade init message severity, fix wording
Change-Id: Iacf874b0fe9fbf840e82e6b63f1c97031f4720de
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2156
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-01 18:23:14 +00:00
Paul Fertser fb5e099af8 jtag/drivers/stlink: allow to reconnect seamlessly after polling failure
If the communication with the target was failing (either because of an
intermittent connection or the target was rebooted), this is needed to
reestablish operational state.

Reported-by: Tim Sander <tim@krieglstein.org>
Tested-by: Tim Sander <tim@krieglstein.org>
Change-Id: I91ea2e2b2b5ef8eb27dfe9bae95ef2a919f67e4e
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2152
Tested-by: jenkins
Reviewed-by: Tim Sander <tim@krieglstein.org>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-06-01 17:28:49 +00:00
Andreas Fritiofson 4a4f716163 ftdi: Optimize GPIO toggling
Only send the new I/O state for the bytes that changed.

Change-Id: I930edc9518e6019331e68e4756acc5e92dda25a4
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1999
Tested-by: jenkins
Reviewed-by: Jens Bauer <jens@gpio.dk>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2014-05-09 19:27:50 +00:00
Spencer Oliver 31496c2bed usb_blaster: fix warning: array subscript has type ‘char’
caught by clang 3.4 running on cygwin.

Change-Id: I59f652337334e557fb50374f5270ba9c30392b6e
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2100
Reviewed-by: Jörg Wunsch <openocd@uriah.heep.sax.de>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
2014-04-14 18:19:56 +00:00
Paul Fertser 3a590658e9 jtag/drivers/remote_bitbang: use sizeof to determine maximum unix socket path length
Different *nix systems use different constants, so sizeof should be
used instead. This fixes the build on OS X (as sun_path length is
hardcoded to 104 on Darwin).

Change-Id: I1df611383dedcfc6d153ec59b453a895c7d84e94
Reported-by: Xiaofan Chen <xiaofanc@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2095
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
2014-04-14 18:16:52 +00:00
Karl Hammar 7256d6acdf parport: add "aspo" hotpluggable adapter config
This adds a new adapter config.

Design files are available from:

http://turkos.aspodata.se/git/openhw/isp/pp_jtag_arm20.sch
http://turkos.aspodata.se/git/openhw/isp/pp_jtag_arm20.pcb

No need to document it anywhere as only a single device was ever
built.

Change-Id: If031fdb9dedb1e544401747bfb7fbc5afc4d5407
Signed-off-by: Karl Hammar <karl@aspodata.se>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2094
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-04-14 18:13:03 +00:00
Paul Fertser 45f71f1082 Makefile.am: fix build for libftdi1, pass CFLAGS where appropriate
Change-Id: I9d8afa6ae32fc01e69ec434b5bc9d71524d386a2
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2079
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
2014-04-14 18:09:40 +00:00
Paul Fertser 9f2bc3b830 jtag/aice/aice_usb: remove unused constants
Those are breaking the build with clang 3.4 (current default compiler
on OS X 10.9.2).

Change-Id: I9f2fbfbb6d544498cb8d6a62565e4ebe7223e784
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2077
Tested-by: jenkins
Reviewed-by: Hsiangkai Wang <hsiangkai@gmail.com>
2014-04-08 11:37:36 +00:00
Andreas Fritiofson e6907e6d7e Don't cast return value of [cm]alloc
Change-Id: I0028a5b6757b1ba00031893d9a2a1725f915a0d5
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2069
Tested-by: jenkins
Reviewed-by: Jörg Wunsch <openocd@uriah.heep.sax.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-03-30 03:53:45 +00:00
Paul Fertser 7301bf1a67 Add usb_blaster cheap clone notes to dist
Change-Id: Ie9569634415ef76e88d5ca58bae6184838cf7114
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1908
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-03-29 07:56:13 +00:00
Paul Fertser 7a16340343 Add rlink speed table sources and everything related to dist
GPL requires providing sources for any derived work. I do not see any
reason to not include the rlink stuff into release tarballs.

Change-Id: I686ab88994030312aca5bdfe731a72f10803b5c3
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1907
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-03-29 07:55:50 +00:00
Andrey Yurovsky fb897cc805 jlink: add support for Jlink-OB (0x0105) devices
The JLink-OB (onboard) devices work the same way as the normal JLink
except that their PID is 0x0105 (and that's the only one we know of so
far) and their endpoint addresses are different due to there being a
CDC-ACM interface as well.  These JLink-OB devices show up on a lot of
vendors' development kits as an integrated debugger.

This change simply checks whether the adapter we opened has a JLink-OB
PID and, if it does, uses the JLink-OB endpoints rather than the
default.  To do this, we add a new routine, jtag_libusb_get_pid() to the
libusb adapter layer, it in turn just calls
libusb_get_device_descriptor(), which previously had no wrapper.

Also, checkpatch.pl doesn't like the VID/PID macros as defined so I
moved them to the array itself.  This should have no effect on the code.

This change adds the 0102 through 0104 PIDs to openocd.rules as well as this
new 0105 PID.

Tested on an Atmel SAM4S Xplained board which has a JLink-OB, also
regression tested by using a 0x0101 PID normal JLink adapter.

Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Change-Id: I121d30e57729cda3adb66e2a5dc72e1fcb7ef8b1
Reviewed-on: http://openocd.zylin.com/2031
Tested-by: jenkins
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-03-29 07:12:42 +00:00
Andreas Fritiofson 09e9625d6c ft2232: Mark interface driver as deprecated
Change-Id: I5ebc924ab66c86f1902942bebc203a34d97abc64
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1899
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-03-28 10:07:01 +00:00
Jörg Wunsch d2273d10b6 CMSIS-DAP: print a debug message when the USB product string cannot be read
As suggested by Stian Skjelstad in a comment in:

http://openocd.zylin.com/#/c/2044/

if the USB product string cannot be read, provide a debug message so
users might get aware of a potential permission problem when looking
at the debug output.

Fix style bug found by Jenkins.

Change-Id: I6acb1c6261fec6f2bee80e4be513a5c5e29eff79
Signed-off-by: Jörg Wunsch <openocd@uriah.heep.sax.de>
Reviewed-on: http://openocd.zylin.com/2048
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-03-17 12:49:50 +00:00
Jörg Wunsch 325066149f All Atmel-provided CMSIS-DAP devices use 512 byte packet size
The existing CMSIS-DAP driver matches the USB VID/PID against 0x3eb
(Atmel VID) and 0x2111 (Atmel EDBG embedded CMSIS-DAP debugger), and
then bumps the packet size from its default of 64 to 512.  However, it
turned out that *all* Atmel-provided CMSIS-DAP devices (EDBG with PID
0x2111; JTAGICE3 with firmware version 3.x, PID 0x2140; new Atmel-ICE
[successor of JTAGICE3], PID 0x2141) require a 512-byte packet size.
Obviously, all run the same USB implementation inside their custom
microcontroller.  Thus, it seems best to simply assume that *all*
Atmel CMSIS-DAP devices use this packet size, and don't check the PID
at all.

This has also been filed as Trac bug #68:

https://sourceforge.net/apps/trac/openocd/ticket/68

Change-Id: I942af93060fdf265fca3961841638caa6182f877
Signed-off-by: Jörg Wunsch <openocd@uriah.heep.sax.de>
Reviewed-on: http://openocd.zylin.com/2045
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
2014-03-17 12:49:07 +00:00
Jörg Wunsch 0c7db47e58 Prevent segfault when the USB product string cannot be retrieved
In the CMSIS-DAP driver, if nothing has been specified by the user, an
attempt is made to find the first device with the (mandatory)
substring "CMSIS-DAP" in any USB device's product string.  However,
while (usually) all devices can be traversed, devices the user does
not have permission for cannot be read the product string from,
resulting in a NULL pointer.  Trying to find the substring "CMSIS-DAP"
causes a segementation fault then.

This has also been filed as Trac bug #67:

https://sourceforge.net/apps/trac/openocd/ticket/67

Change-Id: Idfc9f072e34152e9af99fe1c8ec88c99dea4624c
Signed-off-by: Jörg Wunsch <openocd@uriah.heep.sax.de>
Reviewed-on: http://openocd.zylin.com/2044
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-03-17 12:48:29 +00:00
Bartosz Bielawski 4c9d6038b2 stlink_usb.c: add support for STLink V2-1
The new version of STLink (V2-1) has a different USB endpoint layout.
As the PID of the device also changed it's possible to change EPs used
by OpenOCD in runtime. The patch adds three new fields to stlink_usb_handle_s
and assigns right EP numbers in stlink_usb_open().
Parts of the code inspired by and used with consent of Jens Hoffmann.

Change-Id: I93b69fb889f15317e9bf864905f435905db39745
Signed-off-by: Bartosz Bielawski <bartosz.bielawski@gmail.com>
Reviewed-on: http://openocd.zylin.com/2019
Tested-by: jenkins
Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-03-17 12:41:57 +00:00
Andreas Fritiofson 17fddb4289 stlink: Use callback to increase frequency of trace data sampling
The ST-LINK/V2 has limited internal buffering, such that trace data
can be missed if the target is generating data at a rate quicker than
the OpenOCD trace sampling. The issue of lost data is compounded since
individual TPIU packets may be split across individual STLINK_TRACE_EP
reads, and misleading results can occur if mid-packet loss occurs.

This patch increases the frequency of checking for pending trace data
with the aim of minimising such losses. Note: With the limited (I/O
and memory) bandwidth of the ST-LINK/V2 there cannot, however, be a
guarantee against trace data loss.

The timer callback is only added when enabling tracing, and is removed
when tracing is disabled.

Change-Id: Ibde9794b77793d3068f88cb5c1a26f9ceadcbd8a
Signed-off-by: James G. Smith <jsmith@ecoscentric.com>
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1661
Tested-by: jenkins
2014-03-07 21:19:12 +00:00
Jens Bauer d585c1627a CMSIS-DAP: Fix build errors on Mac OS X
Rename the argument variable 'wait' to 'delay', as 'wait'
conflicts with an API function declared in system header
/usr/include/sys/wait.h on Mac OS X.

Change-Id: I5742da6e5def6e5ec197e774c3844e4bf0424569
Signed-off-by: Jens Bauer <jens@gpio.dk>
Reviewed-on: http://openocd.zylin.com/1973
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-03-04 20:18:17 +00:00
Antony Pavlov b27c53354d drivers/jtag: usb_blaster: make command handlers more strict
If user used wrong argument number for some usb_blaster_* commands
then openocd show just warning message.
This commit makes command handler's behaviour more strict and
openocd treats wrong argument number as an error.

In addition we already have 'help' and 'usage' information in
struct command_registration ublast_command_handlers[],
so we can drop redundancy messages in command handlers.

Change-Id: I73b8c75ec60a18e5258a4bdffe972e8a1afc1066
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Reviewed-on: http://openocd.zylin.com/1942
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-02-24 12:09:15 +00:00
Paul Fertser bb0ef230ca tcl/drscan: handle invalid syntax with a conditional, not assert
When "drscan" command is used improperly, such as in:
drscan stm32f1x.cpu -endstate drpause
there're no fields to scan, and so the assert leads to a
segfault. This should be treated like any other syntax error instead.

Change-Id: Id1743f5d641038e1e3754c6f3097aabc5d1916b9
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1927
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-02-24 12:01:52 +00:00
Antony Pavlov 98b808923f usb_blaster: ublast_access.h: add guard macro
Change-Id: I10f6e2048cf88f64f5dce275a273783365afd65c
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Reviewed-on: http://openocd.zylin.com/1941
Tested-by: jenkins
Reviewed-by: Robert Jarzmik <robert.jarzmik@free.fr>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-02-24 12:01:34 +00:00
Paul Fertser 1f35e124d3 drivers/ftdi: warn the user if he tries to use undefined reset signals
It is really an error to try to use a reset_config that doesn't match
adapter's capabilities, however OpenOCD has no way to specify them.

Using wrong reset_config might lead to very confusing behaviour, so I
think LOG_ERROR is justified here.

Change-Id: I1c6dcfa7c0d78829229a850189cad646b565dd66
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1948
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-02-24 11:57:07 +00:00
Paul Fertser 6d46ad11b5 ft2232: warn about lack of TRST on "turtle" adapter
This patch fixes a build error (assigning a variable to itself) with
clang.

Since this adapter lacks trst, trying to use it in reset_config will
fail silently. Warn the user accordingly.

Change-Id: I16fd20936f00d7ff82962f4fcc629ff434aa4dce
Reported-by: Rainer Müller <raimue@codingfarm.de>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1946
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-02-24 11:56:54 +00:00
Peter Lawrence 3271e6d4d5 CMSIS-DAP: auto-detect CMSIS-DAP USB VID:PID
The current OpenOCD implementation requires CMSIS-DAP adapter USB
VID:PID values to either be hard-coded in the source or manually
supplied by the user's configuration files.  The CMSIS-DAP
specification stipulates that all compliant adapters should have
"CMSIS-DAP" in the product string.  This should obviate the need
for hard-coding.

This patch was previously submitted as changes 1882, 1883, and 1886
but amendments failed to be registered by the server.  The
functionality was changed from 1886 in response to comments so that
user-supplied VID:PID values overrided the CMSIS-DAP auto-detect.

Change-Id: Ifb2dc217248359f448e0a42bd1527dd744c434b0
Signed-off-by: Peter Lawrence <majbthrd@gmail.com>
Reviewed-on: http://openocd.zylin.com/1888
Tested-by: jenkins
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-23 21:32:46 +00:00
Andreas Fritiofson 63fa73169b Retire jtag_add_dr_out
The out only version of jtag_add_dr_scan smells like a bogus optimization
that complicates the minidriver API for questionable gain.

The function was only used by four old ARM targets. Rewrite the callers
to use the generic function and remove all implementations.

Change-Id: I13b643687ee8ed6bc9b6336e7096c34f40ea96af
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1801
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-20 13:28:26 +00:00
Franck Jullien 87e91f4db9 jtag/drivers: add USB-Blaster II
This patchs adds a new access driver for the existing
USB-Blaster interface driver.

This interface (as it is build-in on the sockit development
board) is composed of a Cypress EZ-USB plus a CPLD.

The Cypress chip as an embedded 8051 microcontroller.
When it's powered up, the firmware is downloaded to the
chip then the device is disconnected and reconnected with
the new firmware.

The USB-Blaster II protocol is almost identicial to
the old one. The only difference is that you need to
send a 0x5F before read TDO back. This command
seems to copy TDO buffer datas to the endpoint buffer.

Driver will be auto enabled if libusb-1.0 is detected.

Change-Id: I562a720a68cb4dcabeab791947d5d38776cb70fa
Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
Reviewed-on: http://openocd.zylin.com/1791
Tested-by: jenkins
Reviewed-by: Robert Jarzmik <robert.jarzmik@free.fr>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-20 13:28:02 +00:00
Hsiangkai Wang 94d64ccaeb Conform to C99 integer types format specifiers
Review and modify to conform to C99 integer types format specifiers.
Use arm-none-eabi toolchain to build successfully.

Change-Id: If855072a8f88886809309155ac6d031dcfcbc4b2
Signed-off-by: Hsiangkai Wang <hsiangkai@gmail.com>
Signed-off-by: Hsiangkai <hsiangkai@gmail.com>
Reviewed-on: http://openocd.zylin.com/1794
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-15 12:40:42 +00:00
Spencer Oliver 4dc8cd201c cmsis-dap: add initial cmsis-dap support
This is based on work from:
https://github.com/TheShed/OpenOCD-CMSIS-DAP/tree/cmsis-dap

Main changes include moving over to using HIDAPI rather than libusb-1.0
and cleaning up to merge into master. Support for reset using srst has
also been added.

It has been tested on all the mbed boards as well as the Freedom board
from Freescale. These boards only implement SWD mode, however JTAG mode
has been tested with a Keil ULINK2 and a stm32 target - but requires a lot
more work.

Change-Id: I96d5ee1993bc9c0526219ab754c5aad3b55d812d
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/1542
Tested-by: jenkins
2014-01-09 15:20:51 +00:00
Franck Jullien bc256b17d5 jtag_vpi: make the server address configurable
Change-Id: I58e89c789b79ffb0b54ef94d208be876c271ddf7
Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
Reviewed-on: http://openocd.zylin.com/1840
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-12-31 12:00:49 +00:00
Mathias K 963214c83d stlink: remove stlink_api command
Remove stlink_api command.

Change-Id: I8f7885d3756fec462f9ebbee2ed285a98a51366c
Signed-off-by: Mathias K <kesmtp@freenet.de>
Reviewed-on: http://openocd.zylin.com/1760
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-12-22 20:24:56 +00:00
Franck Jullien 0da3f66ed4 jtag_vpi: fix build errors under MinGW
Change-Id: Ic13f9982014ead811e2f2d737ca1621e0e85577e
Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
Reviewed-on: http://openocd.zylin.com/1839
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-12-22 13:14:04 +00:00
Andreas Fritiofson 255301fb50 versaloon: Finish support for serial number matching
Add a command to specify the serial string and pass it to the find helper.
Actual matching was already supported for both serial and product but was
using hard coded string indices. Instead use the indices from the device
descriptor.

Change-Id: I17c7538e5ad301ef41eace1ee70a202adab23bb4
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1816
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-12-17 22:55:31 +00:00
Mathias K 1e6970dafd hla: Make consistent parameter naming
Rename fd to handle.

Change-Id: I98615aed1546976d00b0f20856d4e8e75f83c575
Signed-off-by: Mathias K <kesmtp@freenet.de>
Reviewed-on: http://openocd.zylin.com/1761
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-11-07 22:19:50 +00:00
Andreas Fritiofson 2ad2554e52 ulink: Fix libusb include changed since pkg-config merge
Change-Id: I1556aaf117f99de046e3c16d5386faaaefdfefd8
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1795
Reviewed-by: Peter Stuge <peter@stuge.se>
Tested-by: jenkins
2013-11-06 13:10:16 +00:00
Paul Fertser 56d4a59548 jtag: fix support for really long scans
When programming large FPGAs the generated SVF files might contain really
long SDR scans. They won't fit in the 1MiB jtag scan page at all, so in
this case the allocated page needs to be bigger. The current code was
silently corrupting memory.

One particular example was sent by Volter targetting XC3S4000. It has an
SDR 11316992 bits long, that is 1414624 bytes.

Change-Id: I39f18d7e0654f2dbdf37df58c837c9ec1fb2aa2a
Reported-by: "Voltner, Jiří" <j.voltner@era.aero>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1792
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-11-06 13:08:38 +00:00
Alan Bowman 6adc1ced89 Correct argument numbering in trace command
The trace command was opening a file named with the source frequency.
This change correctly passes the filename that is specified.

Change-Id: Ia2eb8eda0e1e0f4f44b05c3a0ce7bef3bda51446
Signed-off-by: Alan Bowman <alan.michael.bowman@gmail.com>
Reviewed-on: http://openocd.zylin.com/1800
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-11-06 12:59:04 +00:00
Andreas Fritiofson 484dbcc302 ti_icdi_usb: Remove unnecessary casts and fix byte order bugs
Found by grepping for pointer casts.

Some additional cast can be removed if hexify/unhexify arguments are
changed to a more suitable type.

Change-Id: I13796b056f00976979bf0e754de3aa7648f7f321
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1778
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-10-31 20:45:46 +00:00
Andreas Fritiofson 582c8b0147 ftdi: Remove unnecessary cast
Also make sure future growth of the tap_get_tms_path() return value will
get noticed.

Change-Id: Id859b463e5fdc819a4bc3b4845bf4363fbe713af
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1768
Tested-by: jenkins
Reviewed-by: Mathias Küster <kesmtp@freenet.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-10-31 20:43:35 +00:00
Andreas Fritiofson ba2fbe2247 Remove unnecessary casts
Change-Id: Ia97283707282ccccdc707c969f59337313b4e291
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1767
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-10-31 20:43:27 +00:00