target/arm_adi_v5: fix sync CSW cache on apreg write 79/4679/3
authorAntonio Borneo <borneo.antonio@gmail.com>
Fri, 21 Sep 2018 13:52:02 +0000 (15:52 +0200)
committerMatthias Welwarsky <matthias@welwarsky.de>
Sat, 27 Oct 2018 13:37:05 +0000 (14:37 +0100)
Commit 0057c71ab6b81d0679b232318fc5f84b4becc471 updates the OpenOCD
cached values of CSW and TAR registers if these registers are modified
by an apreg command.
The condition to force the update of CSW cache is incorrect and it will
erase the default CSW value.
Moreover, calling mem_ap_setup_csw() does not honor the value requested
in the apreg command because such value is incorrectly bitwise or-ed
with csw_default.

Fix it by updating csw_value, instead of erasing csw_default, and writing
directly in CSW register the new value from the command line.

Change-Id: I40273cb64d22ccfb9b6d3499bd39b586eb60de38
Fixes: 0057c71ab6b8 ("target/arm_adi_v5: sync CSW and TAR cache on apreg write")
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4679
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
src/target/arm_adi_v5.c

index d9f3bd74f86e209520f9bd864095ee110306cf51..e62ac07577acce79c56af03dcd8b04764a5b0ffe 100644 (file)
@@ -1738,8 +1738,10 @@ COMMAND_HANDLER(dap_apreg_command)
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], value);
                switch (reg) {
                case MEM_AP_REG_CSW:
-                       ap->csw_default = 0;  /* invalid, force write */
-                       retval = mem_ap_setup_csw(ap, value);
+                       ap->csw_value = 0;  /* invalid, in case write fails */
+                       retval = dap_queue_ap_write(ap, reg, value);
+                       if (retval == ERROR_OK)
+                               ap->csw_value = value;
                        break;
                case MEM_AP_REG_TAR:
                        ap->tar_valid = false;  /* invalid, force write */

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)