From: OpenOCD-Gerrit <ope...@us...> - 2021-12-11 17:40:27
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 68ec9d2175f3bad53cd7f1a259e54420047321d6 (commit) from 8a448573fb2804a9abe3e0922648dbbf99224aa9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 68ec9d2175f3bad53cd7f1a259e54420047321d6 Author: Antonio Borneo <bor...@gm...> Date: Thu Nov 11 23:28:33 2021 +0100 adi_v5_swd: add jtag-to-swd through dormant ARM IHI 0031A does not support SWJ-DP, so no switch between JTAG and SWD is considered. ARM IHI 0031B is not publicly available and it's reported as "Confidential Beta" in the history list in following doc versions. From ARM IHI 0031C the direct switch between JTAG and SWD is already deprecated in favor of passing through dormant mode. With no access to IHI 0031B we haven't info if any device strictly requires the direct switch. OpenOCD implements only the deprecated direct switch, so changing it could cause regression on devices that do not implement dormant mode. Plus, not all the adapters support dormant mode. Nevertheless there are already target devices that only allow entering in SWD by passing through dormant. Let the code try both method, alternating one tentative with the deprecated legacy direct switch, then another tentative passing through dormant, and repeat till timeout. This would work on any device that don't support dormant, on new devices that require switch through dormant and will work with adapters that don't support dormant. Change-Id: Ib8619635277d497872079a33fa4e38be9beb84a0 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/6695 Tested-by: jenkins diff --git a/src/target/adi_v5_swd.c b/src/target/adi_v5_swd.c index c23cee157..683504243 100644 --- a/src/target/adi_v5_swd.c +++ b/src/target/adi_v5_swd.c @@ -315,7 +315,12 @@ static int swd_connect_single(struct adiv5_dap *dap) int64_t timeout = timeval_ms() + 500; do { - swd_send_sequence(dap, JTAG_TO_SWD); + if (dap->switch_through_dormant) { + swd_send_sequence(dap, JTAG_TO_DORMANT); + swd_send_sequence(dap, DORMANT_TO_SWD); + } else { + swd_send_sequence(dap, JTAG_TO_SWD); + } /* Clear link state, including the SELECT cache. */ dap->do_reconnect = false; @@ -330,6 +335,7 @@ static int swd_connect_single(struct adiv5_dap *dap) alive_sleep(1); + dap->switch_through_dormant = !dap->switch_through_dormant; } while (timeval_ms() < timeout); if (retval != ERROR_OK) { @@ -568,7 +574,12 @@ static void swd_quit(struct adiv5_dap *dap) * swd->switch_seq(DORMANT_TO_JTAG); */ } else { - swd->switch_seq(SWD_TO_JTAG); + if (dap->switch_through_dormant) { + swd->switch_seq(SWD_TO_DORMANT); + swd->switch_seq(DORMANT_TO_JTAG); + } else { + swd->switch_seq(SWD_TO_JTAG); + } } /* flush the queue to shift out the sequence before exit */ diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index 758cfa096..5c598f16e 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -342,6 +342,11 @@ struct adiv5_dap { bool multidrop_dp_id_valid; /** TINSTANCE field of multidrop_targetsel has been configured */ bool multidrop_instance_id_valid; + + /** + * Record if enter in SWD required passing through DORMANT + */ + bool switch_through_dormant; }; /** ----------------------------------------------------------------------- Summary of changes: src/target/adi_v5_swd.c | 15 +++++++++++++-- src/target/arm_adi_v5.h | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |