This is an automated email from Gerrit.

Antonio Borneo (borneo.anto...@gmail.com) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/5532

-- gerrit

commit cf6ac8b4d347dbbda63cff6a1eff2046e43b96bc
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Tue Jan 28 15:53:06 2020 +0100

    stlink: simplify handling of SWIM
    
    Now that SWIM is not accessed through HLA anymore, decouple the
    SWIM code and remove the conditional execution.
    
    Fix the inconsistency of the return type for stlink_usb_state() in
    case of SWIM (returns ERROR_OK while type is enum target_state)
    introduced by commit 3de6b5f6e52f ("jtag/drivers/stlink_usb :
    implemented and repaired SWIM support").
    The code added by commit above in stlink_usb_state() is an hack to
    reuse existing HLA API to perform a reconnect.
    Move the SWIM specific code from stlink_usb_state() to a dedicated
    stlink_swim_op_reconnect() that provides consistent data type.
    
    Change-Id: I3fe175fef00b0735bea6139b057f217a080c9d38
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>
    Fixes: 3de6b5f6e52f ("jtag/drivers/stlink_usb : implemented and repaired 
SWIM support")

diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 5aa85ab..722ae38 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -1761,18 +1761,6 @@ static enum target_state stlink_usb_state(void *handle)
 
        assert(handle != NULL);
 
-       if (h->st_mode == STLINK_MODE_DEBUG_SWIM) {
-               res = stlink_usb_mode_enter(handle, h->st_mode);
-               if (res != ERROR_OK)
-                       return TARGET_UNKNOWN;
-
-               res = stlink_swim_resync(handle);
-               if (res != ERROR_OK)
-                       return TARGET_UNKNOWN;
-
-               return ERROR_OK;
-       }
-
        if (h->reconnect_pending) {
                LOG_INFO("Previous state query failed, trying to reconnect");
                res = stlink_usb_mode_enter(handle, h->st_mode);
@@ -1892,9 +1880,6 @@ static int stlink_usb_reset(void *handle)
 
        assert(handle != NULL);
 
-       if (h->st_mode == STLINK_MODE_DEBUG_SWIM)
-               return stlink_swim_generate_rst(handle);
-
        stlink_usb_init_buffer(handle, h->rx_ep, 2);
 
        h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_COMMAND;
@@ -3457,7 +3442,7 @@ static void stlink_dap_op_quit(struct adiv5_dap *dap)
 
 static int stlink_swim_op_srst(void)
 {
-       return stlink_usb_reset(stlink_dap_handle);
+       return stlink_swim_generate_rst(stlink_dap_handle);
 }
 
 static int stlink_swim_op_read_mem(uint32_t addr, uint32_t size,
@@ -3508,7 +3493,13 @@ static int stlink_swim_op_write_mem(uint32_t addr, 
uint32_t size,
 
 static int stlink_swim_op_reconnect(void)
 {
-       return stlink_usb_state(stlink_dap_handle);
+       int retval;
+
+       retval = stlink_usb_mode_enter(stlink_dap_handle, 
STLINK_MODE_DEBUG_SWIM);
+       if (retval != ERROR_OK)
+               return retval;
+
+       return stlink_swim_resync(stlink_dap_handle);
 }
 
 static int stlink_dap_config_trace(bool enabled,

-- 


_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to