usbboot icon indicating copy to clipboard operation
usbboot copied to clipboard

Increase supported USB port range to 0-255

Open Mik3Rizzo opened this issue 4 months ago • 8 comments

This pull request enhances the flexibility of the tool by expanding the supported range for the USB port parameter. The previous limit, which was hardcoded to a maximum of 6, has been updated to accept any value from 0 to 255.

Motivation

The original limitation of 0-6 ports can be restrictive for users with more complex hardware setups, such as those utilizing large or multiple USB hubs.

This modification provides a simple yet effective improvement, making the tool more versatile for a broader range of use cases.

Mik3Rizzo avatar Sep 16 '25 10:09 Mik3Rizzo

The change looks ok, although for interop testing we would only claim to support a direct connection to a Pi or known good (doesn't back-power) powered USB hub on Linux (hubs are problematic in libusb on Windows)

timg236 avatar Sep 16 '25 10:09 timg236

Wouldn't be the -l argument with the proper usb path a better fit for complexer setups? I use it myself quite often and ir makes it easier as from the path the topology is also clear. But just asking out of curiosity

nbuchwitz avatar Sep 16 '25 11:09 nbuchwitz

Using a fully qualified path obtained via udev is probably the more robust solution instead of specifying numbers, although the restriction of 0..6 for this old method seems a bit restrictive

timg236 avatar Sep 16 '25 11:09 timg236

The port number is the port number on the USB hub it's connected to so additional levels of hub will most likely only have ports 0-6 for 7 port hubs, I don't remember seeing any hubs which actually have more than 7 ports without chaining.

For example on a Raspberry Pi 3B+ port 3 could be the top right USB or bottom left USB port which is why I added the option to set a path like "1-1.3" or "1-1.1.3" which allows these to be differentiated.

burtyb avatar Sep 16 '25 11:09 burtyb

The port number is the port number on the USB hub it's connected to so additional levels of hub will most likely only have ports 0-6 for 7 port hubs, I don't remember seeing any hubs which actually have more than 7 ports without chaining.

For example on a Raspberry Pi 3B+ port 3 could be the top right USB or bottom left USB port which is why I added the option to set a path like "1-1.3" or "1-1.1.3" which allows these to be differentiated.

Good point. Please can the author describe their hardware setup ?

timg236 avatar Sep 16 '25 11:09 timg236

Good point. Please can the author describe their hardware setup ?

I'm using the rpiboot from a full tower windows PC that has 9 physical usb ports, but for some reason one of them is seen as USB 10 in the device manager.

Wouldn't be the -l argument with the proper usb path a better fit for complexer setups? I use it myself quite often and ir makes it easier as from the path the topology is also clear. But just asking out of curiosity

Yes, it'd be a good solution. In my case, I've just opened the device manager on windows and I've seen that my CM4 was on USB 10.

For example on a Raspberry Pi 3B+ port 3 could be the top right USB or bottom left USB port which is why I added the option to set a path like "1-1.3" or "1-1.1.3" which allows these to be differentiated.

On windows I don't know how to obtain the usb path honestly.

Mik3Rizzo avatar Sep 16 '25 12:09 Mik3Rizzo

If this is to be merged it would need to be updated for the special case where targetPortNo is 99, maybe allow ports 0-254 and switch unconfigured to be 255?

burtyb avatar Oct 02 '25 08:10 burtyb

If this is to be merged it would need to be updated for the special case where targetPortNo is 99, maybe allow ports 0-254 and switch unconfigured to be 255?

I simply limited the range from 0 to 98, to avoid issues with special 99 port.

Mik3Rizzo avatar Oct 02 '25 14:10 Mik3Rizzo