Subject: ADIv5: fix more diagnostics
[openocd.git] / src / target / arm_adi_v5.c
index b8744d55e10d1cb8c978f00ffbe63c3b3ae27d19..bfa5cb4259de7fe431c02e961ade35973fb6d25c 100644 (file)
@@ -8,6 +8,8 @@
  *   Copyright (C) 2009 by Oyvind Harboe                                   *
  *   oyvind.harboe@zylin.com                                               *
  *                                                                         *
+ *   Copyright (C) 2009-2010 by David Brownell                             *
+ *                                                                         *
  *   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     *
@@ -319,27 +321,34 @@ int jtagdp_transaction_endcheck(struct swjdp_common *swjdp)
                }
        }
 
+       /* REVISIT also STICKYCMP, for pushed comparisons (nyet used) */
+
        /* Check for STICKYERR and STICKYORUN */
        if (ctrlstat & (SSTICKYORUN | SSTICKYERR))
        {
                LOG_DEBUG("jtag-dp: CTRL/STAT error, 0x%" PRIx32, ctrlstat);
                /* Check power to debug regions */
                if ((ctrlstat & 0xf0000000) != 0xf0000000)
-               {
                         ahbap_debugport_init(swjdp);
-               }
                else
                {
                        uint32_t mem_ap_csw, mem_ap_tar;
 
-                       /* Print information about last AHBAP access */
-                       LOG_ERROR("AHBAP Cached values: dp_select 0x%" PRIx32
-                               ", ap_csw 0x%" PRIx32 ", ap_tar 0x%" PRIx32,
-                               swjdp->dp_select_value, swjdp->ap_csw_value,
-                               swjdp->ap_tar_value);
+                       /* Maybe print information about last MEM-AP access */
+                       if (swjdp->ap_tar_value != (uint32_t) -1)
+                               LOG_DEBUG("MEM-AP Cached values: "
+                                       "ap_bank 0x%" PRIx32
+                                       ", ap_csw 0x%" PRIx32
+                                       ", ap_tar 0x%" PRIx32,
+                                       swjdp->dp_select_value,
+                                       swjdp->ap_csw_value,
+                                       swjdp->ap_tar_value);
+                       else
+                               LOG_ERROR("Invalid MEM-AP TAR cache!");
+
                        if (ctrlstat & SSTICKYORUN)
-                               LOG_ERROR("JTAG-DP OVERRUN - "
-                                       "check clock or reduce jtag speed");
+                               LOG_ERROR("JTAG-DP OVERRUN - check clock, "
+                                       "memaccess, or reduce jtag speed");
 
                        if (ctrlstat & SSTICKYERR)
                                LOG_ERROR("JTAG-DP STICKY ERROR");
@@ -641,9 +650,12 @@ static int mem_ap_write_buf_packed_u16(struct swjdp_common *swjdp,
 
                        if (nbytes < 4)
                        {
-                               if (mem_ap_write_buf_u16(swjdp, buffer, nbytes, address) != ERROR_OK)
+                               if (mem_ap_write_buf_u16(swjdp, buffer,
+                                               nbytes, address) != ERROR_OK)
                                {
-                                       LOG_WARNING("Block read error address 0x%" PRIx32 ", count 0x%x", address, count);
+                                       LOG_WARNING("Block write error address "
+                                               "0x%" PRIx32 ", count 0x%x",
+                                               address, count);
                                        return ERROR_JTAG_DEVICE_ERROR;
                                }
 
@@ -665,7 +677,9 @@ static int mem_ap_write_buf_packed_u16(struct swjdp_common *swjdp,
                                dap_ap_write_reg_u32(swjdp, AP_REG_DRW, outvalue);
                                if (jtagdp_transaction_endcheck(swjdp) != ERROR_OK)
                                {
-                                       LOG_WARNING("Block read error address 0x%" PRIx32 ", count 0x%x", address, count);
+                                       LOG_WARNING("Block write error address "
+                                               "0x%" PRIx32 ", count 0x%x",
+                                               address, count);
                                        return ERROR_JTAG_DEVICE_ERROR;
                                }
                        }
@@ -736,7 +750,9 @@ static int mem_ap_write_buf_packed_u8(struct swjdp_common *swjdp,
                        {
                                if (mem_ap_write_buf_u8(swjdp, buffer, nbytes, address) != ERROR_OK)
                                {
-                                       LOG_WARNING("Block read error address 0x%" PRIx32 ", count 0x%x", address, count);
+                                       LOG_WARNING("Block write error address "
+                                               "0x%" PRIx32 ", count 0x%x",
+                                               address, count);
                                        return ERROR_JTAG_DEVICE_ERROR;
                                }
 
@@ -758,7 +774,9 @@ static int mem_ap_write_buf_packed_u8(struct swjdp_common *swjdp,
                                dap_ap_write_reg_u32(swjdp, AP_REG_DRW, outvalue);
                                if (jtagdp_transaction_endcheck(swjdp) != ERROR_OK)
                                {
-                                       LOG_WARNING("Block read error address 0x%" PRIx32 ", count 0x%x", address, count);
+                                       LOG_WARNING("Block write error address "
+                                               "0x%" PRIx32 ", count 0x%x",
+                                               address, count);
                                        return ERROR_JTAG_DEVICE_ERROR;
                                }
                        }
@@ -1155,7 +1173,8 @@ is_dap_cid_ok(uint32_t cid3, uint32_t cid2, uint32_t cid1, uint32_t cid0)
                        && ((cid1 & 0x0f) == 0) && cid0 == 0x0d;
 }
 
-int dap_info_command(struct command_context *cmd_ctx, struct swjdp_common *swjdp, int apsel)
+int dap_info_command(struct command_context *cmd_ctx,
+               struct swjdp_common *swjdp, int apsel)
 {
 
        uint32_t dbgbase, apid;
@@ -1163,6 +1182,10 @@ int dap_info_command(struct command_context *cmd_ctx, struct swjdp_common *swjdp
        uint8_t mem_ap;
        uint32_t apselold;
 
+       /* AP address is in bits 31:24 of DP_SELECT */
+       if (apsel >= 256)
+               return ERROR_INVALID_ARGUMENTS;
+
        apselold = swjdp->apsel;
        dap_ap_select(swjdp, apsel);
        dap_ap_read_reg_u32(swjdp, AP_REG_BASE, &dbgbase);
@@ -1515,6 +1538,9 @@ DAP_COMMAND_HANDLER(dap_baseaddr_command)
                break;
        case 1:
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
+               /* AP address is in bits 31:24 of DP_SELECT */
+               if (apsel >= 256)
+                       return ERROR_INVALID_ARGUMENTS;
                break;
        default:
                return ERROR_COMMAND_SYNTAX_ERROR;
@@ -1571,6 +1597,9 @@ DAP_COMMAND_HANDLER(dap_apsel_command)
                break;
        case 1:
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
+               /* AP address is in bits 31:24 of DP_SELECT */
+               if (apsel >= 256)
+                       return ERROR_INVALID_ARGUMENTS;
                break;
        default:
                return ERROR_COMMAND_SYNTAX_ERROR;
@@ -1597,6 +1626,9 @@ DAP_COMMAND_HANDLER(dap_apid_command)
                break;
        case 1:
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
+               /* AP address is in bits 31:24 of DP_SELECT */
+               if (apsel >= 256)
+                       return ERROR_INVALID_ARGUMENTS;
                break;
        default:
                return ERROR_COMMAND_SYNTAX_ERROR;

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)