Skip to content

Commit

Permalink
jtag/esp_usb_jtag: re-init usb port when replug or hard reset detected
Browse files Browse the repository at this point in the history
  • Loading branch information
erhankur committed May 17, 2024
1 parent 482f11a commit 3016576
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/jtag/drivers/esp_usb_jtag.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,18 +322,8 @@ static int esp_usb_jtag_revive_device(struct libusb_device_handle *usb_device)

while (tries-- >= 0) {
new_dev = jtag_libusb_find_device(vids, pids, esp_usb_jtag_serial);
if (new_dev) {
if (esp_usb_jtag_libusb_location_equal(cur_dev, new_dev)) {
/* device is still at the same location on bus and with the same address,
try to reset it */
int rc = libusb_reset_device(usb_device);
if (rc == LIBUSB_ERROR_NOT_FOUND || rc == LIBUSB_ERROR_NO_DEVICE) {
/* re-enumeration is necessary */
break;
}
libusb_unref_device(new_dev);
return rc == 0 ? ERROR_OK : ERROR_WAIT;
}
if (new_dev && esp_usb_jtag_libusb_location_equal(cur_dev, new_dev)) {
/* device is still at the same location on bus and with the same address, try to re-init it */
break;
}
jtag_sleep(100000);
Expand Down

0 comments on commit 3016576

Please sign in to comment.