aboutsummaryrefslogtreecommitdiff
path: root/src/jtag
AgeCommit message (Collapse)AuthorFilesLines
2019-04-10fix for sanitizer errors in left shiftsMete Balci1-1/+1
The modified lines cause "runtime error: left shift of <X> by <Y> places cannot be represented in type 'int'", because integer literal is cast to int by default. Change-Id: Ie38119b5eb46ee470e0d149959e523b48ac4d66d Signed-off-by: Mete Balci <metebalci@gmail.com> Reviewed-on: http://openocd.zylin.com/5005 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-10jtag: tcl: Add cget -idcodeLeonard Crestez1-2/+19
This can be used to dynamically distinguish between similar chips in tcl code. Change-Id: Ic4dfb61693e78616355173142dc7f9b9683a9f73 Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com> Reviewed-on: http://openocd.zylin.com/5033 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2019-04-07Set empty usage field for commands that do not need parametersAntonio Borneo5-4/+12
The missing field causes runtime debug message BUG: command '%s' does not have the '.usage' field filled out While there, fix some minor typo in the help messages: s/deasert/deassert/ s/Deasert/Deassert/ Change-Id: If3dd18265cda103ca0d05609f67f4ca58e7cbb27 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5024 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-07drivers/at91rm9200: fix help and usage to command "at91rm9200_device"Antonio Borneo1-1/+2
Add usage and fix the help text of the command Change-Id: I0e157d76f5d87bcda80f82a110912994908c8e03 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5023 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2019-04-07drivers/vsllink: add help and usage to commandsAntonio Borneo1-0/+12
Change-Id: I4a8a68147011525191ca79e65fc3d7e760371ae1 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5020 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-07drivers/bcm2835gpio: fix usage messagesAntonio Borneo1-2/+18
The notation "(tck tms tdi tdo)* " is incorrect, because it means the quadruple of gpio can be repeated on the command-line. The correct syntax of the command requires instead to provide either all the four gpio numbers (in order to set the values) or to pass an empty command-line (to dump the values previously set). Change the .usage field to "[tck tms tdi tdo]". Change similarly the corresponding .usage field for SWD command. Add the .usage field for the commands that individually set each gpio or gpio property. Dump the previously set values when commands bcm2835gpio_speed_coeffs or bcm2835gpio_peripheral_base are executed with empty command-line. Change-Id: Ie45d8268c1de331aded0bb52d5e6b8f0e8766a5b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5019 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2019-04-07drivers/imx_gpio: fix usage messagesAntonio Borneo1-2/+18
The notation "(tck tms tdi tdo)* " is incorrect, because it means the quadruple of gpio can be repeated on the command-line. The correct syntax of the command requires instead to provide either all the four gpio numbers (in order to set the values) or to pass an empty command-line (to dump the values previously set). Change the .usage field to "[tck tms tdi tdo]". Change similarly the corresponding .usage field for SWD command. Add the .usage field for the commands that individually set each gpio or gpio property. Dump the previously set values when commands imx_gpio_speed_coeffs or imx_gpio_peripheral_base are executed with empty command-line. Change-Id: Id56a68622817101bd0a46fed1fead6d2cd2b6ec6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5018 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-07command_registration: add empty usage field to chained commandsAntonio Borneo2-2/+5
Chained command require a subcommand as first argument. The usage field for chained commands is not really important because the "help" command will list all the subcommands with their respective usage. Add a empty usage field on all chained command. The command "jlink config" can be either followed by a subcommand or used alone, so use a dedicated usage string. Change-Id: I43c3f8a766f96a9bdab4e709e3c90713be41fcef Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5017 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-03-26stlink: Set speed before entering JTAG/SWD modeFrans-Willem Hardijzer1-22/+26
Some boards require a slower clock speed because of passive components on the JTAG/SWD lines. The previous implementation would first try to discover the chips on the default speed, and only after discovery switch to the requested adapter_khz speed. This patch moves the speed change to just before entering the SWD/JTAG mode, which should alleviate this problem. Tested on an STLink V2 clone. Change-Id: I9734452dcc8bb28d6629e64d9a7e32ef92868cf9 Signed-off-by: Frans-Willem Hardijzer <fw@hardijzer.nl> Reviewed-on: http://openocd.zylin.com/4818 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2019-03-08drivers/stlink_usb: use command STLINK_DEBUG_APIV2_READ_IDCODESAntonio Borneo1-5/+13
API v2 deprecates using command STLINK_DEBUG_READCOREID to read the core ID. Switch to STLINK_DEBUG_APIV2_READ_IDCODES on new stlink firmware version. Change-Id: Iabadfc116c57f2c31f08f2e77baefea0cf90bdc3 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4826 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-03-08drivers/stlink_usb: check error code returned by st-linkAntonio Borneo1-36/+46
Most of ST-Link commands return an error code, but this is almost never checked. Check for the error code for every command that returns it. Change-Id: Ifc4e32f8c73196de23700ba0989bfdfe0f5b46e3 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4825 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-03-08drivers/stlink_usb: fix stlink_usb_read_regs() for API v2Antonio Borneo1-9/+10
API v2 implementation for command READALLREGS returns the status in the first two bytes, followed by two bytes of padding. This makes the reply 4 bytes longer and changes the offset of the first register value to 4. Fix it for the case API v2 and clean-up the management of the return value. Change-Id: I448c82bcc0baa72d66fdfe7f0c525b94f8a4468b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4824 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-03-07stlink: handle error GET_IDCODEAntonio Borneo1-0/+4
When the connection with target is lost on the physical JTAG/SWD link (either wire disconnected or DAP/TAP in reset), STLINK fail to connect and returns error STLINK_JTAG_GET_IDCODE_ERROR. Add it in the list of known errors. Change-Id: Iabd6e6892111726f614345497d9286554bfe4ac0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4982 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2019-03-07stlink: handle error bad-APAntonio Borneo1-0/+5
The new firmwares for ST-Link support handling multiple AP, but are (actually) limited to the AP number in range [0..8]. Any tentative to operate on AP number higher than 8 returns an error "bad AP". Add the error code and the related message. Change-Id: I78a98b2612d10e580d03fc43ed9f2b09619d39d8 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4981 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2019-03-06stlink: remove unused assignmentAntonio Borneo1-1/+1
Fix a warning identified by clang 7.0.1: stlink_usb.c:1092:3: warning: Value stored to 'p' is never read p += sprintf(p, "S%d", swim); ^ ~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: Ic9da57e19ceecb0e3d65d3ea3412a05e1c2c779a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4945 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-03-05src/jtag/drivers/ftdi: fix swd pin comment and linksDiego Herranz1-4/+4
- TDI/DO is not pin 2 and in fact, we don't even need to mention which pin number it is. "TDI/DO pin" is descriptive enough. - FT2232D link didn't work anymore. It could have been updated to the current working FT2232D link but changed to link the FT2232H instead which is the latest generation and the most commonly used these days. - Taking advantage of the change, link to the MPSSE document updated. It still worked but through a redirection, so updated just in case the redirection stops working. Change-Id: Ia7d01bbcac2158026831edb010a6b50f58351e42 Signed-off-by: Diego Herranz <diegoherranz@diegoherranz.com> Reviewed-on: http://openocd.zylin.com/4908 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2019-02-25jtag: drivers: cmsis-dap: correct vendor request codePaul Fertser1-2/+2
While at it, change the macro name to make it obvious it's a string, not some numeric ID. This also matches ARM code that's using Change-Id: Id35ba5b95cef0ac77657c40985b24c1ae2720748 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/3855 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-02-19ftdi: use "adapter usb location" instead of ftdi_location commandOleksij Rempel1-27/+2
Use unified "adapter usb location" instead of driver specific command. Change-Id: I568a76b87d09cea0f40f1580cf81f7c51402f6f1 Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-on: http://openocd.zylin.com/4771 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2019-02-07jlink: Use correct SWD buffer sizeMarc Schink1-1/+1
Currently, the SWD buffer size is adjusted corresponding to the free device memory. However, the adjusted size is not used. This fixes SWD operations on devices with small device memory, such as EFM32PG12 Pearl Gecko STK. It should also fix #184. Change-Id: I2ec5cf25c62f18bd9e99a2f4aa1aa8d85ed0821b Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/4878 Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Tested-by: jenkins
2019-02-07drivers/bitbang: remove unused extern declaration of jtag_interfaceAntonio Borneo1-3/+0
After commit a6c4eb03455f ("swd: Remove DAP from parameter list") the global variable jtag_interface is not referenced in the driver. Remove the extern declaration. Change-Id: I72018a59c9cecaa52d9a49ec0d7816ac0e656314 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4874 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2019-02-07command: fix the mode for command "jtag configure"Antonio Borneo2-2/+2
Before commit 877cec20dca6e78f9f029f0f173879cda101a6c2 ("command: check command mode for native jim commands") all the jim commands were erroneously treated as they had mode COMMAND_ANY. The commit above fixes the code in order to check the mode and permit running the commands only if the mode is respected. Those jim commands that have incorrect mode were not detected nor fixes because the wrong mode was masked by the missing mode check. After the commit above, the wrong mode triggers error in several existing configuration scripts. A complete list of commands that now does not run anymore as CONFIG_ANY is reported in ticket 225, but most of them have the mode set correctly. At least two instances of command "jtag configure" have the wrong mode. Fix the mode to CONFIG_ANY for command "jtag configure" in files src/jtag/aice/aice_transport.c and src/jtag/tcl.c Change-Id: I3f96c5fd24d7d463712cbaf1295284fe0dc56b23 Ticket: https://sourceforge.net/p/openocd/tickets/225/ Reported-by: Bill Paul <wpaul@users.sourceforge.net> Fixes: 877cec20dca6 ("command: check command mode for native jim commands") Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4886 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2019-02-07drivers/imx_gpio: fix polarity of srst and trstAntonio Borneo1-2/+2
The comment above the function is correct, but the code set the GPIO with wrong (reversed) polarity. Change-Id: Ifd09688150d3d2018af73521e0da3926bb1b7f84 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4847 Tested-by: jenkins Reviewed-by: Grzegorz Kostka <kostka.grzegorz@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-02-07jtag: drivers: provide initial support for usb path filteringOleksij Rempel5-1/+185
With this patch drivers will be able to use usb path filtering. The path format is identical to the format provided by linux kernel: bus-port.port.... With this format it should be easier just to copy and paste path found in dmesg. Change-Id: I8bafa6fcb7a66ff68cc961a376f97f4f3dee35aa Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-on: http://openocd.zylin.com/4580 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2019-01-23jtag: cmsis-dap: use macro SWJ_PIN_SRST in place of magic valueAntonio Borneo1-1/+1
While connecting under reset, use the already defined macro SWJ_PIN_SRST to assert the srst pin. Change-Id: Icebed462c0fe8f8c15f6522dc56625aa580b8858 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4846 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-01-23arm_adi_v5: fix and update sequences to spec IHI 0031EAntonio Borneo1-16/+110
Fix the SWD line reset sequence accordingly to Arm specification IHI 0031E that requires at least 2 idle clocks after the 50 clocks with SWDIO high. Fix the value of the activation code in the (currently unused) sequence dormant-to-SWD. Make each sequence's length multiple of 8, so it is compatible with adapters that have such limitation (e.g. buspirate) and try to split and comment each part of the sequence (when possible keep each part byte aligned, inspired from commit 3ef9beb52cd0). This slightly increases the sequence length but does not impact run-time performance because these are rarely used sequences. Add the missing sequence dormant-to-JTAG and JTAG-to-dormant, not used yet. On devices that implements the dormant state, IHI 0031E deprecates the direct switching between SWD and JTAG, and recommends using a transition through dormant. This is not implemented. Change-Id: Iad18c0e736cfd9366be175d22658d664b0c61eab Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4851 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2019-01-14drivers/sysfsgpio: fix usage messagesAntonio Borneo1-2/+10
The notation "(tck tms tdi tdo)* " is incorrect, because it means the quadruple of gpio can be repeated on the command-line. The correct syntax of the command requires instead to provide either all the four gpio numbers (in order to set the values) or to pass an empty command-line (to dump the values previously set). Change the .usage field to "[tck tms tdi tdo]". Change similarly the corresponding .usage field for SWD command. Add the .usage field for the commands that individually set each gpio. Change-Id: If5b3c618097b71dfe7fcf988fb3c1499ae03a6d5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4833 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-01-08stlink_usb: Submit multiple USB URBs at once to improve performanceAustin Phillips1-2/+201
Commands to stlink devices are typically comprised of multiple transactions with each transaction completing before moving to the next. This change allows for multiple USB transactions to be issued at once followed by a check that all transactions completed successfully. This improves performance on some machines where there is a large turn-around time between USB transfers such as is seen on some virtual machines. This change is only supported when compiled with libusb1 as libusb1 supports and asynchronous interface. Multi-transaction queueing introduced in this change paves the way for improving speed of other transactions in the future such as memory and register reads where multiple USB transactions in succession are required to complete a command. Multiple USB transactions can be submitted at once using jtag_libusb_bulk_transfer_n function. Change-Id: I924e049217a789ef445b14e00aa1983576970fbf Signed-off-by: Austin Phillips <austin_phillips@hotmail.com> Reviewed-on: http://openocd.zylin.com/4484 Tested-by: jenkins Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2019-01-08libusb: add debug message on adapter not found due to wrong serialAntonio Borneo2-0/+14
When few adapters of the same type are in use, the serial string is the way to select the right one. Currently a serial string that does not match any of the connected adapters will just fail the open, without specific information to track the issue. Add a specific message to highlight that the open failure is caused by a serial mismatch. Change-Id: I5cb77f1045cc746e532d395b2e5ced40a23ab638 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4701 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2019-01-08jtag/drivers/usb_common: return oocd error valuesAntonio Borneo1-4/+7
Where possible, keep the same style for returning error. Change-Id: I3a04220c0b9f129a36e9fe83038b7c19dd57fe61 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4699 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2019-01-08libusb0: return oocd error valuesAntonio Borneo1-3/+3
Commit d1b74376336814266236054f925a9964b87dd8a5 fixes libusb1 to return OpenOCD error values instead of negative errors in Linux kernel's style. The same fix should be applied to libusb0 too. Fix return value of libusb0 to uniform it to OpenOCD style. Change-Id: I68478c29c91c6be720074f58c432fe51477e03ed Fixes: d1b743763368 ("libusb: return oocd error values") Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4698 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2019-01-08drivers: xds110: Add support for XDS110 stand-alone probeEdward Fewell1-1/+84
The XDS110 stand-alone version has the ability to supply voltage to the target board via it's AUX FUNCTIONS port. Added command to enable setting the voltage on the XDS110 stand-alone. Change-Id: I2f21c4a3d15ed99e649f3a83973c5e724c4bfeb6 Signed-off-by: Edward Fewell <efewell@ti.com> Reviewed-on: http://openocd.zylin.com/4793 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-11libusb0: add compatibility define for transfer type bulkAntonio Borneo2-4/+2
For compatibility with libusb1, define LIBUSB_TRANSFER_TYPE_BULK in libusb0. Remove the #ifdef HAVE_LIBUSB1 in jtag/driver/aice This also fixes a compile error in jtag/drivers/openjtag with libusb0. Change-Id: I827b77eac10216759eb31aab461b2b63cabaf195 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4700 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2018-12-11jtag: sysfsgpio: clean up swd gpiosReto Schneider1-0/+2
All SWD GPIOs should be un-exported when no longer needed, not just srst. Change-Id: I998377afe43b72446cab3da2d4406fc2912ff8c3 Signed-off-by: Reto Schneider <code@reto-schneider.ch> Reviewed-on: http://openocd.zylin.com/4784 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2018-12-11jtag: cmsis-dap: developer tool - enter a command by hex nuberTomas Vanek1-0/+31
Handy to test vendor commands in a CMSIS-DAP adapter. Change-Id: Ieeaa276edf770b1a3076a186e9056b4e5180362a Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/3103 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: add support for STLINK-V3Antonio Borneo1-24/+201
Extend the driver to include the minimal functionality to support the HLA model. Due to the small change in the name (ST-LINK/V2 => STLINK-V3), fix the existing names in the comments in udev rules. Change-Id: Ied33e38063a6da81d9bf249ed195444d7cdf4f03 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4717 Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: fix printed version for new STM8 nucleo boardAntonio Borneo1-4/+11
The ST-LINK/V2.1 embedded in the new nucleo boards for STM8 does not follow the normal versioning rules, and puts mass-storage and swim version in the field normally used respectively for jtag and mass-storage version. Apply the check suggested by STMicroelectronics to discriminate the two cases and print the correct version. Change-Id: I0dd1da11013be3f1e56084489e28cfba98bb07af Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4716 Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: dump version in the same format of ST firmware upgrade toolAntonio Borneo1-12/+41
This should help comparing the versions before deciding for a firmware update. Change-Id: I7012a60587587539b2fd1a5f9c3b1ce72877793f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4715 Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: add STLINK_F_HAS_GETLASTRWSTATUS2Antonio Borneo1-2/+15
Starting from stlink V2J15 the API STLINK_DEBUG_APIV2_GETLASTRWSTATUS is obsoleted and replaced by the new API STLINK_DEBUG_APIV2_GETLASTRWSTATUS2. Manage the two cases to be prepared for an eventual future removal of the obsolete API. Change-Id: Ic4498a652865b2eb6148825138c2f6855a06ba47 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4714 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: remove reset pulse when entering in JTAGAntonio Borneo1-5/+5
Until version J14 the behaviour of ST-Link was to send a reset pulse to the target when the debug connection is started in JTAG mode. No reset pulse is sent, instead, in SWD mode. Version J15 introduces a new parameter to avoid the reset pulse in JTAG mode, aligning the behaviour with SWD. This reset from the ST-Link, if propagated to the target, prevents attaching a running target. Actually this reset pulse is very short (few microsecond) and can be easily filtered out by an on-board capacitor, usually present on the reset wire (mainly to filter the bounces of the reset button). Moreover, most of the use cases for ST-Link are with SWD (not with JTAG) and this has probably further masked this JTAG specific behaviour. OpenOCD can tolerate it but requires the flag "connect_assert_srst" to the command "reset_config", but the flag is not present in any configurations in folder tcl. This enforces the guess it was not noticed due to on-board capacitors or missing connection of reset pin or ST-Link only used in SWD; so it's safe applying this patch. Change the default behaviour to avoid reset in JTAG at connection. There is no need to manage the ST-Link version here, since every parameter that is not recognized by older ST-Link is treated as "connect in JTAG with reset pulse", keeping backward compatibility. Change-Id: Idc97a1457279e3970fd0839cadbff22d9b0302d4 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4713 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: simplify api version handlingAntonio Borneo1-33/+23
The API version is hardcoded in the STLINK device and depends on the specific firmware version. There is no way to switch between different API. Thus, it make no sense to keep in two separate variables the current and the max API supported because they are always equal to "the only" API supported by the specific STLINK. Collapse h->version.jtag_api_max and h->jtag_api in a single variable h->version.jtag_api Remove an extra print of api version; this is already advertised while printing the STLINK version. Change-Id: I0519694a34748e5a0aa330932c1256080a6d5f20 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4712 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: add STLINK_F_HAS_MEM_16BITAntonio Borneo1-10/+9
Change-Id: I51a160a105342ddbab99c4182d89650a436f5945 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4711 Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: add STLINK_F_HAS_JTAG_SET_FREQAntonio Borneo1-6/+9
Change-Id: I591543f218c6bb30aaeb6321ba8a9425a2b5b6e2 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4710 Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: add STLINK_F_HAS_SWD_SET_FREQAntonio Borneo1-6/+9
Change-Id: Ibba786c7e18bf15a04b85a2071c79f631a252ccf Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4709 Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: add STLINK_F_HAS_TARGET_VOLTAntonio Borneo1-2/+4
Use an alias to STLINK_F_HAS_TRACE, both are added in the same version Change-Id: Iabf2fdac407f5c4737c3da942323d60ee50c3470 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4708 Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: add STLINK_F_HAS_TRACEAntonio Borneo1-7/+10
Fix the condition for ST-Link/V1; it does not support trace. Trace is added on ST-Link/V2 and ST-Link/V2.1 only. Change-Id: I17416edd05a2c8ece605560b7533edac4f982cfc Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4707 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: simplify maintenance of version and featuresAntonio Borneo1-6/+28
The number of stlink firmware version is growing, each carrying new features. Today's code has several check distributed here and there and it's already hard to track them and verify the correctness. The introduction of STLINK-V3 will make the situation much worst, and the code much less readable. Add a "flags" bitmask in the struct stlink_usb_version to allow setting individual bits for each feature available or for specific quirks and workarounds. This patch does not implement setting nor testing "flags"; it would be introduced in following patches, one bit at a time. Change-Id: I09d78202646a6c8330731f8aa96dc9d295fa5655 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4706 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: check for SWD supportAntonio Borneo1-0/+3
The old ST-Link/V1 can either run an obsolete firmware with API_V1 or a more recent firmware (from V1J11 to last V1J13) with API_V2. SWD is only provided by the latter API. Return error is SWD is selected on adapters that does not support it. Change-Id: Iac4ba54d191ba80fb445a7cd3d8c2621dc7a4846 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4705 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: add support for 16 bit memory read/writeLaurent LEMELE1-20/+121
Recent stlink version V2J26 introduces support for 16 bit memory read/write. Add the new API and modify the wrappers stlink_usb_{read|write}_mem For older version of stlink keep the same behavior as in current code. While there, fix some minor typo in comments inside the wrappers. This fixes ticket #204 ("st-link can't flash stm32f2x based flash without target algorithms"). Change-Id: Id7d404e588f10a4b0f8a93d7ca44cef8e4c49b4f Author: Laurent LEMELE <laurent.lemele@st.com> Rebased-by: Antonio Borneo <borneo.antonio@gmail.com> Ticket: https://sourceforge.net/p/openocd/tickets/204/ Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4704 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2018-12-06stlink: add JTAG speed selectionLaurent LEMELE1-40/+144
ST-Link uses two separate API for setting the interface speed in SWD and JTAG. Add the missing API for JTAG and run the proper API depending on the selected mode. Change-Id: I71e955e23c1d82c2ea1c8bfade7612c5a0377a74 Author: Laurent LEMELE <laurent.lemele@st.com> Rebased-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4703 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-12-06stlink: add usb pid for v2.1 without mass storage deviceAntonio Borneo1-0/+2
New version of ST-Link/V2.1 without mass storage device. From debug point of view, it is compatible with existing ST-Link/V2.1 It uses a new USB PID because the USB endpoints and interfaces are different from usual ST-Link/V2.1 Add the new PID in the driver, in the tcl interface script and in the udev configuration script. Change-Id: Id2e1b5a5d0347c5d951a86a9cdb76be52cfd4ea3 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4702 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>