This is an automated email from Gerrit.

Jan Matyas (mat...@codasip.com) just uploaded a new patch set to Gerrit, which 
you can find at http://openocd.zylin.com/5151

-- gerrit

commit bc6193a08f6ce20dc2a07424352adf6a7148ebe1
Author: Jan Matyas <mat...@codasip.com>
Date:   Thu May 2 09:46:48 2019 +0200

    jtag_vpi: fixed state transitions in "runtest" and "stableclocks"
    
    In jtag_vpi_runtest():
    - Prevented the TAP state from going out of sync (NO_TAP_SHIFT must be 
used).
    
    In jtag_vpi_stableclocks():
    - The TMS line needs to be set properly based on the current state
    (TMS=1 in TAP_RESET state vs. TMS=0 in other cases).
    
    Change-Id: Id49622ba83015f97b61b6a896edde4448f1fbdc6
    Signed-off-by: Jan Matyas <mat...@codasip.com>

diff --git a/src/jtag/drivers/jtag_vpi.c b/src/jtag/drivers/jtag_vpi.c
index 35c7031..59423ad 100644
--- a/src/jtag/drivers/jtag_vpi.c
+++ b/src/jtag/drivers/jtag_vpi.c
@@ -319,7 +319,9 @@ static int jtag_vpi_runtest(int cycles, tap_state_t state)
        if (retval != ERROR_OK)
                return retval;
 
-       retval = jtag_vpi_queue_tdi(NULL, cycles, TAP_SHIFT);
+       /* No TAP shift here. Any state change will be handled below by the 
"state move"
+          operation, if needed. */
+       retval = jtag_vpi_queue_tdi(NULL, cycles, NO_TAP_SHIFT);
        if (retval != ERROR_OK)
                return retval;
 
@@ -328,7 +330,27 @@ static int jtag_vpi_runtest(int cycles, tap_state_t state)
 
 static int jtag_vpi_stableclocks(int cycles)
 {
-       return jtag_vpi_queue_tdi(NULL, cycles, TAP_SHIFT);
+       uint8_t tms_bits[4];
+       int cycles_remain = cycles;
+       int nb_bits;
+       int retval;
+       const int CYCLES_ONE_BATCH = 32;
+
+       assert(cycles >= 0);
+
+       /* use TMS=1 in TAP RESET state, TMS=0 in all other stable states */
+       memset(&tms_bits, (tap_get_state() == TAP_RESET) ? 0xff : 0x00, 4);
+
+       /* send the TMS bits */
+       while (cycles_remain > 0) {
+               nb_bits = (cycles_remain < CYCLES_ONE_BATCH) ? cycles_remain : 
CYCLES_ONE_BATCH;
+               retval = jtag_vpi_tms_seq(tms_bits, nb_bits);
+               if (retval != ERROR_OK)
+                       return retval;
+               cycles_remain -= nb_bits;
+       }
+
+       return ERROR_OK;
 }
 
 static int jtag_vpi_execute_queue(void)

-- 


_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to