aboutsummaryrefslogtreecommitdiff
path: root/src/jtag
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2018-09-23 15:28:05 +0200
committerSpencer Oliver <spen@spen-soft.co.uk>2018-12-06 13:05:27 +0000
commit861730f73230d764e0309422556bc5f7ab33e94f (patch)
treee477985b6397c6864e2d0c4b3dd5f0709be9b63b /src/jtag
parent85223bb500e0d7c1580de07939438aa45759df75 (diff)
downloadriscv-openocd-861730f73230d764e0309422556bc5f7ab33e94f.zip
riscv-openocd-861730f73230d764e0309422556bc5f7ab33e94f.tar.gz
riscv-openocd-861730f73230d764e0309422556bc5f7ab33e94f.tar.bz2
stlink: add STLINK_F_HAS_MEM_16BIT
Change-Id: I51a160a105342ddbab99c4182d89650a436f5945 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4711 Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/jtag')
-rw-r--r--src/jtag/drivers/stlink_usb.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 852fa59..5e0411f 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -280,6 +280,7 @@ enum stlink_mode {
#define STLINK_F_HAS_TRACE (1UL << 0)
#define STLINK_F_HAS_SWD_SET_FREQ (1UL << 1)
#define STLINK_F_HAS_JTAG_SET_FREQ (1UL << 2)
+#define STLINK_F_HAS_MEM_16BIT (1UL << 3)
/* aliases */
#define STLINK_F_HAS_TARGET_VOLT STLINK_F_HAS_TRACE
@@ -684,6 +685,10 @@ static int stlink_usb_version(void *handle)
if (h->version.jtag >= 24)
flags |= STLINK_F_HAS_JTAG_SET_FREQ;
+ /* API to read/write memory at 16 bit from J26 */
+ if (h->version.jtag >= 26)
+ flags |= STLINK_F_HAS_MEM_16BIT;
+
break;
default:
break;
@@ -1746,9 +1751,7 @@ static int stlink_usb_read_mem16(void *handle, uint32_t addr, uint16_t len,
assert(handle != NULL);
- /* only supported by stlink/v2 and for firmware >= 26 */
- if (h->jtag_api == STLINK_JTAG_API_V1 ||
- (h->jtag_api == STLINK_JTAG_API_V2 && h->version.jtag < 26))
+ if (!(h->version.flags & STLINK_F_HAS_MEM_16BIT))
return ERROR_COMMAND_NOTFOUND;
/* data must be a multiple of 2 and half-word aligned */
@@ -1785,9 +1788,7 @@ static int stlink_usb_write_mem16(void *handle, uint32_t addr, uint16_t len,
assert(handle != NULL);
- /* only supported by stlink/v2 and for firmware >= 26 */
- if (h->jtag_api == STLINK_JTAG_API_V1 ||
- (h->jtag_api == STLINK_JTAG_API_V2 && h->version.jtag < 26))
+ if (!(h->version.flags & STLINK_F_HAS_MEM_16BIT))
return ERROR_COMMAND_NOTFOUND;
/* data must be a multiple of 2 and half-word aligned */
@@ -1899,8 +1900,7 @@ static int stlink_usb_read_mem(void *handle, uint32_t addr, uint32_t size,
count *= size;
/* switch to 8 bit if stlink does not support 16 bit memory read */
- if (size == 2 && (h->jtag_api == STLINK_JTAG_API_V1 ||
- (h->jtag_api == STLINK_JTAG_API_V2 && h->version.jtag < 26)))
+ if (size == 2 && !(h->version.flags & STLINK_F_HAS_MEM_16BIT))
size = 1;
while (count) {
@@ -1985,8 +1985,7 @@ static int stlink_usb_write_mem(void *handle, uint32_t addr, uint32_t size,
count *= size;
/* switch to 8 bit if stlink does not support 16 bit memory read */
- if (size == 2 && (h->jtag_api == STLINK_JTAG_API_V1 ||
- (h->jtag_api == STLINK_JTAG_API_V2 && h->version.jtag < 26)))
+ if (size == 2 && !(h->version.flags & STLINK_F_HAS_MEM_16BIT))
size = 1;
while (count) {