Dick Hollenbeck <dick@softplc.com> comments & 7 clock TMS reset for good measure
[openocd.git] / src / jtag / jtag.c
index 91d0863891c6ecf6f33827a4b6eccf0ba8d392e4..a75c9c54a6609aa89479ea38b7aba5026d408a59 100644 (file)
 #include "command.h"
 #include "log.h"
 
-#include "stdlib.h"
-#include "string.h"
+#include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
 
 /* note that this is not marked as static as it must be available from outside jtag.c for those
    that implement the jtag_xxx() minidriver layer
@@ -576,7 +579,6 @@ int MINIDRIVER(interface_jtag_add_ir_scan)(int num_fields, scan_field_t *fields,
                        {
                                found = 1;
                                (*last_cmd)->cmd.scan->fields[nth_tap].out_value = buf_cpy(fields[j].out_value, cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
-                               (*last_cmd)->cmd.scan->fields[nth_tap].out_mask = buf_cpy(fields[j].out_mask, cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
 
                                if (jtag_verify_capture_ir)
                                {
@@ -601,7 +603,6 @@ int MINIDRIVER(interface_jtag_add_ir_scan)(int num_fields, scan_field_t *fields,
                {
                        /* if a tap isn't listed, set it to BYPASS */
                        (*last_cmd)->cmd.scan->fields[nth_tap].out_value = buf_set_ones(cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
-                       (*last_cmd)->cmd.scan->fields[nth_tap].out_mask = NULL;
                        tap->bypass = 1;
                }
 
@@ -649,7 +650,6 @@ int MINIDRIVER(interface_jtag_add_plain_ir_scan)(int num_fields, scan_field_t *f
                (*last_cmd)->cmd.scan->fields[i].tap = fields[i].tap;
                (*last_cmd)->cmd.scan->fields[i].num_bits = num_bits;
                (*last_cmd)->cmd.scan->fields[i].out_value = buf_cpy(fields[i].out_value, cmd_queue_alloc(num_bytes), num_bits);
-               (*last_cmd)->cmd.scan->fields[i].out_mask = buf_cpy(fields[i].out_mask, cmd_queue_alloc(num_bytes), num_bits);
                (*last_cmd)->cmd.scan->fields[i].in_value = fields[i].in_value;
                (*last_cmd)->cmd.scan->fields[i].in_check_value = fields[i].in_check_value;
                (*last_cmd)->cmd.scan->fields[i].in_check_mask = fields[i].in_check_mask;
@@ -726,7 +726,6 @@ int MINIDRIVER(interface_jtag_add_dr_scan)(int num_fields, scan_field_t *fields,
                                scan_size = fields[j].num_bits;
                                (*last_cmd)->cmd.scan->fields[field_count].num_bits = scan_size;
                                (*last_cmd)->cmd.scan->fields[field_count].out_value = buf_cpy(fields[j].out_value, cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
-                               (*last_cmd)->cmd.scan->fields[field_count].out_mask = buf_cpy(fields[j].out_mask, cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
                                (*last_cmd)->cmd.scan->fields[field_count].in_value = fields[j].in_value;
                                (*last_cmd)->cmd.scan->fields[field_count].in_check_value = fields[j].in_check_value;
                                (*last_cmd)->cmd.scan->fields[field_count].in_check_mask = fields[j].in_check_mask;
@@ -747,7 +746,6 @@ int MINIDRIVER(interface_jtag_add_dr_scan)(int num_fields, scan_field_t *fields,
                        /* program the scan field to 1 bit length, and ignore it's value */
                        (*last_cmd)->cmd.scan->fields[field_count].num_bits = 1;
                        (*last_cmd)->cmd.scan->fields[field_count].out_value = NULL;
-                       (*last_cmd)->cmd.scan->fields[field_count].out_mask = NULL;
                        (*last_cmd)->cmd.scan->fields[field_count].in_value = NULL;
                        (*last_cmd)->cmd.scan->fields[field_count].in_check_value = NULL;
                        (*last_cmd)->cmd.scan->fields[field_count].in_check_mask = NULL;
@@ -837,7 +835,6 @@ void MINIDRIVER(interface_jtag_add_dr_out)(jtag_tap_t *target_tap,
                                buf_set_u32(out_value, 0, scan_size, value[j]);
                                (*last_cmd)->cmd.scan->fields[field_count].num_bits = scan_size;
                                (*last_cmd)->cmd.scan->fields[field_count].out_value = buf_cpy(out_value, cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
-                               (*last_cmd)->cmd.scan->fields[field_count].out_mask = NULL;
                                (*last_cmd)->cmd.scan->fields[field_count].in_value = NULL;
                                (*last_cmd)->cmd.scan->fields[field_count].in_check_value = NULL;
                                (*last_cmd)->cmd.scan->fields[field_count].in_check_mask = NULL;
@@ -857,7 +854,6 @@ void MINIDRIVER(interface_jtag_add_dr_out)(jtag_tap_t *target_tap,
                        /* program the scan field to 1 bit length, and ignore it's value */
                        (*last_cmd)->cmd.scan->fields[field_count].num_bits = 1;
                        (*last_cmd)->cmd.scan->fields[field_count].out_value = NULL;
-                       (*last_cmd)->cmd.scan->fields[field_count].out_mask = NULL;
                        (*last_cmd)->cmd.scan->fields[field_count].in_value = NULL;
                        (*last_cmd)->cmd.scan->fields[field_count].in_check_value = NULL;
                        (*last_cmd)->cmd.scan->fields[field_count].in_check_mask = NULL;
@@ -903,7 +899,6 @@ int MINIDRIVER(interface_jtag_add_plain_dr_scan)(int num_fields, scan_field_t *f
                (*last_cmd)->cmd.scan->fields[i].tap = fields[i].tap;
                (*last_cmd)->cmd.scan->fields[i].num_bits = num_bits;
                (*last_cmd)->cmd.scan->fields[i].out_value = buf_cpy(fields[i].out_value, cmd_queue_alloc(num_bytes), num_bits);
-               (*last_cmd)->cmd.scan->fields[i].out_mask = buf_cpy(fields[i].out_mask, cmd_queue_alloc(num_bytes), num_bits);
                (*last_cmd)->cmd.scan->fields[i].in_value = fields[i].in_value;
                (*last_cmd)->cmd.scan->fields[i].in_check_value = fields[i].in_check_value;
                (*last_cmd)->cmd.scan->fields[i].in_check_mask = fields[i].in_check_mask;
@@ -943,7 +938,7 @@ int MINIDRIVER(interface_jtag_add_tlr)(void)
 
 void jtag_add_pathmove(int num_states, tap_state_t *path)
 {
-       tap_state_t cur_state=cmd_queue_cur_state;
+       tap_state_t cur_state = cmd_queue_cur_state;
        int i;
        int retval;
 
@@ -961,6 +956,7 @@ void jtag_add_pathmove(int num_states, tap_state_t *path)
                        LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences");
                        exit(-1);
                }
+
                if ( tap_state_transition(cur_state, true)  != path[i]
                  && tap_state_transition(cur_state, false) != path[i])
                {
@@ -972,7 +968,7 @@ void jtag_add_pathmove(int num_states, tap_state_t *path)
 
        jtag_prelude1();
 
-       retval=interface_jtag_add_pathmove(num_states, path);
+       retval = interface_jtag_add_pathmove(num_states, path);
        cmd_queue_cur_state = path[num_states - 1];
        if (retval!=ERROR_OK)
                jtag_error=retval;
@@ -1489,12 +1485,11 @@ int jtag_examine_chain(void)
        field.tap = NULL;
        field.num_bits = sizeof(idcode_buffer) * 8;
        field.out_value = idcode_buffer;
-       field.out_mask = NULL;
+       
        field.in_value = idcode_buffer;
-       field.in_check_value = NULL;
-       field.in_check_mask = NULL;
+       
+       
        field.in_handler = NULL;
-       field.in_handler_priv = NULL;
 
        for (i = 0; i < JTAG_MAX_CHAIN_SIZE; i++)
        {
@@ -1667,12 +1662,11 @@ int jtag_validate_chain(void)
        field.tap = NULL;
        field.num_bits = total_ir_length;
        field.out_value = ir_test;
-       field.out_mask = NULL;
+       
        field.in_value = ir_test;
-       field.in_check_value = NULL;
-       field.in_check_mask = NULL;
+       
+       
        field.in_handler = NULL;
-       field.in_handler_priv = NULL;
 
        jtag_add_plain_ir_scan(1, &field, TAP_RESET);
        jtag_execute_queue();
@@ -2789,7 +2783,6 @@ static int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, c
                fields[i].tap = tap;
                fields[i].out_value = malloc(CEIL(field_size, 8));
                buf_set_u32(fields[i].out_value, 0, field_size, strtoul(args[i*2+1], NULL, 0));
-               fields[i].out_mask = NULL;
                fields[i].in_value = NULL;
                fields[i].in_check_mask = NULL;
                fields[i].in_handler = NULL;
@@ -2905,7 +2898,6 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args
                fields[field_count].num_bits = bits;
                fields[field_count].out_value = malloc(CEIL(bits, 8));
                str_to_buf(str, len, fields[field_count].out_value, bits, 0);
-               fields[field_count].out_mask = NULL;
                fields[field_count].in_value = fields[field_count].out_value;
                fields[field_count].in_check_mask = NULL;
                fields[field_count].in_check_value = NULL;
@@ -3134,29 +3126,40 @@ static struct
                some long-standing problems.
                Jeff
 
-               I added the bit count into the table
+               I added the bit count into the table, reduced RESET column to 7 bits from 8.
                Dick
+
+               state specific comments:
+               ------------------------
+               *->RESET                   tried the 5 bit reset and it gave me problems, 7 bits seems to
+                                          work better on ARM9 with ft2232 driver.  (Dick)
+
+               RESET->DRSHIFT add 1 extra clock cycles in the RESET state before advancing.
+                                               needed on ARM9 with ft2232 driver.  (Dick)
+
+               RESET->IRSHIFT add 1 extra clock cycles in the RESET state before advancing.
+                                               needed on ARM9 with ft2232 driver.  (Dick)
        */
 
        /* to state: */
-       /*      RESET                   IDLE                            DRSHIFT                 DRPAUSE                 IRSHIFT                 IRPAUSE */              /* from state: */
-       {       B8(11111,5),            B8(0,1),                        B8(0010,4),             B8(01010,5),            B8(00110,5),    B8(010110,6) }, /* RESET */
-       {       B8(11111,5),            B8(0,1),                        B8(001,3),              B8(0101,4),             B8(0011,4),     B8(01011,5) },  /* IDLE */
-       {       B8(11111,5),            B8(011,3),              B8(00111,5),            B8(01,2),               B8(001111,6),   B8(0101111,7) },        /* DRSHIFT */
-       {       B8(11111,5),            B8(011,3),              B8(01,2),               B8(0,1),                        B8(001111,6),   B8(0101111,7) },        /* DRPAUSE */
-       {       B8(11111,5),            B8(011,3),              B8(00111,5),            B8(010111,6),   B8(001111,6),   B8(01,2) },             /* IRSHIFT */
-       {       B8(11111,5),            B8(011,3),              B8(00111,5),            B8(010111,6),   B8(01,2),               B8(0,1) }               /* IRPAUSE */
+       /*      RESET                   IDLE                            DRSHIFT                 DRPAUSE                 IRSHIFT                 IRPAUSE */                      /* from state: */
+       {       B8(1111111,7),  B8(0,1),                        B8(00101,5),    B8(01010,5),            B8(001101,6),   B8(010110,6) },         /* RESET */
+       {       B8(1111111,7),  B8(0,1),                        B8(001,3),              B8(0101,4),             B8(0011,4),     B8(01011,5) },          /* IDLE */
+       {       B8(1111111,7),  B8(011,3),              B8(00111,5),            B8(01,2),               B8(001111,6),   B8(0101111,7) },                /* DRSHIFT */
+       {       B8(1111111,7),  B8(011,3),              B8(01,2),               B8(0,1),                        B8(001111,6),   B8(0101111,7) },                /* DRPAUSE */
+       {       B8(1111111,7),  B8(011,3),              B8(00111,5),            B8(010111,6),   B8(001111,6),   B8(01,2) },                     /* IRSHIFT */
+       {       B8(1111111,7),  B8(011,3),              B8(00111,5),            B8(010111,6),   B8(01,2),               B8(0,1) }                       /* IRPAUSE */
 
 #else  /* this is the old table, converted from hex and with the bit_count set to 7 for each combo, like before */
 
        /* to state: */
-       /*      RESET                   IDLE                            DRSHIFT                 DRPAUSE                 IRSHIFT                 IRPAUSE */              /* from state: */
-       {       B8(1111111,7),  B8(0000000,7),  B8(0010111,7),  B8(0001010,7),  B8(0011011,7),  B8(0010110,7) },        /* RESET */
-       {       B8(1111111,7),  B8(0000000,7),  B8(0100101,7),          B8(0000101,7),  B8(0101011,7),          B8(0001011,7) },        /* IDLE */
-       {       B8(1111111,7),  B8(0110001,7),  B8(0000000,7),  B8(0000001,7),  B8(0001111,7),  B8(0101111,7) },        /* DRSHIFT */
-       {       B8(1111111,7),  B8(0110000,7),  B8(0100000,7),          B8(0010111,7),  B8(0011110,7),  B8(0101111,7) },        /* DRPAUSE */
-       {       B8(1111111,7),  B8(0110001,7),  B8(0000111,7),  B8(0010111,7),  B8(0000000,7),  B8(0000001,7) },        /* IRSHIFT */
-       {       B8(1111111,7),  B8(0110000,7),  B8(0011100,7),  B8(0010111,7),  B8(0100000,7),          B8(0101111,7) }         /* IRPAUSE */
+       /*      RESET                   IDLE                            DRSHIFT                 DRPAUSE                 IRSHIFT                 IRPAUSE */                      /* from state: */
+       {       B8(1111111,7),  B8(0000000,7),  B8(0010111,7),  B8(0001010,7),  B8(0011011,7),  B8(0010110,7) },                /* RESET */
+       {       B8(1111111,7),  B8(0000000,7),  B8(0100101,7),  B8(0000101,7),  B8(0101011,7),  B8(0001011,7) },                /* IDLE */
+       {       B8(1111111,7),  B8(0110001,7),  B8(0000000,7),  B8(0000001,7),  B8(0001111,7),  B8(0101111,7) },                /* DRSHIFT */
+       {       B8(1111111,7),  B8(0110000,7),  B8(0100000,7),  B8(0010111,7),  B8(0011110,7),  B8(0101111,7) },                /* DRPAUSE */
+       {       B8(1111111,7),  B8(0110001,7),  B8(0000111,7),  B8(0010111,7),  B8(0000000,7),  B8(0000001,7) },                /* IRSHIFT */
+       {       B8(1111111,7),  B8(0110000,7),  B8(0011100,7),  B8(0010111,7),  B8(0100000,7),  B8(0101111,7) }                 /* IRPAUSE */
 
 #endif
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)