aboutsummaryrefslogtreecommitdiff
path: root/src/jtag/swd.h
AgeCommit message (Collapse)AuthorFilesLines
2022-07-23openocd: src/jtag: replace the GPL-2.0-or-later license tagAntonio Borneo1-13/+2
Replace the FSF boilerplate with the SPDX tag. The SPDX tag on files *.c is incorrect, as it should use the C99 single line comment using '//'. But current checkpatch doesn't allow C99 comments, so keep using standard C comments, by now. Change-Id: Ie873d12bb0fb838d0d6252e6b9ca3c2118853e9a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7069 Tested-by: jenkins
2021-11-20drivers/swd: add support for SWD multidropTomas Vanek1-0/+41
According to ARM IHI0031C+ chapter 2.3.11 "TARGETSEL, Target Selection register" multidrop capable DPv2 must not drive SWDIO line during the response phase of a write to TARGETSEL register. Introduce helper functions swd_cmd_returns_ack() and swd_ack_to_error_code() to centralize these tests from all drivers to one place. Introduce distinct error codes for SWD protocol. Partly inspired by Graham Sanderson's http://review.openocd.org/4935 Change-Id: Ie5f9edb22e066a933a534bf2b29e7e1d3087dad1 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6699 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2021-07-02jtag/swd: rename CamelCase macrosAntonio Borneo1-4/+4
Change-Id: I4bce678b67d3d2347e88da9507820837697b5aa7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6302 Tested-by: jenkins
2020-01-14swd: get rid of jtag queue to assert/deassert srstAntonio Borneo1-1/+0
The transport SWD uses the JTAG queue to assert/deassert the system reset srst. This is the major inconsistency that has to be removed to properly split JTAG and SWD. Introduce a new driver API, reset(), to controls both the signals trst and srst in the driver, skipping the JTAG queue. Put the new API in struct jtag_interface, even if in this patch it's used for SWD only; the goal is to get it reused by the other transports. Add the implementation of the API in all the drivers that implement SWD. Such implementation is almost the same of the old code in JTAG queue. Create a wrapper adapter_system_reset() to use the new API and remove the SWD specific swd_add_reset(). In the wrapper replace jtag_add_sleep() with jtag_sleep(), because the former uses the JTAG queue too. Rename the old jtag_add_reset() as legacy_jtag_add_reset() with the target to remove it when all drivers would be ported to the new reset API. Create a new jtag_add_reset() that calls the legacy function for drivers still on the old reset API. Use the new API also on JTAG transport for the drivers that can support both SWD and JTAG. For the moment, do not modify the implementation of JTAG-only drivers, which will continue using the usual method. This should be cleaned-up in future commits. Change-Id: I32331c88313f6059b25e12c6bb0156aebc1c074f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4895 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-02arm_adi_v5: add API send_sequence() and use itAntonio Borneo1-8/+0
The method to send an arbitrary sequence to DAP depends on the transport and is thus different on JTAG and SWD. This is already coded in dap_to_jtag() and dap_to_swd(). Add a new API send_sequence() in struct dap_ops. Add the implementations of send_sequence() in adi_v5_jtag.c and adi_v5_swd.c Rewrite dap_to_jtag() and dap_to_swd() using the new API. Move the enum swd_special_seq in arm_adi_v5.h to solve a circular dependencies among swd.h and arm_adi_v5.h Change-Id: I9db13a00f129761eab283783c094cfff2dd92610 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4902 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-06-06swd: remove unused API frequency()Antonio Borneo1-18/+0
The specific SWD API to change/query the adapter speed is never called because the equivalent JTAG API is used in place of it. In the restructure of struct jtag_interface, the JTAG API is promoted as global adapter API, thus a specific SWD one is not anymore required. Change-Id: I1e810d255b4dfcd5791b4fac8ae1260c31a057fd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4891 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>
2018-03-20transport: add transport_is_hla()Tomas Vanek1-2/+0
and move declaration of all transport_is_xxx() functions to transport.h Change-Id: Ib229115b5017507b49655bc43b517ab6fb32f7a6 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4469 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2016-05-24Make #include guard naming consistentMarc Schink1-3/+3
Change-Id: Ie13e8af0bb74ed290f811dcad64ad06c9d8cb4fa Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/2956 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2016-05-24Remove FSF address from GPL noticesMarc Schink1-3/+1
Also make GPL notices consistent according to: https://www.gnu.org/licenses/gpl-howto.html Change-Id: I84c9df40a774958a7ed91460c5d931cfab9f45ba Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/3488 Tested-by: jenkins Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com> Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-12-29swd: Remove DAP from parameter listAndreas Fritiofson1-11/+10
Making the SWD driver aware of the DAP that controls it is a layering violation. The only usage for the DAP pointer is to store the number of idle cycles the AP may need to avoid WAITs. Replace the DAP pointer with a cycle count hint instead to avoid future misuse. Change-Id: I3e64e11a43ba2396bd646a4cf8f9bc331805d802 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/3141 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2015-03-25drivers/cmsis-dap: port to common SWD frameworkPaul Fertser1-1/+0
Valgrind-tested. Comparison of flashing performance on an FRDM-KL25Z board running mbed CMSIS-DAP variant, 5MHz clock, old driver: wrote 28096 bytes from file demo.elf in 26.833590s (1.023 KiB/s) verified 27264 bytes in 1.754972s (15.171 KiB/s) this implementation: wrote 28096 bytes from file demo.elf in 3.691939s (7.432 KiB/s) verified 27264 bytes in 0.598987s (44.450 KiB/s) Also tested "Keil ULINK-ME CMSIS-DAP" with an STM32F100 target, 5MHz clock, results reading from flash, old driver: dumped 131072 bytes in 98.445305s (1.300 KiB/s) this implementation: dumped 131072 bytes in 8.242686s (15.529 KiB/s) Change-Id: Ic64d3124b1d6cd9dd1016445bb627c71e189ae95 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/2356 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-06-28swd: Add frequency setting and special/switching sequences to the APIAndreas Fritiofson1-0/+103
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-28swd: Remove support for turnaround periods other than 1Andreas Fritiofson1-5/+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-28swd: Fix park bit polarity according to ADIv5.1 SupplementAndreas Fritiofson1-1/+1
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-28swd: Convert API to asynchronousAndreas Fritiofson1-36/+34
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-28swd: Improve parity calculation and move it to types.hAndreas Fritiofson1-12/+1
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-28adi_v5: Remove unused features of the DAP and SWD interfacesAndreas Fritiofson1-13/+1
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-28adi_v5_swd: Improve SWD supportFatih Aşıcı1-2/+2
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-01-09cmsis-dap: add initial cmsis-dap supportSpencer Oliver1-5/+12
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
2013-06-05update files to correct FSF addressSpencer Oliver1-1/+1
Change-Id: I429f7fd51f77b0e7c86d7a7f110ca31afd76c173 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/1426 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2012-04-10topic: add reset functions for SWDSimon Qian1-0/+8
Add swd_init_reset and swd_add_reset. Add adapter_assert_reset and adapter_deassert_reset, and call them instead of JTAG reset functions. Change-Id: Ib2551c6fbb45513e0ae0dc331cfe3ee3f922298a Signed-off-by: Simon Qian <simonqian.openocd@gmail.com> Reviewed-on: http://openocd.zylin.com/526 Tested-by: jenkins Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2012-02-06build: cleanup src/jtag directorySpencer Oliver1-6/+23
Change-Id: I7caf57ca3d9dfbe152504472a6bb26c2a28b92e8 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/423 Tested-by: jenkins
2010-12-24initial SWD transport (SWD infrastructure #2)David Brownell1-0/+114
This piggy backs on JTAG so it's not yet pretty, but that seems unavoidable so far given today's OpenOCD internals. SWD init and data transfer are unfinished and untested, but that should cause no regressions, and will be addressed by the time drivers start using this infrastructure. Checking in whould get the code working better sooner, and turn up any structural/architectural issues while they're easier to fix. The debug adapter drivers will provide simple SWD driver structs with methods that kick in as needed (instead of JTAG). So far just one adapter driver has been updated (not yet ready to use or circulate). The biggest issues are probably - fault handling, where the ARM Debug Interface V5 pipelining needs work in both JTAG and SWD modes and - missing rewrite of block I/O code to work on both of our Cortex-ready transports (Current code is hard-wired to JTAG); relates also to the pipelining issue. - omitted support to activate/deactivate SWO/SWV trace (this is technically trivial, but configuring what to trace is NOT. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> ---- doc/openocd.texi | 17 ++ src/jtag/core.c | 3 src/jtag/interface.h | 4 src/jtag/jtag.h | 2 src/jtag/swd.h | 114 +++++++++++++++++++ src/jtag/tcl.c | 2 src/target/adi_v5_swd.c | 281 ++++++++++++++++++++++++++++++++++++++++++++++-- src/target/arm_adi_v5.c | 8 + src/target/arm_adi_v5.h | 3 9 files changed, 425 insertions(+), 9 deletions(-)