drivers/stlink_usb: fix stlink_usb_read_regs() for API v2
API v2 implementation for command READALLREGS returns the status in the first two bytes, followed by two bytes of padding. This makes the reply 4 bytes longer and changes the offset of the first register value to 4. Fix it for the case API v2 and clean-up the management of the return value. Change-Id: I448c82bcc0baa72d66fdfe7f0c525b94f8a4468b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4824 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>reverse-resume-order
parent
720380f9e3
commit
d46b28983d
|
@ -1895,20 +1895,21 @@ static int stlink_usb_read_regs(void *handle)
|
||||||
|
|
||||||
assert(handle != NULL);
|
assert(handle != NULL);
|
||||||
|
|
||||||
stlink_usb_init_buffer(handle, h->rx_ep, 84);
|
stlink_usb_init_buffer(handle, h->rx_ep, 88);
|
||||||
|
|
||||||
h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_COMMAND;
|
h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_COMMAND;
|
||||||
if (h->version.jtag_api == STLINK_JTAG_API_V1)
|
if (h->version.jtag_api == STLINK_JTAG_API_V1) {
|
||||||
|
|
||||||
h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV1_READALLREGS;
|
h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV1_READALLREGS;
|
||||||
else
|
|
||||||
h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV2_READALLREGS;
|
|
||||||
|
|
||||||
res = stlink_usb_xfer(handle, h->databuf, 84);
|
res = stlink_usb_xfer(handle, h->databuf, 84);
|
||||||
|
/* regs data from offset 0 */
|
||||||
|
} else {
|
||||||
|
h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV2_READALLREGS;
|
||||||
|
res = stlink_usb_xfer(handle, h->databuf, 88);
|
||||||
|
/* status at offset 0, regs data from offset 4 */
|
||||||
|
}
|
||||||
|
|
||||||
if (res != ERROR_OK)
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
return ERROR_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
|
|
Loading…
Reference in New Issue