This is an automated email from Gerrit. Oleksij Rempel ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4582
-- gerrit commit b7e07292d551ffebcf1a1121f456b1c0bcb7976e Author: Oleksij Rempel <[email protected]> Date: Fri Jun 29 10:52:44 2018 +0200 drivers: USB Blaster II: provide usb path filter support Change-Id: Ib36688f610b1deebc25dcdba9e4672c9ba6c039a Signed-off-by: Oleksij Rempel <[email protected]> diff --git a/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c b/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c index 3875ce1..5dc833c 100644 --- a/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c +++ b/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c @@ -186,7 +186,7 @@ static int ublast2_libusb_init(struct ublast_lowlevel *low) bool renumeration = false; int ret; - if (jtag_libusb_open(vids, pids, NULL, NULL, &temp) == ERROR_OK) { + if (jtag_libusb_open(vids, pids, NULL, low->usb_location, &temp) == ERROR_OK) { LOG_INFO("Altera USB-Blaster II (uninitialized) found"); LOG_INFO("Loading firmware..."); ret = load_usb_blaster_firmware(temp, low); @@ -200,13 +200,13 @@ static int ublast2_libusb_init(struct ublast_lowlevel *low) const uint16_t pids_renum[] = { low->ublast_pid, 0 }; if (renumeration == false) { - if (jtag_libusb_open(vids_renum, pids_renum, NULL, NULL, &low->libusb_dev) != ERROR_OK) { + if (jtag_libusb_open(vids_renum, pids_renum, NULL, low->usb_location, &low->libusb_dev) != ERROR_OK) { LOG_ERROR("Altera USB-Blaster II not found"); return ERROR_FAIL; } } else { int retry = 10; - while (jtag_libusb_open(vids_renum, pids_renum, NULL, NULL, &low->libusb_dev) != ERROR_OK && retry--) { + while (jtag_libusb_open(vids_renum, pids_renum, NULL, low->usb_location, &low->libusb_dev) != ERROR_OK && retry--) { usleep(1000000); LOG_INFO("Waiting for renumerate..."); } diff --git a/src/jtag/drivers/usb_blaster/ublast_access.h b/src/jtag/drivers/usb_blaster/ublast_access.h index 252f003..706f6f8 100644 --- a/src/jtag/drivers/usb_blaster/ublast_access.h +++ b/src/jtag/drivers/usb_blaster/ublast_access.h @@ -41,6 +41,7 @@ struct ublast_lowlevel { char *ublast_device_desc; struct jtag_libusb_device_handle *libusb_dev; char *firmware_path; + char *usb_location; int (*write)(struct ublast_lowlevel *low, uint8_t *buf, int size, uint32_t *bytes_written); diff --git a/src/jtag/drivers/usb_blaster/usb_blaster.c b/src/jtag/drivers/usb_blaster/usb_blaster.c index df9f2a1..e41030d 100644 --- a/src/jtag/drivers/usb_blaster/usb_blaster.c +++ b/src/jtag/drivers/usb_blaster/usb_blaster.c @@ -123,6 +123,7 @@ struct ublast_info { uint16_t ublast_vid_uninit, ublast_pid_uninit; int flags; char *firmware_path; + char *usb_location; }; /* @@ -874,6 +875,7 @@ static int ublast_init(void) info.drv->ublast_pid_uninit = info.ublast_pid_uninit; info.drv->ublast_device_desc = info.ublast_device_desc; info.drv->firmware_path = info.firmware_path; + info.drv->usb_location = info.usb_location; info.flags |= info.drv->flags; @@ -901,9 +903,17 @@ static int ublast_quit(void) { uint8_t byte0 = 0; unsigned int retlen; + int ret; ublast_buf_write(&byte0, 1, &retlen); - return info.drv->close(info.drv); + ret = info.drv->close(info.drv); + + free(info.firmware_path); + free(info.ublast_device_desc); + free(info.usb_location); + free(info.lowlevel_name); + + return ret; } COMMAND_HANDLER(ublast_handle_device_desc_command) @@ -1027,6 +1037,20 @@ COMMAND_HANDLER(ublast_firmware_command) return ERROR_OK; } +#ifdef HAVE_LIBUSB_GET_PORT_NUMBERS +COMMAND_HANDLER(ublast_handle_location_command) +{ + if (CMD_ARGC == 1) { + if (info.usb_location) + free(info.usb_location); + info.usb_location = strdup(CMD_ARGV[0]); + } else { + return ERROR_COMMAND_SYNTAX_ERROR; + } + + return ERROR_OK; +} +#endif static const struct command_registration ublast_command_handlers[] = { { @@ -1066,6 +1090,15 @@ static const struct command_registration ublast_command_handlers[] = { .help = "configure the USB-Blaster II firmware location", .usage = "path/to/blaster_xxxx.hex", }, +#ifdef HAVE_LIBUSB_GET_PORT_NUMBERS + { + .name = "usb_blaster_location", + .handler = &ublast_handle_location_command, + .mode = COMMAND_CONFIG, + .help = "set the USB bus location of the USB Blaster device", + .usage = "<bus>-port[.port]...", + }, +#endif COMMAND_REGISTRATION_DONE }; -- ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
