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

-- gerrit

commit a5d4f12d1cce220a4c150aaf3527c5e00c16675c
Author: Marc Schink <[email protected]>
Date:   Thu Apr 23 21:10:10 2026 +0200

    adapter/ch347: 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.
    
    Change-Id: I3736449fe3ece4bcda458169f6c78c922a31671e
    Signed-off-by: Marc Schink <[email protected]>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index 5576be4740..ebd31ae685 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -2604,15 +2604,6 @@ command @ref{adapter gpio, @command{adapter gpio led}}.
 
 This driver has these driver-specific command:
 
-@deffn {Config Command} {ch347 vid_pid} [vid pid]+
-The vendor ID and product ID of the CH347F or CH347T device in mode 3. If not 
specified
-the driver will use vendor ID 0x1a86 and product ID 0x55dd.
-Currently, up to four [@var{vid}, @var{pid}] pairs may be given, e.g.
-@example
-ch347 vid_pid 0x1a86 0x55dd 0x1a86 0x55de
-@end example
-@end deffn
-
 @deffn {Config Command} {ch347 device_desc} description
 If specified connect to a device which exactly has this product description
 string. If not specified the first found device with the correct vendor
diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c
index c031ceece2..31762eb475 100644
--- a/src/jtag/drivers/ch347.c
+++ b/src/jtag/drivers/ch347.c
@@ -255,8 +255,6 @@ static bool swd_mode;
 static uint16_t default_ch347_vids[] = {DEFAULT_VENDOR_ID, DEFAULT_VENDOR_ID, 
DEFAULT_VENDOR_ID, 0};
 static uint16_t default_ch347_pids[] = {DEFAULT_CH347T_PRODUCT_ID,
        DEFAULT_CH347F_PRODUCT_ID, DEFAULT_OTHER_PRODUCT_ID, 0};
-static uint16_t custom_ch347_vids[] = {0, 0, 0, 0};
-static uint16_t custom_ch347_pids[] = {0, 0, 0, 0};
 static char *ch347_device_desc;
 static uint8_t ch347_activity_led_gpio_pin = 0xFF;
 static bool ch347_activity_led_active_high;
@@ -1420,8 +1418,13 @@ static int ch347_execute_queue(struct jtag_command 
*cmd_queue)
  */
 static int ch347_open_device(void)
 {
-       const uint16_t *ch347_vids = custom_ch347_vids[0] != 0 ? 
custom_ch347_vids : default_ch347_vids;
-       const uint16_t *ch347_pids = custom_ch347_pids[0] != 0 ? 
custom_ch347_pids : default_ch347_pids;
+       const uint16_t *ch347_vids = default_ch347_vids;
+       const uint16_t *ch347_pids = default_ch347_pids;
+
+       if (adapter_usb_get_vids()[0] != 0) {
+               ch347_vids = adapter_usb_get_vids();
+               ch347_pids = adapter_usb_get_pids();
+       }
 
        int retval = jtag_libusb_open(ch347_vids, ch347_pids, 
ch347_device_desc, &ch347_handle, NULL);
        if (retval != ERROR_OK) {
@@ -1773,24 +1776,6 @@ static int ch347_speed_get_index(int khz, int *speed_idx)
        return ERROR_OK;
 }
 
-/**
- * @brief The command handler for setting the device usb vid/pid
- *
- * @return ERROR_OK at success; ERROR_COMMAND_SYNTAX_ERROR otherwise
- */
-COMMAND_HANDLER(ch347_handle_vid_pid_command)
-{
-       if (CMD_ARGC < 2)
-               return ERROR_COMMAND_SYNTAX_ERROR;
-
-       for (int i = 0; i < (int)(MIN(CMD_ARGC, 
ARRAY_SIZE(custom_ch347_pids))); i += 2) {
-               COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i], custom_ch347_vids[i / 
2]);
-               COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], custom_ch347_pids[i 
/ 2]);
-       }
-
-       return ERROR_OK;
-}
-
 /**
  * @brief The command handler for setting the device description that should 
be found
  *
@@ -1807,13 +1792,6 @@ COMMAND_HANDLER(ch347_handle_device_desc_command)
 }
 
 static const struct command_registration ch347_subcommand_handlers[] = {
-       {
-               .name = "vid_pid",
-               .handler = &ch347_handle_vid_pid_command,
-               .mode = COMMAND_CONFIG,
-               .help = "the vendor ID and product ID of the CH347 device",
-               .usage = "(vid pid)*",
-       },
        {
                .name = "device_desc",
                .handler = &ch347_handle_device_desc_command,
diff --git a/tcl/board/easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg 
b/tcl/board/easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg
index 76f1435beb..53a4098f0e 100644
--- a/tcl/board/easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg
+++ b/tcl/board/easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg
@@ -11,8 +11,8 @@
 adapter driver ch347
 
 # Identify the device
+adapter usb vid_pid 0x1a86 0x55dd
 ch347 device_desc "EasyDevKit"
-ch347 vid_pid 0x1a86 0x55dd
 
 # Configure activity LED
 # Note: The LED is active-low on GPIO4.

-- 

Reply via email to