jtag/drivers/stlink_usb: fix SWO prescaler 56/5656/3
authorCliff L. Biffle <cliff@oxide.computer>
Tue, 12 May 2020 20:28:04 +0000 (13:28 -0700)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 30 Oct 2020 22:01:32 +0000 (22:01 +0000)
The config_trace function has an out-parameter for generating the
prescaler for the TPIU. The STLink implementation wasn't always writing
it, causing the tpiu command to load uninitialized stack memory (minus
one) into the TPIU's prescaler register when 'external' was requested.

This change ensures that the out-parameter (and the other one,
trace_freq, which hadn't caused any buggy behavior for me) are written
every time.

Signed-off-by: Cliff L. Biffle <cliff@oxide.computer>
Change-Id: I222975869b1aa49cc6b1963c79d5ea0f46522b8c
Reviewed-on: http://openocd.zylin.com/5656
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/jtag/drivers/stlink_usb.c

index ce55b94a556e3620f757177d2d8b5b3babbc8a45..bfc27f2aacfaec947c1801ff73e0f088d6ea4318 100644 (file)
@@ -2996,12 +2996,8 @@ int stlink_config_trace(void *handle, bool enabled,
                return ERROR_FAIL;
        }
 
-       if (!enabled) {
-               stlink_usb_trace_disable(h);
-               return ERROR_OK;
-       }
-
-       if (*trace_freq > STLINK_TRACE_MAX_HZ) {
+       /* Only concern ourselves with the frequency if the STlink is processing it. */
+       if (enabled && *trace_freq > STLINK_TRACE_MAX_HZ) {
                LOG_ERROR("ST-LINK doesn't support SWO frequency higher than %u",
                          STLINK_TRACE_MAX_HZ);
                return ERROR_FAIL;
@@ -3024,6 +3020,10 @@ int stlink_config_trace(void *handle, bool enabled,
        }
 
        *prescaler = presc;
+
+       if (!enabled)
+               return ERROR_OK;
+
        h->trace.source_hz = *trace_freq;
 
        return stlink_usb_trace_enable(h);

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)