slight speedup to jtag-tap
authorGreg Davill <greg.davill@gmail.com>
Sat, 18 Apr 2020 15:24:41 +0000 (00:54 +0930)
committerGreg Davill <greg.davill@gmail.com>
Sat, 18 Apr 2020 15:24:41 +0000 (00:54 +0930)
ecpprog.c
jtag_tap.c

index a899b47a14ed3ec4266afebd876820daab8af367..52eff187e42fd994ba84d1c148e2364eeaca729a 100644 (file)
--- 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)
index 9bc45bd4fe85377202c8c9863b86ab0bf6d9ad50..5236243260ddddaec96e95678384bc63f762307e 100644 (file)
@@ -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));
+               
        }
 }