aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2018-12-20 00:01:58 +0100
committerTomas Vanek <vanekt@fbl.cz>2019-03-08 07:06:28 +0000
commit56568b7996323da8e9254cadcdd555323a76466f (patch)
tree57e53cf4dd24b39710d517fd4b0f0d4cd78a71e3
parent05c6c871e3328dd38dc46ea11b3b9b546feb7850 (diff)
downloadriscv-openocd-56568b7996323da8e9254cadcdd555323a76466f.zip
riscv-openocd-56568b7996323da8e9254cadcdd555323a76466f.tar.gz
riscv-openocd-56568b7996323da8e9254cadcdd555323a76466f.tar.bz2
drivers/stlink_usb: use command STLINK_DEBUG_APIV2_READ_IDCODES
API v2 deprecates using command STLINK_DEBUG_READCOREID to read the core ID. Switch to STLINK_DEBUG_APIV2_READ_IDCODES on new stlink firmware version. Change-Id: Iabadfc116c57f2c31f08f2e77baefea0cf90bdc3 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4826 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
-rw-r--r--src/jtag/drivers/stlink_usb.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 64c44d9..491f2e4 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -1553,7 +1553,7 @@ static int stlink_swim_readbytes(void *handle, uint32_t addr, uint32_t len, uint
/** */
static int stlink_usb_idcode(void *handle, uint32_t *idcode)
{
- int res;
+ int res, offset;
struct stlink_usb_handle_s *h = handle;
assert(handle != NULL);
@@ -1564,17 +1564,25 @@ static int stlink_usb_idcode(void *handle, uint32_t *idcode)
return ERROR_OK;
}
- stlink_usb_init_buffer(handle, h->rx_ep, 4);
+ stlink_usb_init_buffer(handle, h->rx_ep, 12);
h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_COMMAND;
- h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_READCOREID;
+ if (h->version.jtag_api == STLINK_JTAG_API_V1) {
+ h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_READCOREID;
- res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 4);
+ res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 4);
+ offset = 0;
+ } else {
+ h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV2_READ_IDCODES;
+
+ res = stlink_usb_xfer_errcheck(handle, h->databuf, 12);
+ offset = 4;
+ }
if (res != ERROR_OK)
return res;
- *idcode = le_to_h_u32(h->databuf);
+ *idcode = le_to_h_u32(h->databuf + offset);
LOG_DEBUG("IDCODE: 0x%08" PRIX32, *idcode);