From 2b73796a5c0f341129d68d59bc19947c132dd8fe Mon Sep 17 00:00:00 2001 From: Greg Savin <43152568+SiFiveGregS@users.noreply.github.com> Date: Thu, 28 Mar 2019 09:48:22 -0700 Subject: Adjusted epilogue width. --- src/jtag/drivers/ftdi.c | 80 +++++++++++++++++-------------- tcl/board/sifive-e31arty-onboard-ftdi.cfg | 4 +- 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c index 7b25190..48150c2 100644 --- a/src/jtag/drivers/ftdi.c +++ b/src/jtag/drivers/ftdi.c @@ -504,39 +504,49 @@ static void ftdi_execute_pathmove(struct jtag_command *cmd) } #if BUILD_FTDI_BSCAN == 1 -static void bscan_single_field_data_scan(const uint8_t *out, unsigned out_offset, uint8_t *in, +static void bscan_shift(bool traverse_to_end_state, const uint8_t *out, unsigned out_offset, uint8_t *in, unsigned in_offset, unsigned length) { - DO_CLOCK_DATA(mpsse_ctx, - out, - 0, - in, - 0, - length - 1, - ftdi_jtag_mode); - uint8_t last_bit = 0; - if (out) - bit_copy(&last_bit, 0, out, length - 1, 1); - uint8_t tms_bits = 0x01; - DO_CLOCK_TMS_CS(mpsse_ctx, - &tms_bits, - 0, - in, - length - 1, - 1, - last_bit, - ftdi_jtag_mode); - tap_set_state(tap_state_transition(tap_get_state(), 1)); - DO_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_state() != tap_get_end_state()) - move_to_state(tap_get_end_state()); + if (traverse_to_end_state) { + DO_CLOCK_DATA(mpsse_ctx, + out, + out_offset, + in, + in_offset, + length - 1, + ftdi_jtag_mode); + uint8_t last_bit = 0; + if (out) + bit_copy(&last_bit, 0, out, length - 1, 1); + uint8_t tms_bits = 0x01; + DO_CLOCK_TMS_CS(mpsse_ctx, + &tms_bits, + 0, + in, + in_offset + length - 1, + 1, + last_bit, + ftdi_jtag_mode); + tap_set_state(tap_state_transition(tap_get_state(), 1)); + DO_CLOCK_TMS_CS_OUT(mpsse_ctx, + &tms_bits, + 1, + 1, + 0, + ftdi_jtag_mode); + tap_set_state(tap_state_transition(tap_get_state(), 0)); + + if (tap_get_state() != tap_get_end_state()) + move_to_state(tap_get_end_state()); + } else { + DO_CLOCK_DATA(mpsse_ctx, + out, + out_offset, + in, + in_offset, + length, + ftdi_jtag_mode); + } } @@ -566,7 +576,7 @@ static void ftdi_execute_scan_via_bscan(struct jtag_command *cmd) // Do the 6-bit IR scan of 0x23 (USER4) - bscan_single_field_data_scan(&bscan_ir_user, 0, NULL, 0, bscan_ir_user_width); + bscan_shift(true, &bscan_ir_user, 0, NULL, 0, bscan_ir_user_width); if (tap_get_state() != tap_get_end_state()) move_to_state(tap_get_end_state()); @@ -584,7 +594,7 @@ static void ftdi_execute_scan_via_bscan(struct jtag_command *cmd) // shift in prologue uint8_t prologue = (scan_size << 1) | (cmd->cmd.scan->ir_scan ? 0 : 1); - static const uint8_t epilogue = 0x1; + static const uint8_t epilogue = 0x0; DO_CLOCK_DATA(mpsse_ctx, &prologue, @@ -639,8 +649,8 @@ static void ftdi_execute_scan_via_bscan(struct jtag_command *cmd) ftdi_jtag_mode); - // shift in epilogue and exit shift state - bscan_single_field_data_scan(&epilogue, 0, NULL, 0, 2); + // shift in epilogue (3 bits of value zero), exiting shift state and traversing to idle state + bscan_shift(true, &epilogue, 0, NULL, 0, 3); if (tap_get_state() != tap_get_end_state()) move_to_state(tap_get_end_state()); diff --git a/tcl/board/sifive-e31arty-onboard-ftdi.cfg b/tcl/board/sifive-e31arty-onboard-ftdi.cfg index c36e6f1..745828a 100644 --- a/tcl/board/sifive-e31arty-onboard-ftdi.cfg +++ b/tcl/board/sifive-e31arty-onboard-ftdi.cfg @@ -4,9 +4,9 @@ # -c "adapter_khz 5000" -f "interface/ftdi/arty-onboard-ftdi.cfg" -f "board/sifive-e31arty-onboard-ftdi.cfg" set _CHIPNAME riscv -jtag newtap $_CHIPNAME cpu -irlen 6 -expected-id 0x0362d093 +jtag newtap $_CHIPNAME cpu -irlen 6; # -expected-id 0x0362d093 -# Arrange for bscan tunneling mode to become active after the JTAG chain is verified +# Arrange for bscan tunneling mode to become active after the JTAG chain is verified (or has been reset but even if the full verification sequence wasn't perfect) jtag configure $_CHIPNAME.cpu -event setup { ftdi_bscan_mode on } -- cgit v1.1