drivers/stlink_usb: use command STLINK_DEBUG_APIV2_READ_IDCODES 26/4826/5
authorAntonio Borneo <borneo.antonio@gmail.com>
Wed, 19 Dec 2018 23:01:58 +0000 (00:01 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Fri, 8 Mar 2019 07:06:28 +0000 (07:06 +0000)
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>
src/jtag/drivers/stlink_usb.c

index 64c44d90dad443e9804005f7452164ba89f1d978..491f2e4ff2ceb41857374dc1a9f5925f5db17df1 100644 (file)
@@ -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);
 

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)