This is an automated email from Gerrit.

Cliff L. Biffle ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/5656

-- gerrit

commit 0220493eb042d0bc9f8d1f00942b95c598209433
Author: Cliff L. Biffle <[email protected]>
Date:   Tue May 12 13:28:04 2020 -0700

    jtag/drivers/stlink_usb: fix SWO prescaler
    
    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 <[email protected]>
    Change-Id: I222975869b1aa49cc6b1963c79d5ea0f46522b8c

diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 03d3da7..24e9165 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -3025,12 +3025,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;
@@ -3053,6 +3049,11 @@ 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);

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to