From: Greg Davill Date: Sat, 18 Apr 2020 15:24:41 +0000 (+0930) Subject: slight speedup to jtag-tap X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dc548ac7c0b6be210bdb1ca3c1d3cddef99f21ff;p=ecpprog.git slight speedup to jtag-tap --- diff --git a/ecpprog.c b/ecpprog.c index a899b47..52eff18 100644 --- a/ecpprog.c +++ b/ecpprog.c @@ -498,10 +498,7 @@ static void print_status_register(uint32_t status){ printf(" SED Error: %s\n", status & (1 << 29) ? "Yes" : "No" ); printf(" Bypass Mode: %s\n", status & (1 << 30) ? "Yes" : "No" ); printf(" Flow Througuh Mode: %s\n", status & (1 << 31) ? "Yes" : "No" ); - } - - } @@ -937,6 +934,11 @@ int main(int argc, char **argv) /* Put device into SPI bypass mode */ enter_spi_background_mode(); + usleep(20000); + flash_reset(); + + usleep(20000); + flash_read_id(); } else if (prog_sram) diff --git a/jtag_tap.c b/jtag_tap.c index 9bc45bd..5236243 100644 --- a/jtag_tap.c +++ b/jtag_tap.c @@ -213,29 +213,48 @@ void jtag_state_ack(bool tms) void jtag_state_step(bool tms) { - mpsse_send_byte(MC_DATA_TMS | MC_DATA_LSB | MC_DATA_BITS); - mpsse_send_byte(0); + //mpsse_send_byte(MC_DATA_TMS | MC_DATA_LSB | MC_DATA_BITS); + //mpsse_send_byte(0); if (tms) { - mpsse_send_byte(1); + // mpsse_send_byte(1); } else { - mpsse_send_byte(0); + // mpsse_send_byte(0); } jtag_state_ack(tms); } + +uint8_t bit_reverse(uint8_t); + void jtag_go_to_state(unsigned state) { - mpsse_purge(); + if (state == STATE_TEST_LOGIC_RESET) { - for (int i = 0; i < 6; ++i) { + for (int i = 0; i < 5; ++i) { jtag_state_step(true); } + mpsse_send_byte(MC_DATA_TMS | MC_DATA_LSB | MC_DATA_BITS); + mpsse_send_byte(5 - 1); + mpsse_send_byte(0b11111); + } else { + uint8_t d = 0; + uint8_t count = 0; while (jtag_current_state() != state) { + d = (d >> 1) & ~0x80; + if((tms_map[jtag_current_state()] >> state) & 1){ + d |= 0x80; + } + count++; + jtag_state_step((tms_map[jtag_current_state()] >> state) & 1); } + mpsse_send_byte(MC_DATA_TMS | MC_DATA_LSB | MC_DATA_BITS); + mpsse_send_byte(count - 1); + mpsse_send_byte(d >> (8-count)); + } }