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/4711

-- gerrit

commit 2105df53510319ab7efd99e5e35db9558dc201cd
Author: Antonio Borneo <[email protected]>
Date:   Sun Sep 23 15:28:05 2018 +0200

    stlink: add STLINK_F_HAS_MEM_16BIT
    
    Change-Id: I51a160a105342ddbab99c4182d89650a436f5945
    Signed-off-by: Antonio Borneo <[email protected]>

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) {

-- 


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

Reply via email to