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/+/9592
-- gerrit commit 58865dfac6b5059b231e990b284bdd050dadc991 Author: Marc Schink <[email protected]> Date: Thu Apr 23 21:02:28 2026 +0200 adapter/ft232r: 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 'ft232r_vid_pid' command for backwards compatibility, but mark it as deprecated. Change-Id: I6234207ac3840626954411aa49a9a3bed040323d Signed-off-by: Marc Schink <[email protected]> diff --git a/doc/openocd.texi b/doc/openocd.texi index e7f02c4123..5576be4740 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2911,11 +2911,6 @@ FT232R These interfaces have several commands, used to configure the driver before initializing the JTAG scan chain: -@deffn {Config Command} {ft232r vid_pid} @var{vid} @var{pid} -The vendor ID and product ID of the adapter. If not specified, default -0x0403:0x6001 is used. -@end deffn - @deffn {Config Command} {ft232r jtag_nums} @var{tck} @var{tms} @var{tdi} @var{tdo} Set four JTAG GPIO numbers at once. If not specified, default 0 3 1 2 or TXD CTS RXD RTS is used. diff --git a/src/jtag/drivers/ft232r.c b/src/jtag/drivers/ft232r.c index 5bd934c386..e668909a5f 100644 --- a/src/jtag/drivers/ft232r.c +++ b/src/jtag/drivers/ft232r.c @@ -58,8 +58,10 @@ #define FT232R_BUF_SIZE_EXTRA 4096 -static uint16_t ft232r_vid = 0x0403; /* FTDI */ -static uint16_t ft232r_pid = 0x6001; /* FT232R */ +// Default VID/PID pair for FTDI FT232R. +static uint16_t ft232r_vids[] = {0x0403, 0}; +static uint16_t ft232r_pids[] = {0x6001, 0}; + static struct libusb_device_handle *adapter; static uint8_t *ft232r_output; @@ -244,12 +246,24 @@ static int ft232r_speed(int divisor) static int ft232r_init(void) { - uint16_t avids[] = {ft232r_vid, 0}; - uint16_t apids[] = {ft232r_pid, 0}; - if (jtag_libusb_open(avids, apids, NULL, &adapter, NULL)) { + const uint16_t *vids = ft232r_vids; + const uint16_t *pids = ft232r_pids; + + if (adapter_usb_get_vids()[0] != 0) { + vids = adapter_usb_get_vids(); + pids = adapter_usb_get_pids(); + } + + if (jtag_libusb_open(vids, pids, NULL, &adapter, NULL)) { + char usb_vid_pid_str[256] = {0}; + for (unsigned int i = 0; vids[i] != 0; i++) + snprintf(usb_vid_pid_str + strlen(usb_vid_pid_str), + sizeof(usb_vid_pid_str) - strlen(usb_vid_pid_str), + "%04x:%04x ", vids[i], pids[i]); + const char *ft232r_serial_desc = adapter_get_required_serial(); - LOG_ERROR("ft232r not found: vid=%04x, pid=%04x, serial=%s\n", - ft232r_vid, ft232r_pid, (!ft232r_serial_desc) ? "[any]" : ft232r_serial_desc); + LOG_ERROR("ft232r not found: serial=%s, vid/pid=%s\n", + (!ft232r_serial_desc) ? "[any]" : ft232r_serial_desc, usb_vid_pid_str); return ERROR_JTAG_INIT_FAILED; } @@ -385,22 +399,6 @@ static int ft232r_bit_name_to_number(const char *name) return -1; } -COMMAND_HANDLER(ft232r_handle_vid_pid_command) -{ - if (CMD_ARGC > 2) { - LOG_WARNING("ignoring extra IDs in ft232r_vid_pid " - "(maximum is 1 pair)"); - CMD_ARGC = 2; - } - if (CMD_ARGC == 2) { - COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], ft232r_vid); - COMMAND_PARSE_NUMBER(u16, CMD_ARGV[1], ft232r_pid); - } else - LOG_WARNING("incomplete ft232r_vid_pid configuration"); - - return ERROR_OK; -} - COMMAND_HANDLER(ft232r_handle_jtag_nums_command) { if (CMD_ARGC == 4) { @@ -541,13 +539,6 @@ COMMAND_HANDLER(ft232r_handle_restore_serial_command) } static const struct command_registration ft232r_subcommand_handlers[] = { - { - .name = "vid_pid", - .handler = ft232r_handle_vid_pid_command, - .mode = COMMAND_CONFIG, - .help = "USB VID and PID of the adapter", - .usage = "vid pid", - }, { .name = "jtag_nums", .handler = ft232r_handle_jtag_nums_command, diff --git a/src/jtag/startup.tcl b/src/jtag/startup.tcl index 03a01e6a2b..8264c0db87 100644 --- a/src/jtag/startup.tcl +++ b/src/jtag/startup.tcl @@ -840,8 +840,8 @@ proc ft232r_serial_desc args { lappend _telnet_autocomplete_skip ft232r_vid_pid proc ft232r_vid_pid args { - echo "DEPRECATED! use 'ft232r vid_pid' not 'ft232r_vid_pid'" - eval ft232r vid_pid $args + echo "DEPRECATED! use 'adapter usb vid_pid' not 'ft232r_vid_pid'" + eval adapter usb vid_pid $args } lappend _telnet_autocomplete_skip ft232r_jtag_nums diff --git a/tcl/interface/ft232r/radiona_ulx3s.cfg b/tcl/interface/ft232r/radiona_ulx3s.cfg index 3fc3d7105e..54a82f1590 100644 --- a/tcl/interface/ft232r/radiona_ulx3s.cfg +++ b/tcl/interface/ft232r/radiona_ulx3s.cfg @@ -7,7 +7,7 @@ adapter driver ft232r adapter speed 1000 -ft232r vid_pid 0x0403 0x6015 +adapter usb vid_pid 0x0403 0x6015 ft232r tck_num DSR ft232r tms_num DCD ft232r tdi_num RI --
