Devices on fixed USB ports

SilSil New Member Posts: 29 ✭✭

Dear all,

I have a problem with my USB port names.

In my system with a UP Squared board equipped with Ubilinux I use all the three USB. One of them is connected to a fixed device (i.e. a small webcam), while the other two are connected to a two devices. I call these two devices as DEV0 and DEV1, only for simplicity.

I would need that DEV0 is always connected to a port called /dev/ttyUSB0 and that DEV1 is always connected do /dev/ttyUSB1. The names can be different, of course, but they must not changed when the devices are off and the turn on again.

Up to now, my devices changed the name of the port where they are connected...
For instance, DEV0, now is connected to: /dev/serial/by-path/pci-0000:00:15.0-usb-0:3:1.0-port0 and DEV1 to /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AI050EYN-if00-port0.
Why does it happen?

Futhremore I cannot associate device ID to a specific USB using the udev rules, since DEV0 and DEV1 can change for other system with the same configuration and I do not know "a-priori" the ID of DEV0 and DEV1...

Summarizing, in a few word I would like that DEV0 and DEV1 are always connected to /dev/ttyUSB0 and /dev/ttyUSB1 respectively whatever they are.

Could you help me to solve my problem?

Thanks in advance.

Eng. Silvano Bertoldo, PhD


  • snuhgsnuhg New Member Posts: 14

    Hi Silvano,

    you were on the right track when you suggested the use of udev rules and I guess by now you might have found a udev rule that works for you. In case there is still a problem, it can probably be solved by further tweaking your udev rules a bit. Probably the easiest and most common way to get persistent device names or device paths assigned to USB devices is by using device specific attribute values in the udev matching rules. Here is an example. (admittedly for a Raspberry Pi and not an UP2 with Ubilinux, but it doesn't matter because it works the same in both cases)

    I am not quite sure what USB devices you are using as DEV0 and DEV1. One looks like it could be a null-modem cable with an FTDI chip. The second one I don't know, perhaps a mouse or a keyboard. The FTDI cable will most likely show up as /dev/ttyUSB* when you plug it in. You can then check the device attributes associated with it by opening a shell window and typing the command udevadm info --attribute-walk --name=/dev/ttyUSB* (note that * stands for 0 or1 or whatever the actual number is in your case). Given that you use a cable with FTDI chip you should see a list of attributes containing ATTRS{idProduct}=="6001" and ATTRS{idVendor}=="0403". If you use use those two in your udev rule you can tell the system to assign a persistent device name of your choice (for example ttyUSB0) to the FTDI cable by adding SYMLINK+="ttyUSB0" to the udev rule. The method is the same for your second USB device, but the details differ of course. For example, you might have to use other attributes in the udev rule to get useful matching rules for this specific device. All in all, it's relatively straightforward solution to your problem as long as you do not connect several USB devices of the same type (for example two or more FTDI cables) to the same host .

  • snuhgsnuhg New Member Posts: 14

    @snuhg said:

    ...... adding SYMLINK+="ttyUSB0" to the udev rule .......

    Have to add that (according to udev man pages) the name of a symlink should not be identical to the kernel name of a device. So, in the example I gave in my previous post, "ttyUSB0" would probably be a poor choice for a symlink name.

  • SilSil New Member Posts: 29 ✭✭
    edited June 2019

    Ok, but what happens if I change cable or device?

    Eng. Silvano Bertoldo, PhD

  • snuhgsnuhg New Member Posts: 14
    edited June 2019

    What do you want to achieve? Given your latest question, it is not clear to me anymore what your goal is.

    Your first post seemed to suggest that you have two particular USB devices you are plugging in and you want the system to always (i.e. each time you plug them in or boot the system) assign each of them their own individual persistent port name. If you want that, the route I suggested in my post is probably the easiest way to go forward.

    Or is it that you rather want to get two fixed port names (say, ttyUSB0 and ttyUSB1) irrespective of what the two USB devices are you are plugging in? In that case you have to choose udev rules with match keys that match some attribute(s) of a USB parent device and symlinks with the port names you want. The udevadm command mentioned in my post gives a list of all device attributes, including the attribute values of all parent devices (i.e. all parent devices of the device you plug in). If you go up in the parent device hierarchy you'll eventually find a parent device that is common to all devices you plug in. This parent device will have some device attributes you can use in your udev rules.

    If I am still misreading your question, I'd suggest you get more specific in what devices you are using and what goals you want to achieve.

  • SilSil New Member Posts: 29 ✭✭

    Ok, thanks a lot @snuhg!
    All your anwers, including the last one, together were very very interesting and helped me a lot!

    Thanks again!


    Eng. Silvano Bertoldo, PhD

Sign In or Register to comment.