This is an automated email from Gerrit.

Andrey Skvortsov ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/2217

-- gerrit

commit ea58d24cb3637451968eabea3b7b8ad6e541e672
Author: Andrey Skvortsov <[email protected]>
Date:   Wed Jul 16 15:58:03 2014 +0400

    jtag: drivers: stlink: fix problem with breaking SWO trace on target
    reset command
    
    If the SWO trace was enabled, then the reset run/halt commands broke
    the SWO trace functionality. ST-Link received wrong data afterwards
    until OpenOCD is restarted.
    Disabling and reenabling tracing after any reset fixes this problem.
    Tested on STLINK v2 JTAG v21 with LDM-K1986BE92QI development board.
    
    Change-Id: I756ab02c1a80930e6d6085a0c66140b480d2b3a8
    Signed-off-by: Andrey Skvortsov <[email protected]>

diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 5574a40..c606b5e 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -942,11 +942,27 @@ static int stlink_usb_reset(void *handle)
 
        LOG_DEBUG("RESET: 0x%08X", h->databuf[0]);
 
-       /* the following is not a error under swd (using hardware srst), so 
return success */
-       if (h->databuf[0] == STLINK_SWD_AP_WAIT || h->databuf[0] == 
STLINK_SWD_DP_WAIT)
+       /* the following is not a error under swd (using hardware srst) */
+       if (h->databuf[0] == STLINK_SWD_AP_WAIT
+               || h->databuf[0] == STLINK_SWD_DP_WAIT
+               || h->databuf[0] == STLINK_DEBUG_ERR_OK) {
+
+               /* Try to restart tracing, if it's used */
+               if (h->jtag_api == STLINK_JTAG_API_V2 && h->trace.source_hz) {
+
+                       if (h->trace.enabled)
+                               stlink_usb_trace_disable(handle);
+
+                       if (!h->trace.enabled) {
+                               if (stlink_usb_trace_enable(handle) == ERROR_OK)
+                                       LOG_DEBUG("Tracing: restarted");
+                               else
+                                       LOG_ERROR("Tracing: restart failed");
+                       }
+               }
                return ERROR_OK;
-
-       return h->databuf[0] == STLINK_DEBUG_ERR_OK ? ERROR_OK : ERROR_FAIL;
+       } else
+               return ERROR_FAIL;
 }
 
 static int stlink_usb_assert_srst(void *handle, int srst)

-- 

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to