diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2020-01-28 15:53:06 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2020-05-24 21:33:22 +0100 |
commit | ce9e21b769358b6408aada59810c33544bd8df4d (patch) | |
tree | 86d04f69f242513de8e230e0f72fdbca224ea02f | |
parent | 72f67790cf21b6328c9e599fb549b81f805694fc (diff) | |
download | riscv-openocd-ce9e21b769358b6408aada59810c33544bd8df4d.zip riscv-openocd-ce9e21b769358b6408aada59810c33544bd8df4d.tar.gz riscv-openocd-ce9e21b769358b6408aada59810c33544bd8df4d.tar.bz2 |
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.antonio@gmail.com>
Fixes: 3de6b5f6e52f ("jtag/drivers/stlink_usb : implemented and repaired SWIM support")
Reviewed-on: http://openocd.zylin.com/5532
Tested-by: jenkins
-rw-r--r-- | src/jtag/drivers/stlink_usb.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c index c866dc5..7281e58 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; @@ -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, |