jtag/stlink: add STLINK-V3PWR support 55/7755/2
authorLaurent LEMELE <laurent.lemele@st.com>
Tue, 13 Dec 2022 15:12:08 +0000 (16:12 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 8 Jul 2023 18:06:33 +0000 (18:06 +0000)
STLINK-V3PWR is both a standalone debugger probe compatible with
STLINK-V3 and a source measurement unit (SMU).
Link: http://www.st.com/stlink-v3pwr
This code adds support for the debugger probe functionality.

Change-Id: Ib056e55722528f922c5574bb6fbf77e2f2b2b0c1
Signed-off-by: Laurent LEMELE <laurent.lemele@st.com>
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7755
Tested-by: jenkins
contrib/60-openocd.rules
doc/openocd.texi
src/jtag/drivers/stlink_usb.c
tcl/interface/stlink-dap.cfg
tcl/interface/stlink.cfg

index bb6f478a1e5ae86d0b2a36403d65dafc3c5324fc..fc35fb9b9e96c9e081ba8cd0c661f1187879ac51 100644 (file)
@@ -99,6 +99,8 @@ ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374e", MODE="660", GROUP="plugdev",
 ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374f", MODE="660", GROUP="plugdev", TAG+="uaccess"
 ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3753", MODE="660", GROUP="plugdev", TAG+="uaccess"
 ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3754", MODE="660", GROUP="plugdev", TAG+="uaccess"
+ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3755", MODE="660", GROUP="plugdev", TAG+="uaccess"
+ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3757", MODE="660", GROUP="plugdev", TAG+="uaccess"
 
 # Cypress SuperSpeed Explorer Kit
 ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="0007", MODE="660", GROUP="plugdev", TAG+="uaccess"
index d99917e0d69c98b05071de78db487a47b1072473..12a8ca56dfb6e90296aa64fe99de0e387d92d2f3 100644 (file)
@@ -463,6 +463,12 @@ They only work with STMicroelectronics chips, notably STM32 and STM8.
 @item @b{STLINK-V3}
 @* This is available standalone and as part of some kits.
 @* Link: @url{http://www.st.com/stlink-v3}
+@item @b{STLINK-V3PWR}
+@* This is available standalone.
+Beside the debugger functionality, the probe includes a SMU (source
+measurement unit) aimed at analyzing power consumption during code
+execution. The SMU is not supported by OpenOCD.
+@* Link: @url{http://www.st.com/stlink-v3pwr}
 @end itemize
 
 For info the original ST-LINK enumerates using the mass storage usb class; however,
@@ -3184,7 +3190,7 @@ passed as is to the underlying adapter layout handler.
 @anchor{st_link_dap_interface}
 @deffn {Interface Driver} {st-link}
 This is a driver that supports STMicroelectronics adapters ST-LINK/V2
-(from firmware V2J24) and STLINK-V3, thanks to a new API that provides
+(from firmware V2J24), STLINK-V3 and STLINK-V3PWR, thanks to a new API that provides
 directly access the arm ADIv5 DAP.
 
 The new API provide access to multiple AP on the same DAP, but the
index ee629542ba7f3f153f3aaa11143040a4c73370c3..2c5b63dd6e1f49b9faf4432fe23fcc19db54f324 100644 (file)
@@ -84,6 +84,8 @@
 #define STLINK_V3S_PID          (0x374F)
 #define STLINK_V3_2VCP_PID      (0x3753)
 #define STLINK_V3E_NO_MSD_PID   (0x3754)
+#define STLINK_V3P_USBLOADER_PID (0x3755)
+#define STLINK_V3P_PID           (0x3757)
 
 /*
  * ST-Link/V1, ST-Link/V2 and ST-Link/V2.1 are full-speed USB devices and
@@ -1297,8 +1299,8 @@ static int stlink_usb_version(void *handle)
                break;
        }
 
-       /* STLINK-V3 requires a specific command */
-       if (v == 3 && x == 0 && y == 0) {
+       /* STLINK-V3 & STLINK-V3P require a specific command */
+       if (v >= 3 && x == 0 && y == 0) {
                stlink_usb_init_buffer(handle, h->rx_ep, 16);
 
                h->cmdbuf[h->cmdidx++] = STLINK_APIV3_GET_VERSION_EX;
@@ -1414,6 +1416,41 @@ static int stlink_usb_version(void *handle)
                if (h->version.jtag >= 6)
                        flags |= STLINK_F_HAS_RW8_512BYTES;
 
+               break;
+       case 4:
+               /* STLINK-V3P use api-v3 */
+               h->version.jtag_api = STLINK_JTAG_API_V3;
+
+               /* STLINK-V3P is a superset of ST-LINK/V3 */
+
+               /* API for trace */
+               /* API for target voltage */
+               flags |= STLINK_F_HAS_TRACE;
+
+               /* preferred API to get last R/W status */
+               flags |= STLINK_F_HAS_GETLASTRWSTATUS2;
+
+               /* API to access DAP registers */
+               flags |= STLINK_F_HAS_DAP_REG;
+
+               /* API to read/write memory at 16 bit */
+               /* API to write memory without address increment */
+               flags |= STLINK_F_HAS_MEM_16BIT;
+
+               /* API required to init AP before any AP access */
+               flags |= STLINK_F_HAS_AP_INIT;
+
+               /* API required to return proper error code on close AP */
+               flags |= STLINK_F_FIX_CLOSE_AP;
+
+               /* Banked regs (DPv1 & DPv2) support */
+               /* API to read memory without address increment */
+               /* Memory R/W supports CSW */
+               flags |= STLINK_F_HAS_DPBANKSEL;
+
+               /* 8bit read/write max packet size 512 bytes */
+               flags |= STLINK_F_HAS_RW8_512BYTES;
+
                break;
        default:
                break;
@@ -3402,6 +3439,8 @@ static int stlink_usb_usb_open(void *handle, struct hl_interface_param_s *param)
                        case STLINK_V3S_PID:
                        case STLINK_V3_2VCP_PID:
                        case STLINK_V3E_NO_MSD_PID:
+                       case STLINK_V3P_USBLOADER_PID:
+                       case STLINK_V3P_PID:
                                h->version.stlink = 3;
                                h->tx_ep = STLINK_V2_1_TX_EP;
                                h->trace_ep = STLINK_V2_1_TRACE_EP;
@@ -3820,7 +3859,7 @@ static int stlink_config_trace(void *handle, bool enabled,
                return ERROR_FAIL;
        }
 
-       unsigned int max_trace_freq = (h->version.stlink == 3) ?
+       unsigned int max_trace_freq = (h->version.stlink >= 3) ?
                        STLINK_V3_TRACE_MAX_HZ : STLINK_TRACE_MAX_HZ;
 
        /* Only concern ourselves with the frequency if the STlink is processing it. */
index 5c24cbdab7083e30a67234b0f2325b834c6d1a34..99c81c180c2ef01ec5da4337149d362ee410f5bb 100644 (file)
@@ -11,7 +11,7 @@
 #
 
 adapter driver st-link
-st-link vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754
+st-link vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754 0x0483 0x3755 0x0483 0x3757
 
 # transport select dapdirect_jtag
 # transport select dapdirect_swd
index e4906b74ed96d6034f4f6d4bf2f673645c55c3a5..8578bf2199fbd9acfb476e1d2b38124a47226c9e 100644 (file)
@@ -8,7 +8,7 @@
 adapter driver hla
 hla_layout stlink
 hla_device_desc "ST-LINK"
-hla_vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754
+hla_vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754 0x0483 0x3755 0x0483 0x3757
 
 # Optionally specify the serial number of ST-LINK/V2 usb device.  ST-LINK/V2
 # devices seem to have serial numbers with unreadable characters.  ST-LINK/V2

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)