stlink: simplify handling of SWIM 32/5532/6
authorAntonio Borneo <borneo.antonio@gmail.com>
Tue, 28 Jan 2020 14:53:06 +0000 (15:53 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 24 May 2020 20:33:22 +0000 (21:33 +0100)
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.antonio@gmail.com>
Fixes: 3de6b5f6e52f ("jtag/drivers/stlink_usb : implemented and repaired SWIM support")
Reviewed-on: http://openocd.zylin.com/5532
Tested-by: jenkins
src/jtag/drivers/stlink_usb.c

index c866dc54d3007fbb3866c000e521cc33d4bf9b2d..7281e584396327ab2f7bcaa279ed2915da0d76c3 100644 (file)
@@ -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;
@@ -3536,7 +3521,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,
@@ -3587,7 +3572,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,

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)