5

I have multiple devices connected to 3 USB ports.

I can list them connected with some identification numbers through the following commands:

# cd /sys/bus/usb/drivers/usb
# ls
1-1     1-1.2   1-1.3   1-1.4   bind    uevent  unbind  usb1    usb2
# cat 1-1.2/product
My Connected Device

I want to put a label in the physical port of "My Connected Device" like "Connect Here". And I need to ensure that the following unbind/bind command can be sent only to that port to that specific device:

echo -n "1-1.2" > /sys/bus/usb/drivers/usb/unbind

If the hardware is the same, is it reliable to consider that after a reboot the system will always assign 1-1.2 to the same physical USB port?

5
  • Your title appears to be incomplete. If it's complete, I think some explanation is warranted. Mar 24, 2016 at 15:19
  • Fixed! Was that the only reason for the -1?
    – natenho
    Mar 24, 2016 at 15:21
  • I didn't downvote you. Did you mean vs instead of x? Mar 24, 2016 at 15:25
  • Logically it should be so. Why don't you test it? Mar 24, 2016 at 15:27
  • @MostafaAhangarha I've already tested a couple of times but I think it can't be enough to ensure that it will always do that way, because it's some kind of hardware stuff, I don't know which order things are done.
    – natenho
    Mar 24, 2016 at 15:32

2 Answers 2

2

As long as your USB hardware doesn't change (e.g: USB hubs, USB cards, etc), then yes, it is safe to assume that indeed the device will be assigned to the same location in /sys/bus/usb/devices/x-x.x. Linux should scan for and assign those x-x.x IDs in the same order every boot, however bear in mind that a device has to be connected to that port for that directory entry to exist.

2

Usb hosts are basically PCI devices and those are initilized using the same initial enumeration if it adheres to PCI specification. So short answer is yes.

5
  • I understand that for /dev and connected devices, it won't generate the same /dev/fooXX, but is that the same for USB bus ports?
    – natenho
    Mar 24, 2016 at 15:39
  • Now I understood your question...Usb hosts are basically PCI devices and those are initilized using the same initial enumeration if it adheres to PCI specification. So short answer is yes.
    – marc
    Mar 24, 2016 at 16:03
  • So the USB physical ports are not guaranteed to have the same 1-1.2 or 1-1.3 assigned in the same hardware?
    – natenho
    Mar 24, 2016 at 16:07
  • It seems I wasn't clear in my answer. They are guaranteed to use always the same interface identifier.
    – marc
    Mar 24, 2016 at 16:09
  • Ah ok!! Could you please edit your answer?
    – natenho
    Mar 24, 2016 at 16:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .