For example, to always refer to the same USB to serial adapter by the same port name, when you have more than one connected.

This guide is based on the excellent guide here.

1 – Get a list of your USB devices
dmesg | grep ttyUSB

Example result:

usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
2 – Get specific attributes for the device

For our example device we will use:

  • Its name “ttyUSB0”
  • The numbers after “USB”, so “1-1.2”

, use its attached to name like this:

udevadm info --name=/dev/ttyUSB0 --attribute-walk

The results are for the complete chain of devices linked to the specified USB port., look for the section that ends with has our devices “1-1.2”

  looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.2':
    KERNELS=="1-1.2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{speed}=="12"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bMaxPower}=="90mA"
    ATTRS{manufacturer}=="FTDI"
    ATTRS{idProduct}=="6001"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bmAttributes}=="a0"
    ATTRS{quirks}=="0x0"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{busnum}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{bcdDevice}=="0600"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{configuration}==""
    ATTRS{removable}=="unknown"
    ATTRS{urbnum}=="300690"
    ATTRS{devnum}=="3"
    ATTRS{product}=="FT232R USB UART"
    ATTRS{serial}=="B400LXUC"
    ATTRS{version}==" 2.00"
    ATTRS{authorized}=="1"
    ATTRS{tx_lanes}=="1"
    ATTRS{rx_lanes}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{devspec}=="(null)"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{maxchild}=="0"
    ATTRS{devpath}=="1.2"
    ATTRS{idVendor}=="0403"
    ATTRS{bConfigurationValue}=="1"

You want to get some unique attributes from this so this device can be uniquely identified.

These are typically good:

    ATTRS{idProduct}=="6001"
    ATTRS{idVendor}=="0403"

This can also be used if you are using multiple of the same device type:

 ATTRS{serial}=="B400LXUC"
3 – Update the USB device list file
sudo nano /etc/udev/rules.d/10-usb-serial.rules

The file will open, it will be empty if its not been used before. Create a line for your device, setting the attributes to match what you got above and giving it the unique name your want to use in the SYMLINK+ fireld.

SUBSYSTEM=="tty", ATTRS{idProduct}=="6001", ATTRS{idVendor}=="0403", SYMLINK+="ttyUSB_MYDEVICE1"

Save the file and close it.

4 – Enter this command to let the new rules take effect
sudo udevadm trigger
5 – Verify your new name has been assigned
ls -l /dev/ttyUSB*

In our example we get this

crw-rw---- 1 root dialout 188, 0 Dec 11 16:03 /dev/ttyUSB0
lrwxrwxrwx 1 root root         7 Dec 11 16:03 /dev/ttyUSB_MYDEVICE1 -> ttyUSB0
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *