arm_adi_v5: Add ability to ignore the CSYSPWRUPACK bit 10/3710/6
authorMatthias Welwarsky <matthias.welwarsky@sysgo.com>
Tue, 3 Apr 2018 17:13:40 +0000 (19:13 +0200)
committerMatthias Welwarsky <matthias@welwarsky.de>
Sat, 7 Apr 2018 19:30:12 +0000 (20:30 +0100)
The CTRL/STAT register in the ARM DAP DP has a debug power up
ack bit and a system power up ack bit. Some devices do not set
the system power up ack bit until sometime later. To avoid having
the initial target examination fail due to this or to have a
sticky bit error report claim power failure due to this a user
can now specify that this bit should be ignored.

Change-Id: I2451234bbe904984e29562ef6f616cc6d6f60732
Signed-off-by: Eric Katzfey <eric.katzfey@mentalbee.com>
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/3710
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
doc/openocd.texi
src/target/adi_v5_jtag.c
src/target/arm_adi_v5.c
src/target/arm_adi_v5.h
src/target/arm_dap.c

index d0a3d49b8d12b203437011812697258f53febf4a..f51ff24421e8eba00dd34787fa1bbb39228d40f4 100644 (file)
@@ -3779,6 +3779,11 @@ a TAP doesn't conform to the JTAG specification.
 to verify that instruction scans work correctly.
 Such scans are not used by OpenOCD except to verify that
 there seems to be no problems with JTAG scan chain operations.
+@item @code{-ignore-syspwrupack}
+@*Specify this to ignore the CSYSPWRUPACK bit in the ARM DAP DP CTRL/STAT
+register during initial examination and when checking the sticky error bit.
+This bit is normally checked after setting the CSYSPWRUPREQ bit, but some
+devices do not set the ack bit until sometime later.
 @end itemize
 @end deffn
 
@@ -4014,11 +4019,21 @@ instead of "@option{-chain-position} @var{dotted.name}" when the target is creat
 
 The @command{dap} command group supports the following sub-commands:
 
-@deffn Command {dap create} dap_name @option{-chain-position} dotted.name
+@deffn Command {dap create} dap_name @option{-chain-position} dotted.name configparams...
 Declare a DAP instance named @var{dap_name} linked to the JTAG tap
 @var{dotted.name}. This also creates a new command (@command{dap_name})
 which is used for various purposes including additional configuration.
 There can only be one DAP for each JTAG tap in the system.
+
+A DAP may also provide optional @var{configparams}:
+
+@itemize @bullet
+@item @code{-ignore-syspwrupack}
+@*Specify this to ignore the CSYSPWRUPACK bit in the ARM DAP DP CTRL/STAT
+register during initial examination and when checking the sticky error bit.
+This bit is normally checked after setting the CSYSPWRUPREQ bit, but some
+devices do not set the ack bit until sometime later.
+@end itemize
 @end deffn
 
 @deffn Command {dap names}
index dc02379002a0900837afe0fba38b366c93566ec1..8c206115d8c872401beabbf62957f6d8e9302fc1 100644 (file)
@@ -553,7 +553,7 @@ static int jtagdp_overrun_check(struct adiv5_dap *dap)
 static int jtagdp_transaction_endcheck(struct adiv5_dap *dap)
 {
        int retval;
-       uint32_t ctrlstat;
+       uint32_t ctrlstat, pwrmask;
 
        /* too expensive to call keep_alive() here */
 
@@ -571,8 +571,10 @@ static int jtagdp_transaction_endcheck(struct adiv5_dap *dap)
        if (ctrlstat & SSTICKYERR) {
                LOG_DEBUG("jtag-dp: CTRL/STAT 0x%" PRIx32, ctrlstat);
                /* Check power to debug regions */
-               if ((ctrlstat & (CDBGPWRUPREQ | CDBGPWRUPACK | CSYSPWRUPREQ | CSYSPWRUPACK)) !=
-                                               (CDBGPWRUPREQ | CDBGPWRUPACK | CSYSPWRUPREQ | CSYSPWRUPACK)) {
+               pwrmask = CDBGPWRUPREQ | CDBGPWRUPACK | CSYSPWRUPREQ;
+               if (!dap->ignore_syspwrupack)
+                       pwrmask |= CSYSPWRUPACK;
+               if ((ctrlstat & pwrmask) != pwrmask) {
                        LOG_ERROR("Debug regions are unpowered, an unexpected reset might have happened");
                        dap->do_reconnect = true;
                }
index 2b7d7b22d7d96b22288f5a946a5cbe4b39cf6652..f9b51cdec1e3bb1dc1a66acfb8436a194d1b6594 100644 (file)
@@ -676,12 +676,14 @@ int dap_dp_init(struct adiv5_dap *dap)
        if (retval != ERROR_OK)
                return retval;
 
-       LOG_DEBUG("DAP: wait CSYSPWRUPACK");
-       retval = dap_dp_poll_register(dap, DP_CTRL_STAT,
-                                     CSYSPWRUPACK, CSYSPWRUPACK,
-                                     DAP_POWER_DOMAIN_TIMEOUT);
-       if (retval != ERROR_OK)
-               return retval;
+       if (!dap->ignore_syspwrupack) {
+               LOG_DEBUG("DAP: wait CSYSPWRUPACK");
+               retval = dap_dp_poll_register(dap, DP_CTRL_STAT,
+                                             CSYSPWRUPACK, CSYSPWRUPACK,
+                                             DAP_POWER_DOMAIN_TIMEOUT);
+               if (retval != ERROR_OK)
+                       return retval;
+       }
 
        retval = dap_queue_dp_read(dap, DP_CTRL_STAT, NULL);
        if (retval != ERROR_OK)
index aa5fa42fef6efcdc6c277dd005218f81b41b6280..bc5611650d92d1bc97d0bab08c6d9dff286fd4bb 100644 (file)
@@ -244,6 +244,10 @@ struct adiv5_dap {
         * should be performed before the next access.
         */
        bool do_reconnect;
+
+       /** Flag saying whether to ignore the syspwrupack flag in DAP. Some devices
+        *  do not set this bit until later in the bringup sequence */
+       bool ignore_syspwrupack;
 };
 
 /**
index 692feb322fca732f1514edee326670a558c13a4e..797feb5bafdf83dbe36ff5bf338fe52afafdd8bd 100644 (file)
@@ -141,10 +141,12 @@ int dap_cleanup_all(void)
 
 enum dap_cfg_param {
        CFG_CHAIN_POSITION,
+       CFG_IGNORE_SYSPWRUPACK,
 };
 
 static const Jim_Nvp nvp_config_opts[] = {
        { .name = "-chain-position",   .value = CFG_CHAIN_POSITION },
+       { .name = "-ignore-syspwrupack", .value = CFG_IGNORE_SYSPWRUPACK },
        { .name = NULL, .value = -1 }
 };
 
@@ -177,6 +179,9 @@ static int dap_configure(Jim_GetOptInfo *goi, struct arm_dap_object *dap)
                        /* loop for more */
                        break;
                }
+               case CFG_IGNORE_SYSPWRUPACK:
+                       dap->dap.ignore_syspwrupack = true;
+                       break;
                default:
                        break;
                }

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)