Allow autoscan up to 64 bit IR lengths
[openocd.git] / src / jtag / core.c
index 63f319a3f96906c648d5781248556762f3f21210..b61280cc0ce2bb349a1d23f3bb041b4aba62516c 100644 (file)
@@ -25,7 +25,7 @@
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -894,7 +894,7 @@ void jtag_sleep(uint32_t us)
 /* A reserved manufacturer ID is used in END_OF_CHAIN_FLAG, so we
  * know that no valid TAP will have it as an IDCODE value.
  */
-#define END_OF_CHAIN_FLAG       0x000000ff
+#define END_OF_CHAIN_FLAG       0xffffffff
 
 /* a larger IR length than we ever expect to autoprobe */
 #define JTAG_IRLEN_MAX          60
@@ -962,10 +962,10 @@ static bool jtag_idcode_is_final(uint32_t idcode)
 {
        /*
         * Some devices, such as AVR8, will output all 1's instead
-        * of TDI input value at end of chain.  Allow those values
+        * of TDI input value at end of chain. Allow those values
         * instead of failing.
         */
-       return idcode == END_OF_CHAIN_FLAG || idcode == 0xFFFFFFFF;
+       return idcode == END_OF_CHAIN_FLAG;
 }
 
 /**
@@ -1177,7 +1177,7 @@ static int jtag_validate_ircapture(void)
        int total_ir_length = 0;
        uint8_t *ir_test = NULL;
        struct scan_field field;
-       int val;
+       uint64_t val;
        int chain_pos = 0;
        int retval;
 
@@ -1236,8 +1236,8 @@ static int jtag_validate_ircapture(void)
                 */
                if (tap->ir_length == 0) {
                        tap->ir_length = 2;
-                       while ((val = buf_get_u32(ir_test, chain_pos, tap->ir_length + 1)) == 1
-                                       && tap->ir_length <= 32) {
+                       while ((val = buf_get_u64(ir_test, chain_pos, tap->ir_length + 1)) == 1
+                                       && tap->ir_length <= 64) {
                                tap->ir_length++;
                        }
                        LOG_WARNING("AUTO %s - use \"... -irlen %d\"",
@@ -1251,25 +1251,23 @@ static int jtag_validate_ircapture(void)
                 * this part of the JTAG spec, so their capture mask/value
                 * attributes might disable this test.
                 */
-               val = buf_get_u32(ir_test, chain_pos, tap->ir_length);
+               val = buf_get_u64(ir_test, chain_pos, tap->ir_length);
                if ((val & tap->ir_capture_mask) != tap->ir_capture_value) {
-                       LOG_ERROR("%s: IR capture error; saw 0x%0*x not 0x%0*x",
+                       LOG_ERROR("%s: IR capture error; saw 0x%0*" PRIx64 " not 0x%0*" PRIx32,
                                jtag_tap_name(tap),
-                               (tap->ir_length + 7) / tap->ir_length,
-                               val,
-                               (tap->ir_length + 7) / tap->ir_length,
-                               (unsigned) tap->ir_capture_value);
+                               (tap->ir_length + 7) / tap->ir_length, val,
+                               (tap->ir_length + 7) / tap->ir_length, tap->ir_capture_value);
 
                        retval = ERROR_JTAG_INIT_FAILED;
                        goto done;
                }
-               LOG_DEBUG("%s: IR capture 0x%0*x", jtag_tap_name(tap),
+               LOG_DEBUG("%s: IR capture 0x%0*" PRIx64, jtag_tap_name(tap),
                        (tap->ir_length + 7) / tap->ir_length, val);
                chain_pos += tap->ir_length;
        }
 
        /* verify the '11' sentinel we wrote is returned at the end */
-       val = buf_get_u32(ir_test, chain_pos, 2);
+       val = buf_get_u64(ir_test, chain_pos, 2);
        if (val != 0x3) {
                char *cbuf = buf_to_str(ir_test, total_ir_length, 16);
 
@@ -1371,6 +1369,11 @@ int adapter_init(struct command_context *cmd_ctx)
                        return retval;
        }
 
+       if (jtag->speed == NULL) {
+               LOG_INFO("This adapter doesn't support configurable speed");
+               return ERROR_OK;
+       }
+
        if (CLOCK_MODE_UNSELECTED == clock_mode) {
                LOG_ERROR("An adapter speed is not selected in the init script."
                        " Insert a call to adapter_khz or jtag_rclk to proceed.");
@@ -1549,7 +1552,17 @@ int jtag_init_reset(struct command_context *cmd_ctx)
                if ((jtag_reset_config & RESET_SRST_PULLS_TRST) == 0)
                        jtag_add_reset(0, 1);
        }
-       jtag_add_reset(0, 0);
+
+       /* some targets enable us to connect with srst asserted */
+       if (jtag_reset_config & RESET_CNCT_UNDER_SRST) {
+               if (jtag_reset_config & RESET_SRST_NO_GATING)
+                       jtag_add_reset(0, 1);
+               else {
+                       LOG_WARNING("\'srst_nogate\' reset_config option is required");
+                       jtag_add_reset(0, 0);
+               }
+       } else
+               jtag_add_reset(0, 0);
        retval = jtag_execute_queue();
        if (retval != ERROR_OK)
                return retval;
@@ -1572,6 +1585,14 @@ int jtag_init(struct command_context *cmd_ctx)
 
        /* guard against oddball hardware: force resets to be inactive */
        jtag_add_reset(0, 0);
+
+       /* some targets enable us to connect with srst asserted */
+       if (jtag_reset_config & RESET_CNCT_UNDER_SRST) {
+               if (jtag_reset_config & RESET_SRST_NO_GATING)
+                       jtag_add_reset(0, 1);
+               else
+                       LOG_WARNING("\'srst_nogate\' reset_config option is required");
+       }
        retval = jtag_execute_queue();
        if (retval != ERROR_OK)
                return retval;

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)