Skip to content

Commit

Permalink
Add Jtag to Dormant sequence in case the target has both jtag and swd…
Browse files Browse the repository at this point in the history
… and is jtag by default
  • Loading branch information
mean authored and dragonmux committed Oct 24, 2024
1 parent 64a3667 commit 2de7560
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/target/adiv5_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
#define ADIV5_SWD_TO_JTAG_SELECT_SEQUENCE 0xe73cU /* 16 bits, LSB (MSB: 0x3ce7) */
#define ADIV5_JTAG_TO_SWD_SELECT_SEQUENCE 0xe79eU /* 16 bits, LSB (MSB: 0x79e7) */

/* ADIv5 JTAG to dormant sequence */
#define ADIV5_JTAG_TO_DORMANT_SEQUENCE0 0x1fU /* 5 bits */
#define ADIV5_JTAG_TO_DORMANT_SEQUENCE1 0x33bbbbbaU /* 31 bits, LSB (MSB : 0x2eeeeee6) */
#define ADIV5_JTAG_TO_DORMANT_SEQUENCE2 0xffU /* 8 bits */

/*
* ADIv5 Selection Alert sequence
* This sequence is sent MSB first and can be represented as either:
Expand Down
12 changes: 10 additions & 2 deletions src/target/adiv5_swd.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,19 @@ static void dormant_to_swd_sequence(void)
* §5.3.4 Switching out of Dormant state
*/

DEBUG_INFO("Switching out of dormant state into SWD\n");

/* Send at least 8 SWCLKTCK cycles with SWDIOTMS HIGH */
swd_line_reset_sequence(false);

/*
* If the target is both JTAG and SWD with JTAG as default, switch JTAG->DS first.
* See B5.3.2
*/
DEBUG_INFO("Switching from JTAG do dormant\n");
swd_proc.seq_out(ADIV5_JTAG_TO_DORMANT_SEQUENCE0, 5U);
swd_proc.seq_out(ADIV5_JTAG_TO_DORMANT_SEQUENCE1, 31U);
swd_proc.seq_out(ADIV5_JTAG_TO_DORMANT_SEQUENCE2, 8U);
/* Send the 128-bit Selection Alert sequence on SWDIOTMS */
DEBUG_INFO("Switching out of dormant state into SWD\n");
swd_proc.seq_out(ADIV5_SELECTION_ALERT_SEQUENCE_0, 32U);
swd_proc.seq_out(ADIV5_SELECTION_ALERT_SEQUENCE_1, 32U);
swd_proc.seq_out(ADIV5_SELECTION_ALERT_SEQUENCE_2, 32U);
Expand Down

0 comments on commit 2de7560

Please sign in to comment.