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/+/9608
-- gerrit commit edb68557e0172c9a823e153d15ae42da36c6188d Author: Marc Schink <[email protected]> Date: Mon Apr 27 07:55:19 2026 +0200 adapter: Implement USB product name handling Multiple adapter drivers currently implement their own 'device_desc' commands, leading to duplicated code. Move this functionality into the adapter core, similar to how device serial handling is implemented. Additionally, rename the command from 'device_desc' to 'product_name' to more accurately describe its purpose and align with what it actually does. Driver specific changes will follow in a separate patch series. Change-Id: If4ef83e9e47e91c9b41dd98c49c074fcdd4ec497 Signed-off-by: Marc Schink <[email protected]> diff --git a/doc/openocd.texi b/doc/openocd.texi index 2ea23f5302..1b77f0db20 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2514,6 +2514,11 @@ The USB bus topology can be queried with the command @emph{lsusb -t} or @emph{dm This command is only available if your libusb1 is at least version 1.0.16. @end deffn +@deffn {Config Command} {adapter usb product_name} name +Specifies the USB product name (the @emph{iProduct} string) of the adapter to use. +If this is not set, the product name is not used during device selection. +@end deffn + @deffn {Config Command} {adapter serial} serial_string Specifies the @var{serial_string} of the adapter to use. If this command is not specified, serial strings are not checked. diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index b17331f882..1a3c50a2f6 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -45,6 +45,7 @@ static struct { // vid = pid = 0 marks the end of the list. uint16_t usb_vids[MAX_USB_IDS + 1]; uint16_t usb_pids[MAX_USB_IDS + 1]; + char *product_name; char *serial; enum adapter_clk_mode clock_mode; int speed_khz; @@ -201,6 +202,7 @@ int adapter_quit(void) free(adapter_config.serial); free(adapter_config.usb_location); + free(adapter_config.product_name); struct jtag_tap *t = jtag_all_taps(); while (t) { @@ -345,6 +347,11 @@ const char *adapter_usb_get_location(void) return adapter_config.usb_location; } +const char *adapter_usb_get_product_name(void) +{ + return adapter_config.product_name; +} + bool adapter_usb_location_equal(uint8_t dev_bus, uint8_t *port_path, size_t path_len) { size_t path_step, string_length; @@ -1145,6 +1152,17 @@ COMMAND_HANDLER(handle_usb_vid_pid_command) return ERROR_OK; } +COMMAND_HANDLER(handle_usb_product_name_command) +{ + if (CMD_ARGC != 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + free(adapter_config.product_name); + adapter_config.product_name = strdup(CMD_ARGV[0]); + + return ERROR_OK; +} + static const struct command_registration adapter_usb_command_handlers[] = { { .name = "vid_pid", @@ -1153,6 +1171,13 @@ static const struct command_registration adapter_usb_command_handlers[] = { .help = "set the USB VID and PID of the USB device", .usage = "(vid pid)*", }, + { + .name = "product_name", + .handler = &handle_usb_product_name_command, + .mode = COMMAND_CONFIG, + .help = "set the USB product name of the USB device", + .usage = "(vid pid)*", + }, #ifdef HAVE_LIBUSB_GET_PORT_NUMBERS { .name = "location", diff --git a/src/jtag/adapter.h b/src/jtag/adapter.h index 4254ae96dc..c22ac53fe1 100644 --- a/src/jtag/adapter.h +++ b/src/jtag/adapter.h @@ -92,6 +92,9 @@ bool is_adapter_initialized(void); /** @returns USB location string set with command 'adapter usb location' */ const char *adapter_usb_get_location(void); +/** @returns USB product name set with command 'adapter usb product_name' */ +const char *adapter_usb_get_product_name(void); + /** @returns true if USB location string is "<dev_bus>-<port_path[0]>[.<port_path[1]>[...]]" */ bool adapter_usb_location_equal(uint8_t dev_bus, uint8_t *port_path, size_t path_len); --
