This is an automated email from Gerrit.

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

-- gerrit

commit 265b0335e1fa6fe7f46d5b45c716753e8d430e95
Author: Antonio Borneo <[email protected]>
Date:   Thu Dec 20 00:01:58 2018 +0100

    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 <[email protected]>

diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 4a1eabd..d4619ce 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -1343,7 +1343,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);
@@ -1354,17 +1354,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);
 

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to