Add error handling and remove double readout.
[openocd.git] / src / target / adi_v5_jtag.c
index 9f37bd553d841080b8c416eceed2c553d2f1e524..1100b17d21cfa761de0476f99dbff85fb6b73b60 100644 (file)
@@ -23,7 +23,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.
  ***************************************************************************/
 
 /**
@@ -50,6 +50,8 @@
 #define JTAG_ACK_OK_FAULT      0x2
 #define JTAG_ACK_WAIT          0x1
 
+static int jtag_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack);
+
 /***************************************************************************
  *
  * DPACC and APACC scanchain access through JTAG-DP (or SWJ-DP)
  * @param ack points to where the three bit JTAG_ACK_* code will be stored
  */
 
-/* FIXME don't export ... this is a temporary workaround for the
- * mem_ap_read_buf_u32() mess, until it's no longer JTAG-specific.
- */
-int adi_jtag_dp_scan(struct adiv5_dap *dap,
+static int adi_jtag_dp_scan(struct adiv5_dap *dap,
                uint8_t instr, uint8_t reg_addr, uint8_t RnW,
                uint8_t *outvalue, uint8_t *invalue, uint8_t *ack)
 {
@@ -235,12 +234,16 @@ static int jtagdp_transaction_endcheck(struct adiv5_dap *dap)
                while (dap->ack != JTAG_ACK_OK_FAULT) {
                        if (dap->ack == JTAG_ACK_WAIT) {
                                if ((timeval_ms()-then) > 1000) {
-                                       /* NOTE:  this would be a good spot
-                                        * to use JTAG_DP_ABORT.
-                                        */
                                        LOG_WARNING("Timeout (1000ms) waiting "
                                                "for ACK=OK/FAULT "
-                                               "in JTAG-DP transaction");
+                                               "in JTAG-DP transaction - aborting");
+
+                                       uint8_t ack;
+                                       int abort_ret = jtag_ap_q_abort(dap, &ack);
+
+                                       if (abort_ret != 0)
+                                               LOG_WARNING("Abort failed : return=%d ack=%d", abort_ret, ack);
+
                                        return ERROR_JTAG_DEVICE_ERROR;
                                }
                        } else {
@@ -339,30 +342,6 @@ static int jtagdp_transaction_endcheck(struct adiv5_dap *dap)
 
 /*--------------------------------------------------------------------------*/
 
-static int jtag_idcode_q_read(struct adiv5_dap *dap,
-               uint8_t *ack, uint32_t *data)
-{
-       struct arm_jtag *jtag_info = dap->jtag_info;
-       int retval;
-       struct scan_field fields[1];
-
-       /* This is a standard JTAG operation -- no DAP tweakage */
-       retval = arm_jtag_set_instr(jtag_info, JTAG_DP_IDCODE, NULL, TAP_IDLE);
-       if (retval != ERROR_OK)
-               return retval;
-
-       fields[0].num_bits = 32;
-       fields[0].out_value = NULL;
-       fields[0].in_value = (void *) data;
-
-       jtag_add_dr_scan(jtag_info->tap, 1, fields, TAP_IDLE);
-
-       jtag_add_callback(arm_le_to_h_u32,
-                       (jtag_callback_data_t) data);
-
-       return ERROR_OK;
-}
-
 static int jtag_dp_q_read(struct adiv5_dap *dap, unsigned reg,
                uint32_t *data)
 {
@@ -433,13 +412,12 @@ static int jtag_dp_run(struct adiv5_dap *dap)
  * part of DAP setup
 */
 const struct dap_ops jtag_dp_ops = {
-       .queue_idcode_read =    jtag_idcode_q_read,
-       .queue_dp_read =        jtag_dp_q_read,
-       .queue_dp_write =       jtag_dp_q_write,
-       .queue_ap_read =        jtag_ap_q_read,
-       .queue_ap_write =       jtag_ap_q_write,
-       .queue_ap_abort =       jtag_ap_q_abort,
-       .run =                  jtag_dp_run,
+       .queue_dp_read       = jtag_dp_q_read,
+       .queue_dp_write      = jtag_dp_q_write,
+       .queue_ap_read       = jtag_ap_q_read,
+       .queue_ap_write      = jtag_ap_q_write,
+       .queue_ap_abort      = jtag_ap_q_abort,
+       .run                 = jtag_dp_run,
 };
 
 

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)