This is an automated email from Gerrit.

"zapb <[email protected]>" just uploaded a new patch set to Gerrit, which you can 
find at https://review.openocd.org/c/openocd/+/9594

-- gerrit

commit fb530dbb83361a0f093b82007421fe3e26911954
Author: Marc Schink <[email protected]>
Date:   Thu Apr 23 21:18:30 2026 +0200

    adapter/cmsis-dap: Delegate USB VID/PID parsing to adapter core
    
    Use the USB VID/PIDs provided by the adapter core instead of parsing
    them in the driver code.
    
    Keep the legacy 'cmsis_dap_vid_pid' command for backwards compatibility,
    but mark it as deprecated.
    
    Change-Id: I044c8b49a0715408595723d3a8c7a9b6c9318c62
    Signed-off-by: Marc Schink <[email protected]>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index ebd31ae685..be54d600e0 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -2618,15 +2618,6 @@ ch347 device_desc "EasyDevKit"
 ARM CMSIS-DAP compliant based adapter v1 (USB HID based)
 or v2 (USB bulk or TCP/IP).
 
-@deffn {Config Command} {cmsis-dap vid_pid} [vid pid]+
-The vendor ID and product ID of the CMSIS-DAP device. If not specified
-the driver will attempt to auto detect the CMSIS-DAP device.
-Currently, up to eight [@var{vid}, @var{pid}] pairs may be given, e.g.
-@example
-cmsis-dap vid_pid 0xc251 0xf001 0x0d28 0x0204
-@end example
-@end deffn
-
 @deffn {Config Command} {cmsis-dap backend} 
[@option{auto}|@option{usb_bulk}|@option{hid}|@option{tcp}]
 Specifies how to communicate with the adapter:
 
diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c
index 9f60a5ede4..759a6738d6 100644
--- a/src/jtag/drivers/cmsis_dap.c
+++ b/src/jtag/drivers/cmsis_dap.c
@@ -78,10 +78,6 @@ static const struct cmsis_dap_backend *const 
cmsis_dap_backends[] = {
  * PID 0x0204: MBED CMSIS-DAP
  */
 
-#define MAX_USB_IDS 8
-/* vid = pid = 0 marks the end of the list */
-static uint16_t cmsis_dap_vid[MAX_USB_IDS + 1] = { 0 };
-static uint16_t cmsis_dap_pid[MAX_USB_IDS + 1] = { 0 };
 static int cmsis_dap_backend = -1;
 static bool swd_mode;
 static bool cmsis_dap_quirk_mode;  /* enable expensive workarounds */
@@ -283,7 +279,8 @@ static int cmsis_dap_open(void)
                /* Use forced backend */
                backend = cmsis_dap_backends[cmsis_dap_backend];
                if (backend->open)
-                       retval = backend->open(dap, cmsis_dap_vid, 
cmsis_dap_pid, adapter_get_required_serial());
+                       retval = backend->open(dap, adapter_usb_get_vids(),
+                               adapter_usb_get_pids(), 
adapter_get_required_serial());
                else
                        LOG_ERROR("Requested CMSIS-DAP backend is disabled by 
configure");
 
@@ -294,7 +291,7 @@ static int cmsis_dap_open(void)
                        if (!backend->open)
                                continue;
 
-                       retval = backend->open(dap, cmsis_dap_vid, 
cmsis_dap_pid, adapter_get_required_serial());
+                       retval = backend->open(dap, adapter_usb_get_vids(), 
adapter_usb_get_pids(), adapter_get_required_serial());
                        if (retval == ERROR_OK)
                                break;
                }
@@ -2184,36 +2181,6 @@ COMMAND_HANDLER(cmsis_dap_handle_cmd_command)
        return ERROR_OK;
 }
 
-COMMAND_HANDLER(cmsis_dap_handle_vid_pid_command)
-{
-       if (CMD_ARGC > MAX_USB_IDS * 2) {
-               LOG_WARNING("ignoring extra IDs in cmsis-dap vid_pid "
-                       "(maximum is %d pairs)", MAX_USB_IDS);
-               CMD_ARGC = MAX_USB_IDS * 2;
-       }
-       if (CMD_ARGC < 2 || (CMD_ARGC & 1)) {
-               LOG_WARNING("incomplete cmsis-dap vid_pid configuration 
directive");
-               if (CMD_ARGC < 2)
-                       return ERROR_COMMAND_SYNTAX_ERROR;
-               /* remove the incomplete trailing id */
-               CMD_ARGC -= 1;
-       }
-
-       unsigned int i;
-       for (i = 0; i < CMD_ARGC; i += 2) {
-               COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i], cmsis_dap_vid[i >> 1]);
-               COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], cmsis_dap_pid[i >> 
1]);
-       }
-
-       /*
-        * Explicitly terminate, in case there are multiples instances of
-        * cmsis_dap_vid_pid.
-        */
-       cmsis_dap_vid[i >> 1] = cmsis_dap_pid[i >> 1] = 0;
-
-       return ERROR_OK;
-}
-
 COMMAND_HANDLER(cmsis_dap_handle_backend_command)
 {
        if (CMD_ARGC != 1)
@@ -2272,13 +2239,6 @@ static const struct command_registration 
cmsis_dap_subcommand_handlers[] = {
                .usage = "",
                .help = "issue cmsis-dap command",
        },
-       {
-               .name = "vid_pid",
-               .handler = &cmsis_dap_handle_vid_pid_command,
-               .mode = COMMAND_CONFIG,
-               .help = "the vendor ID and product ID of the CMSIS-DAP device",
-               .usage = "(vid pid)*",
-       },
        {
                .name = "backend",
                .handler = &cmsis_dap_handle_backend_command,
diff --git a/src/jtag/drivers/cmsis_dap.h b/src/jtag/drivers/cmsis_dap.h
index 880fc33502..4272ab4831 100644
--- a/src/jtag/drivers/cmsis_dap.h
+++ b/src/jtag/drivers/cmsis_dap.h
@@ -65,7 +65,7 @@ enum cmsis_dap_blocking {
 
 struct cmsis_dap_backend {
        const char *name;
-       int (*open)(struct cmsis_dap *dap, uint16_t vids[], uint16_t pids[], 
const char *serial);
+       int (*open)(struct cmsis_dap *dap, const uint16_t vids[], const 
uint16_t pids[], const char *serial);
        void (*close)(struct cmsis_dap *dap);
        int (*read)(struct cmsis_dap *dap, int transfer_timeout_ms,
                                enum cmsis_dap_blocking blocking);
diff --git a/src/jtag/drivers/cmsis_dap_tcp.c b/src/jtag/drivers/cmsis_dap_tcp.c
index 7894550fe2..0c86f94564 100644
--- a/src/jtag/drivers/cmsis_dap_tcp.c
+++ b/src/jtag/drivers/cmsis_dap_tcp.c
@@ -113,8 +113,8 @@ static int cmsis_dap_tcp_alloc(struct cmsis_dap *dap, 
unsigned int pkt_sz);
 static void cmsis_dap_tcp_free(struct cmsis_dap *dap);
 
 static int cmsis_dap_tcp_open(struct cmsis_dap *dap,
-               uint16_t vids[] __attribute__((unused)),
-               uint16_t pids[] __attribute__((unused)),
+               const uint16_t vids[] __attribute__((unused)),
+               const uint16_t pids[] __attribute__((unused)),
                const char *serial __attribute__((unused)))
 {
        // Skip the open if the user has not provided a hostname.
diff --git a/src/jtag/drivers/cmsis_dap_usb_bulk.c 
b/src/jtag/drivers/cmsis_dap_usb_bulk.c
index d34d4e31c1..ac684f49b5 100644
--- a/src/jtag/drivers/cmsis_dap_usb_bulk.c
+++ b/src/jtag/drivers/cmsis_dap_usb_bulk.c
@@ -63,7 +63,7 @@ static void cmsis_dap_usb_close(struct cmsis_dap *dap);
 static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz);
 static void cmsis_dap_usb_free(struct cmsis_dap *dap);
 
-static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t 
pids[], const char *serial)
+static int cmsis_dap_usb_open(struct cmsis_dap *dap, const uint16_t vids[], 
const uint16_t pids[], const char *serial)
 {
        int err;
        struct libusb_context *ctx;
diff --git a/src/jtag/drivers/cmsis_dap_usb_hid.c 
b/src/jtag/drivers/cmsis_dap_usb_hid.c
index a4058ec803..8d4de68857 100644
--- a/src/jtag/drivers/cmsis_dap_usb_hid.c
+++ b/src/jtag/drivers/cmsis_dap_usb_hid.c
@@ -68,7 +68,7 @@ static void cmsis_dap_hid_close(struct cmsis_dap *dap);
 static int cmsis_dap_hid_alloc(struct cmsis_dap *dap, unsigned int pkt_sz);
 static void cmsis_dap_hid_free(struct cmsis_dap *dap);
 
-static int cmsis_dap_hid_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t 
pids[], const char *serial)
+static int cmsis_dap_hid_open(struct cmsis_dap *dap, const uint16_t vids[], 
const uint16_t pids[], const char *serial)
 {
        hid_device *dev = NULL;
        int i;
diff --git a/src/jtag/startup.tcl b/src/jtag/startup.tcl
index 8264c0db87..24a5bdda78 100644
--- a/src/jtag/startup.tcl
+++ b/src/jtag/startup.tcl
@@ -1143,8 +1143,8 @@ proc "cmsis_dap_backend" {backend} {
 
 lappend _telnet_autocomplete_skip "cmsis_dap_vid_pid"
 proc "cmsis_dap_vid_pid" {args} {
-       echo "DEPRECATED! use 'cmsis-dap vid_pid', not 'cmsis_dap_vid_pid'"
-       eval cmsis-dap vid_pid $args
+       echo "DEPRECATED! use 'adapter usb vid_pid', not 'cmsis_dap_vid_pid'"
+       eval adapter usb vid_pid $args
 }
 
 lappend _telnet_autocomplete_skip "cmsis_dap_usb"

-- 

Reply via email to