@@ -256,6 +256,7 @@ struct _settings {
256256 uint32_t binary_start = FLASH_START;
257257 int bus=-1 ;
258258 int address=-1 ;
259+ int port = -1 ;
259260 string serial;
260261 uint32_t offset = 0 ;
261262 uint32_t from = 0 ;
@@ -2264,6 +2265,7 @@ int main(int argc, char **argv) {
22642265 for (libusb_device **dev = devs; *dev; dev++) {
22652266 if (settings.bus != -1 && settings.bus != libusb_get_bus_number (*dev)) continue ;
22662267 if (settings.address != -1 && settings.address != libusb_get_device_address (*dev)) continue ;
2268+ if (settings.port != -1 && settings.port != libusb_get_port_number (*dev)) continue ;
22672269 libusb_device_handle *handle = nullptr ;
22682270 auto result = picoboot_open_device (*dev, &handle);
22692271 if (handle) {
@@ -2351,8 +2353,14 @@ int main(int argc, char **argv) {
23512353 " Forced command requires a single rebootable RP2040 device to be targeted." );
23522354 }
23532355 if (selected_cmd->force_requires_pre_reboot ()) {
2354- // we reboot into BOOTSEL mode and disable MSC interface (the 1 here)
23552356 auto &to_reboot = devices[dr_vidpid_stdio_usb][0 ].first ;
2357+ // adjust filter settings, so we can find the device after reboot
2358+ if (!settings.serial .empty ()) {
2359+ settings.serial = " " ;
2360+ settings.bus = libusb_get_bus_number (to_reboot);
2361+ settings.port = libusb_get_port_number (to_reboot);
2362+ }
2363+ // we reboot into BOOTSEL mode and disable MSC interface (the 1 here)
23562364 reboot_device (to_reboot, true , 1 );
23572365 fos << " The device was asked to reboot into BOOTSEL mode so the command can be executed.\n\n " ;
23582366 for (const auto &handle : to_close) {
@@ -2369,7 +2377,9 @@ int main(int argc, char **argv) {
23692377 // again is to assume it is the only now visible device.
23702378 settings.force = false ;
23712379 settings.address = -1 ;
2372- settings.bus = -1 ;
2380+ if (settings.serial .empty ()) {
2381+ settings.bus = -1 ;
2382+ }
23732383 continue ;
23742384 }
23752385 }
0 commit comments