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/+/9598

-- gerrit

commit 4a9a6188a57423c16cdafd60f71ffd21dd14627f
Author: Marc Schink <[email protected]>
Date:   Sun Apr 26 10:30:52 2026 +0200

    adapter/usb-blaster: 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 'usb_blaster_vid_pid' command for backwards compatibility,
    but mark it as deprecated.
    
    Change-Id: I3f16e50100c9ce80fa5d06884631fb4575fce465
    Signed-off-by: Marc Schink <[email protected]>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index 5b33328525..21ba7c2c98 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -2993,22 +2993,25 @@ remote_bitbang host mysocket
 
 @deffn {Interface Driver} {usb_blaster}
 USB JTAG/USB-Blaster compatibles over one of the userspace libraries
-for FTDI chips. These interfaces have several commands, used to
-configure the driver before initializing the JTAG scan chain:
+for FTDI chips.
 
-@deffn {Config Command} {usb_blaster vid_pid} vid pid
-The vendor ID and product ID of the FTDI FT245 device. If not specified,
-default values are used.
-Currently, only one @var{vid}, @var{pid} pair may be given, e.g. for
-Altera USB-Blaster (default):
+Use @command{adapter usb vid_pid} to specify the vendor and product ID of the
+FT256 device. If not specified, default values are used.
+
+For example, Altera USB-Blaster (default):
 @example
-usb_blaster vid_pid 0x09FB 0x6001
+adapter usb vid_pid 0x09FB 0x6001
 @end example
 The following VID/PID is for Kolja Waschk's USB JTAG:
 @example
-usb_blaster vid_pid 0x16C0 0x06AD
+adapter usb vid_pid 0x16C0 0x06AD
 @end example
-@end deffn
+
+Note that the second VID/PID pair passed to @command{adapter usb vid_pid} is
+used to detect uninitialized devices.
+
+This driver has several commands, used for configuration before initializing 
the
+JTAG scan chain:
 
 @deffn {Command} {usb_blaster pin} (@option{pin6}|@option{pin8}) 
(@option{0}|@option{1}|@option{s}|@option{t})
 Sets the state or function of the unused GPIO pins on USB-Blasters
diff --git a/src/jtag/drivers/usb_blaster/usb_blaster.c 
b/src/jtag/drivers/usb_blaster/usb_blaster.c
index 81344664e2..b952732779 100644
--- a/src/jtag/drivers/usb_blaster/usb_blaster.c
+++ b/src/jtag/drivers/usb_blaster/usb_blaster.c
@@ -63,6 +63,7 @@
 #endif
 
 /* project specific includes */
+#include <jtag/adapter.h>
 #include <jtag/interface.h>
 #include <jtag/commands.h>
 #include <helper/time_support.h>
@@ -825,9 +826,9 @@ static int ublast_execute_queue(struct jtag_command 
*cmd_queue)
  */
 static int ublast_init(void)
 {
-       int ret, i;
+       int ret;
 
-       for (i = 0; lowlevel_drivers_map[i].name; i++) {
+       for (unsigned int i = 0; lowlevel_drivers_map[i].name; i++) {
                if (info.lowlevel_name) {
                        if (!strcmp(lowlevel_drivers_map[i].name, 
info.lowlevel_name)) {
                                info.drv = 
lowlevel_drivers_map[i].drv_register();
@@ -853,6 +854,24 @@ static int ublast_init(void)
                return ERROR_JTAG_DEVICE_ERROR;
        }
 
+       unsigned int num_vid_pid_pairs = 0;
+
+       for (unsigned int i = 0; adapter_usb_get_vids()[i]; i++)
+               num_vid_pid_pairs++;
+
+       if (num_vid_pid_pairs > 0) {
+               info.ublast_vid = adapter_usb_get_vids()[0];
+               info.ublast_pid = adapter_usb_get_pids()[0];
+       }
+
+       if (num_vid_pid_pairs > 1) {
+               info.ublast_vid_uninit = adapter_usb_get_vids()[1];
+               info.ublast_pid_uninit = adapter_usb_get_pids()[1];
+       }
+
+       if (num_vid_pid_pairs > 2)
+               LOG_WARNING("ignoring extra IDs in adapter usb vid_pid (maximum 
is 2 pairs)");
+
        /*
         * Register the lowlevel driver
         */
@@ -893,31 +912,6 @@ static int ublast_quit(void)
        return info.drv->close(info.drv);
 }
 
-COMMAND_HANDLER(ublast_handle_vid_pid_command)
-{
-       if (CMD_ARGC > 4) {
-               LOG_WARNING("ignoring extra IDs in ublast_vid_pid "
-                                       "(maximum is 2 pairs)");
-               CMD_ARGC = 4;
-       }
-
-       if (CMD_ARGC >= 2) {
-               COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], info.ublast_vid);
-               COMMAND_PARSE_NUMBER(u16, CMD_ARGV[1], info.ublast_pid);
-       } else {
-               LOG_WARNING("incomplete ublast_vid_pid configuration");
-       }
-
-       if (CMD_ARGC == 4) {
-               COMMAND_PARSE_NUMBER(u16, CMD_ARGV[2], info.ublast_vid_uninit);
-               COMMAND_PARSE_NUMBER(u16, CMD_ARGV[3], info.ublast_pid_uninit);
-       } else {
-               LOG_WARNING("incomplete ublast_vid_pid configuration");
-       }
-
-       return ERROR_OK;
-}
-
 COMMAND_HANDLER(ublast_handle_pin_command)
 {
        uint8_t out_value;
@@ -1006,15 +1000,6 @@ COMMAND_HANDLER(ublast_firmware_command)
 
 
 static const struct command_registration ublast_subcommand_handlers[] = {
-       {
-               .name = "vid_pid",
-               .handler = ublast_handle_vid_pid_command,
-               .mode = COMMAND_CONFIG,
-               .help = "the vendor ID and product ID of the USB-Blaster and "
-                       "vendor ID and product ID of the uninitialized device "
-                       "for USB-Blaster II",
-               .usage = "vid pid vid_uninit pid_uninit",
-       },
        {
                .name = "lowlevel_driver",
                .handler = ublast_handle_lowlevel_drv_command,
diff --git a/src/jtag/startup.tcl b/src/jtag/startup.tcl
index 482eb86da7..247058436a 100644
--- a/src/jtag/startup.tcl
+++ b/src/jtag/startup.tcl
@@ -817,8 +817,8 @@ proc usb_blaster_device_desc args {
 
 lappend _telnet_autocomplete_skip usb_blaster_vid_pid
 proc usb_blaster_vid_pid args {
-       echo "DEPRECATED! use 'usb_blaster vid_pid' not 'usb_blaster_vid_pid'"
-       eval usb_blaster vid_pid $args
+       echo "DEPRECATED! use 'adapter usb vid_pid' not 'usb_blaster_vid_pid'"
+       eval adapter usb vid_pid $args
 }
 
 lappend _telnet_autocomplete_skip usb_blaster_lowlevel_driver
diff --git a/tcl/board/altera_sockit.cfg b/tcl/board/altera_sockit.cfg
index bbd87d6466..3df6f87429 100644
--- a/tcl/board/altera_sockit.cfg
+++ b/tcl/board/altera_sockit.cfg
@@ -14,7 +14,7 @@ adapter driver usb_blaster
 source [find target/altera_fpgasoc.cfg]
 
 # If the USB Blaster II were supported, these settings would be needed
-#usb_blaster vid_pid 0x09fb 0x6810
+#adapter usb vid_pid 0x09fb 0x6810
 #usb_blaster device_desc "USB-Blaster II"
 
 adapter speed 100
diff --git a/tcl/interface/altera-usb-blaster.cfg 
b/tcl/interface/altera-usb-blaster.cfg
index cc6057b510..c9a56b268a 100644
--- a/tcl/interface/altera-usb-blaster.cfg
+++ b/tcl/interface/altera-usb-blaster.cfg
@@ -9,5 +9,5 @@
 adapter driver usb_blaster
 usb_blaster lowlevel_driver ftdi
 # These are already the defaults.
-# usb_blaster vid_pid 0x09FB 0x6001
+# adapter usb vid_pid 0x09FB 0x6001
 # usb_blaster device_desc "USB-Blaster"
diff --git a/tcl/interface/altera-usb-blaster2.cfg 
b/tcl/interface/altera-usb-blaster2.cfg
index 93f9809b03..95927676bb 100644
--- a/tcl/interface/altera-usb-blaster2.cfg
+++ b/tcl/interface/altera-usb-blaster2.cfg
@@ -5,6 +5,6 @@
 #
 
 adapter driver usb_blaster
-usb_blaster vid_pid 0x09fb 0x6010 0x09fb 0x6810
+adapter usb vid_pid 0x09fb 0x6010 0x09fb 0x6810
 usb_blaster lowlevel_driver ublast2
 usb_blaster firmware /path/to/quartus/blaster_6810.hex
diff --git a/tcl/interface/usb-jtag.cfg b/tcl/interface/usb-jtag.cfg
index 039c748b37..c7f3d60c24 100644
--- a/tcl/interface/usb-jtag.cfg
+++ b/tcl/interface/usb-jtag.cfg
@@ -32,7 +32,7 @@
 # driver but ixo-usb-jtag requires the ftdi driver.
 
 adapter driver usb_blaster
-usb_blaster vid_pid 0x16C0 0x06AD
+adapter usb vid_pid 0x16C0 0x06AD
 usb_blaster device_desc "Van Ooijen Technische Informatica"
 # ixo-usb-jtag is only compatible with the ublast1 protocol implemented via the
 # ftdi modes, using ublast2 will cause openocd to hang.

-- 

Reply via email to