aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis de Arquer <luis.dearquer@inertim.com>2021-03-24 17:12:14 +0100
committerAntonio Borneo <borneo.antonio@gmail.com>2021-05-01 14:21:38 +0100
commitb44948985f080df55adeb9377596432fff3c50d6 (patch)
tree0e86eeccc0ca683ce84d71cf008c7720e8418955
parentd10141ef07644fc6a39211d60e811a868d91c575 (diff)
downloadriscv-openocd-b44948985f080df55adeb9377596432fff3c50d6.zip
riscv-openocd-b44948985f080df55adeb9377596432fff3c50d6.tar.gz
riscv-openocd-b44948985f080df55adeb9377596432fff3c50d6.tar.bz2
drivers/ftdi: drscan: Skip DR-PAUSE when endstate == IDLE
Currently, all drscan commands will cycle through DR-PAUSE before reaching TAP-IDLE. This patch provides a different path on FTDI driver. This change is required for the ST On Chip Emulator (OnCE), to avoid re-enabling the OnCE tap after every DRSCAN. This is because the OnCE TAP (see ST Application Note AN4035) gets disabled if DR-PAUSE is entered before DR-UPDATE. With this commit, the current path: DR-SHIFT -> DR-EXIT1 -> DR-PAUSE -> DR-EXIT2 -> DR-UPDATE -> IDLE is changed to: DR-SHIFT -> DR-EXIT1 -> DR-UPDATE -> IDLE only if IDLE is the endstate (which is the driver default). Before this patch, once the SHIFT sequence is complete, the driver would normally move to the nearest stable state, which is DR-PAUSE, by clocking out a '10' binary sequence. Then it would follow the path provided by tap_get_tms_path() to reach endstate. It is done this way because tap_get_tms_path() only supports stable states. After this patch, the strategy is mostly the same, with the exception that, if TAP_IDLE is the endstate, a '110' binary sequence is output after completing the SHIFT sequence. This takes the TAP directly to IDLE, with no further action required. A scheme of the DR chain is shown below. A * character is used to mark the stable states. ---------------------------------------------------------------------- | | 0 v 1 0 0 1 0 1 1 | IDLE* -> SEL-DR -> CAPTURE -> SHIFT* -> EXIT1 -> PAUSE* -> EXIT2 -> UPDATE | ^ 1 | | ----------------------------- Change-Id: Ib413e5c4c0bbf75dae0b4672119bae4ef03d0258 Signed-off-by: Luis de Arquer <luis.dearquer@inertim.com> Reviewed-on: http://openocd.zylin.com/6123 Tested-by: jenkins Reviewed-by: Christopher Head <chead@zaber.com> Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
-rw-r--r--src/jtag/drivers/ftdi.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c
index 9e47d3c..8c83d45 100644
--- a/src/jtag/drivers/ftdi.c
+++ b/src/jtag/drivers/ftdi.c
@@ -482,7 +482,11 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
uint8_t last_bit = 0;
if (field->out_value)
bit_copy(&last_bit, 0, field->out_value, field->num_bits - 1, 1);
- uint8_t tms_bits = 0x01;
+
+ /* If endstate is TAP_IDLE, clock out 1-1-0 (->EXIT1 ->UPDATE ->IDLE)
+ * Otherwise, clock out 1-0 (->EXIT1 ->PAUSE)
+ */
+ uint8_t tms_bits = 0x03;
mpsse_clock_tms_cs(mpsse_ctx,
&tms_bits,
0,
@@ -492,13 +496,24 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
last_bit,
ftdi_jtag_mode);
tap_set_state(tap_state_transition(tap_get_state(), 1));
- mpsse_clock_tms_cs_out(mpsse_ctx,
- &tms_bits,
- 1,
- 1,
- last_bit,
- ftdi_jtag_mode);
- tap_set_state(tap_state_transition(tap_get_state(), 0));
+ if (tap_get_end_state() == TAP_IDLE) {
+ mpsse_clock_tms_cs_out(mpsse_ctx,
+ &tms_bits,
+ 1,
+ 2,
+ last_bit,
+ ftdi_jtag_mode);
+ tap_set_state(tap_state_transition(tap_get_state(), 1));
+ tap_set_state(tap_state_transition(tap_get_state(), 0));
+ } else {
+ mpsse_clock_tms_cs_out(mpsse_ctx,
+ &tms_bits,
+ 2,
+ 1,
+ last_bit,
+ ftdi_jtag_mode);
+ tap_set_state(tap_state_transition(tap_get_state(), 0));
+ }
} else
mpsse_clock_data(mpsse_ctx,
field->out_value,