Force sane SRST and TRST initialization
[openocd.git] / src / jtag / ft2232.c
index bebf707ad4311ca58b5e54e6ce184e6aa6659b71..839976faa1aee37b41673a472144030615c27faf 100644 (file)
@@ -1,13 +1,16 @@
 /***************************************************************************
+*   Copyright (C) 2009 by Øyvind Harboe                                   *
+*      Øyvind Harboe <oyvind.harboe@zylin.com>                               *
+*                                                                         *
+*   Copyright (C) 2009 by SoftPLC Corporation.  http://softplc.com        *
+*      Dick Hollenbeck <dick@softplc.com>                                    *
+*                                                                         *
 *   Copyright (C) 2004, 2006 by Dominic Rath                              *
 *   Dominic.Rath@gmx.de                                                   *
 *                                                                         *
 *   Copyright (C) 2008 by Spencer Oliver                                  *
 *   spen@spen-soft.co.uk                                                  *
 *                                                                         *
-*   Copyright (C) 2009 by SoftPLC Corporation.  http://softplc.com        *
-*      Dick Hollenbeck <dick@softplc.com>                                    *
-*                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
@@ -260,9 +263,8 @@ static void clock_tms(uint8_t mpsse_cmd, int tms_bits, int tms_count, bool tdi_b
 
        assert(tms_count > 0);
 
-#if 0
-       LOG_DEBUG("mpsse cmd=%02x, tms_bits = 0x%08x, bit_count=%d", mpsse_cmd, tms_bits, tms_count);
-#endif
+       DEBUG_JTAG_IO("mpsse cmd=%02x, tms_bits = 0x%08x, bit_count=%d",
+                       mpsse_cmd, tms_bits, tms_count);
 
        for (tms_byte = tms_ndx = i = 0;   i < tms_count;   ++i, tms_bits>>=1)
        {
@@ -770,6 +772,8 @@ static void ft2232_add_pathmove(tap_state_t* path, int num_states)
 
        assert((unsigned) num_states <= 32u);           /* tms_bits only holds 32 bits */
 
+       DEBUG_JTAG_IO("-");
+
        /* this loop verifies that the path is legal and logs each state in the path */
        while (num_states)
        {
@@ -949,7 +953,6 @@ static void ft2232_add_scan(bool ir_scan, enum scan_type type, uint8_t* buffer,
                        tms_count = 2;
                        /* Clock Data to TMS/CS Pin with Read */
                        mpsse_cmd = 0x6b;
-                       /* LOG_DEBUG("added TMS scan (read)"); */
                }
                else
                {
@@ -957,9 +960,9 @@ static void ft2232_add_scan(bool ir_scan, enum scan_type type, uint8_t* buffer,
                        tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
                        /* Clock Data to TMS/CS Pin (no Read) */
                        mpsse_cmd = 0x4b;
-                       /* LOG_DEBUG("added TMS scan (no read)"); */
                }
 
+               DEBUG_JTAG_IO("finish %s", (type == SCAN_OUT) ? "without read" : "via PAUSE");
                clock_tms(mpsse_cmd, tms_bits, tms_count, last_bit);
        }
 
@@ -1151,6 +1154,7 @@ static int ft2232_large_scan(scan_command_t* cmd, enum scan_type type, uint8_t*
                        /* LOG_DEBUG("added TMS scan (no read)"); */
                }
 
+               DEBUG_JTAG_IO("finish, %s", (type == SCAN_OUT) ? "no read" : "read");
                clock_tms(mpsse_cmd, tms_bits, tms_count, last_bit);
        }
 
@@ -1562,10 +1566,9 @@ static int ft2232_execute_runtest(jtag_command_t *cmd)
        }
 
        require_send = 1;
-#ifdef _DEBUG_JTAG_IO_
-       LOG_DEBUG("runtest: %i, end in %s", cmd->cmd.runtest->num_cycles, tap_state_name(tap_get_end_state()));
-#endif
-
+       DEBUG_JTAG_IO("runtest: %i, end in %s",
+                       cmd->cmd.runtest->num_cycles,
+                       tap_state_name(tap_get_end_state()));
        return retval;
 }
 
@@ -1574,7 +1577,8 @@ static int ft2232_execute_statemove(jtag_command_t *cmd)
        int     predicted_size = 0;
        int     retval = ERROR_OK;
 
-       DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
+       DEBUG_JTAG_IO("statemove end in %s",
+                       tap_state_name(cmd->cmd.statemove->end_state));
 
        /* only send the maximum buffer size that FT2232C can handle */
        predicted_size = 3;
@@ -1682,10 +1686,9 @@ static int ft2232_execute_scan(jtag_command_t *cmd)
        require_send = 1;
        if (buffer)
                free(buffer);
-#ifdef _DEBUG_JTAG_IO_
-       LOG_DEBUG("%s scan, %i bits, end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
+       DEBUG_JTAG_IO("%s scan, %i bits, end in %s",
+                       (cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
                        tap_state_name(tap_get_end_state()));
-#endif
        return retval;
 
 }
@@ -1709,12 +1712,16 @@ static int ft2232_execute_reset(jtag_command_t *cmd)
                first_unsent = cmd;
        }
 
+       if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
+       {
+               tap_set_state(TAP_RESET);
+       }
+
        layout->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
        require_send = 1;
 
-#ifdef _DEBUG_JTAG_IO_
-       LOG_DEBUG("trst: %i, srst: %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
-#endif
+       DEBUG_JTAG_IO("trst: %i, srst: %i",
+                       cmd->cmd.reset->trst, cmd->cmd.reset->srst);
        return retval;
 }
 
@@ -1729,10 +1736,9 @@ static int ft2232_execute_sleep(jtag_command_t *cmd)
                                retval = ERROR_JTAG_QUEUE_FAILED;
        first_unsent = cmd->next;
        jtag_sleep(cmd->cmd.sleep->us);
-#ifdef _DEBUG_JTAG_IO_
-                       LOG_DEBUG("sleep %i usec while in %s", cmd->cmd.sleep->us, tap_state_name(tap_get_state()));
-#endif
-
+       DEBUG_JTAG_IO("sleep %i usec while in %s",
+                       cmd->cmd.sleep->us,
+                       tap_state_name(tap_get_state()));
        return retval;
 }
 
@@ -1746,10 +1752,9 @@ static int ft2232_execute_stableclocks(jtag_command_t *cmd)
         */
        if (ft2232_stableclocks(cmd->cmd.stableclocks->num_cycles, cmd) != ERROR_OK)
                retval = ERROR_JTAG_QUEUE_FAILED;
-#ifdef _DEBUG_JTAG_IO_
-       LOG_DEBUG("clocks %i while in %s", cmd->cmd.stableclocks->num_cycles, tap_state_name(tap_get_state()));
-#endif
-
+       DEBUG_JTAG_IO("clocks %i while in %s",
+                       cmd->cmd.stableclocks->num_cycles,
+                       tap_state_name(tap_get_state()));
        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)