diff --git a/src/jtag/drivers/ft2232.c b/src/jtag/drivers/ft2232.c index 2ac410a..207166a 100644 --- a/src/jtag/drivers/ft2232.c +++ b/src/jtag/drivers/ft2232.c @@ -153,6 +153,7 @@ static int ft2232_stableclocks(int num_cycles, struct jtag_command* cmd); static char * ft2232_device_desc_A = NULL; static char* ft2232_device_desc = NULL; static char* ft2232_serial = NULL; +static uint8_t ft2232_index = 0; static uint8_t ft2232_latency = 2; static unsigned ft2232_max_tck = FTDI_2232C_MAX_TCK; @@ -2239,8 +2240,8 @@ static int ft2232_init_libftdi(uint16_t vid, uint16_t pid, int more, int* try_mo } /* context, vendor id, product id */ - if (ftdi_usb_open_desc(&ftdic, vid, pid, ft2232_device_desc, - ft2232_serial) < 0) + if (ftdi_usb_open_desc_index(&ftdic, vid, pid, ft2232_device_desc, + ft2232_serial, ft2232_index) < 0) { if (more) LOG_WARNING("unable to open ftdi device (trying more): %s", @@ -3173,6 +3174,23 @@ COMMAND_HANDLER(ft2232_handle_serial_command) return ERROR_OK; } +COMMAND_HANDLER(ft2232_handle_index_command) +{ + if (CMD_ARGC == 1) + { + ft2232_index = atoi(CMD_ARGV[0]); +#if BUILD_FT2232_FTD2XX == 1 + LOG_ERROR("ft2232_index available only for libftdi build, ignoring"); +#endif + } + else + { + LOG_ERROR("expected exactly one argument to ft2232_index "); + } + + return ERROR_OK; +} + COMMAND_HANDLER(ft2232_handle_layout_command) { if (CMD_ARGC != 1) { @@ -4343,6 +4361,13 @@ static const struct command_registration ft2232_command_handlers[] = { .usage = "(vid pid)* ", }, { + .name = "ft2232_index", + .handler = &ft2232_handle_index_command, + .mode = COMMAND_CONFIG, + .help = "set the index of the FTDI FT2232 device", + .usage = "index_number", + }, + { .name = "ft2232_latency", .handler = &ft2232_handle_latency_command, .mode = COMMAND_CONFIG,