1

I connected two ESP boards (that are connected to an USB hub. So the ESP boards are indirectly connected via one USB port of the USB hub) to my acer-extensa-5630z (old model). In /dev directory, both the ESP boards are listed as ttyUSB0 and ttyUSB1 respectively.

I wanted to change the names "ttyUSB0" and "ttyUSB1" to "esp1" and "esp2" respectively. Below are the steps that I followed in order to change the names.

  1. I listed the attributes using the following commands to get the attributes listed below
udevadm info --attribute-walk --name=/dev/ttyUSB0
ram@ram-Extensa-5630:/etc/udev/rules.d$ udevadm info --attribute-walk --name=/dev/ttyUSB0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2/2-1.2:1.0/ttyUSB0/tty/ttyUSB0':
    KERNEL=="ttyUSB0"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2/2-1.2:1.0/ttyUSB0':
    KERNELS=="ttyUSB0"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="ch341-uart"
    ATTRS{port_number}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2/2-1.2:1.0':
    KERNELS=="2-1.2:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="ch341"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{authorized}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bInterfaceProtocol}=="02"
    ATTRS{bNumEndpoints}=="03"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2':
    KERNELS=="2-1.2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bmAttributes}=="80"
    ATTRS{bDeviceClass}=="ff"
    ATTRS{speed}=="12"
    ATTRS{rx_lanes}=="1"
    ATTRS{version}==" 1.10"
    ATTRS{idProduct}=="7523"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{product}=="USB2.0-Serial"
    ATTRS{removable}=="unknown"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{urbnum}=="16"
    ATTRS{devnum}=="27"
    ATTRS{idVendor}=="1a86"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="1.2"
    ATTRS{configuration}==""
    ATTRS{tx_lanes}=="1"
    ATTRS{bMaxPower}=="98mA"
    ATTRS{ltm_capable}=="no"
    ATTRS{busnum}=="2"
    ATTRS{maxchild}=="0"
    ATTRS{bcdDevice}=="0263"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{bConfigurationValue}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1':
    KERNELS=="2-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{rx_lanes}=="1"
    ATTRS{version}==" 2.00"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{urbnum}=="35"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{idVendor}=="045b"
    ATTRS{quirks}=="0x0"
    ATTRS{devnum}=="25"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{devpath}=="1"
    ATTRS{authorized}=="1"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="0209"
    ATTRS{speed}=="480"
    ATTRS{tx_lanes}=="1"
    ATTRS{busnum}=="2"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{maxchild}=="4"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bcdDevice}=="0100"
    ATTRS{ltm_capable}=="no"
    ATTRS{configuration}==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2':
    KERNELS=="usb2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{idVendor}=="1d6b"
    ATTRS{bcdDevice}=="0504"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="0000:00:1d.7"
    ATTRS{version}==" 2.00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{rx_lanes}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{manufacturer}=="Linux 5.4.0-58-generic ehci_hcd"
    ATTRS{tx_lanes}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{speed}=="480"
    ATTRS{busnum}=="2"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bmAttributes}=="e0"
    ATTRS{removable}=="unknown"
    ATTRS{devnum}=="1"
    ATTRS{maxchild}=="6"
    ATTRS{urbnum}=="226"
    ATTRS{product}=="EHCI Host Controller"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{authorized}=="1"
    ATTRS{configuration}==""
    ATTRS{interface_authorized_default}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="0"
    ATTRS{idProduct}=="0002"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7':
    KERNELS=="0000:00:1d.7"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci-pci"
    ATTRS{local_cpulist}=="0-1"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{subsystem_vendor}=="0x1025"
    ATTRS{vendor}=="0x8086"
    ATTRS{uframe_periodic_max}=="100"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{numa_node}=="-1"
    ATTRS{driver_override}=="(null)"
    ATTRS{revision}=="0x03"
    ATTRS{device}=="0x293a"
    ATTRS{irq}=="23"
    ATTRS{local_cpus}=="3"
    ATTRS{enable}=="1"
    ATTRS{companion}==""
    ATTRS{subsystem_device}=="0x013c"
    ATTRS{ari_enabled}=="0"
    ATTRS{msi_bus}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0320"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

ram@ram-Extensa-5630:/etc/udev/rules.d$ 

Following is the command I used to display the attributes of ttyUSB1

udevadm info --attribute-walk --name=/dev/ttyUSB1
ram@ram-Extensa-5630:/etc/udev/rules.d$ udevadm info --attribute-walk --name=/dev/ttyUSB1

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1/2-1.1.4/2-1.1.4:1.0/ttyUSB1/tty/ttyUSB1':
    KERNEL=="ttyUSB1"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1/2-1.1.4/2-1.1.4:1.0/ttyUSB1':
    KERNELS=="ttyUSB1"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="ch341-uart"
    ATTRS{port_number}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1/2-1.1.4/2-1.1.4:1.0':
    KERNELS=="2-1.1.4:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="ch341"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="03"
    ATTRS{bInterfaceProtocol}=="02"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{authorized}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1/2-1.1.4':
    KERNELS=="2-1.1.4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{speed}=="12"
    ATTRS{authorized}=="1"
    ATTRS{idProduct}=="7523"
    ATTRS{version}==" 1.10"
    ATTRS{bMaxPower}=="98mA"
    ATTRS{ltm_capable}=="no"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{tx_lanes}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bmAttributes}=="80"
    ATTRS{devpath}=="1.1.4"
    ATTRS{urbnum}=="16"
    ATTRS{removable}=="unknown"
    ATTRS{bcdDevice}=="0263"
    ATTRS{busnum}=="2"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{configuration}==""
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{devnum}=="28"
    ATTRS{product}=="USB2.0-Serial"
    ATTRS{quirks}=="0x0"
    ATTRS{maxchild}=="0"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{rx_lanes}=="1"
    ATTRS{bDeviceClass}=="ff"
    ATTRS{idVendor}=="1a86"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1':
    KERNELS=="2-1.1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{quirks}=="0x0"
    ATTRS{ltm_capable}=="no"
    ATTRS{idProduct}=="0209"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{configuration}==""
    ATTRS{bcdDevice}=="0100"
    ATTRS{version}==" 2.00"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{removable}=="unknown"
    ATTRS{urbnum}=="26"
    ATTRS{tx_lanes}=="1"
    ATTRS{devnum}=="26"
    ATTRS{rx_lanes}=="1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{speed}=="480"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{busnum}=="2"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="4"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{idVendor}=="045b"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{authorized}=="1"
    ATTRS{devpath}=="1.1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1':
    KERNELS=="2-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{idVendor}=="045b"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{busnum}=="2"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{removable}=="unknown"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{configuration}==""
    ATTRS{urbnum}=="35"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{rx_lanes}=="1"
    ATTRS{devpath}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{tx_lanes}=="1"
    ATTRS{bcdDevice}=="0100"
    ATTRS{speed}=="480"
    ATTRS{devnum}=="25"
    ATTRS{authorized}=="1"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{quirks}=="0x0"
    ATTRS{version}==" 2.00"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{idProduct}=="0209"
    ATTRS{maxchild}=="4"
    ATTRS{ltm_capable}=="no"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2':
    KERNELS=="usb2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceClass}=="09"
    ATTRS{configuration}==""
    ATTRS{urbnum}=="226"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{idVendor}=="1d6b"
    ATTRS{maxchild}=="6"
    ATTRS{removable}=="unknown"
    ATTRS{ltm_capable}=="no"
    ATTRS{quirks}=="0x0"
    ATTRS{busnum}=="2"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{devnum}=="1"
    ATTRS{version}==" 2.00"
    ATTRS{speed}=="480"
    ATTRS{authorized}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{devpath}=="0"
    ATTRS{product}=="EHCI Host Controller"
    ATTRS{manufacturer}=="Linux 5.4.0-58-generic ehci_hcd"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{serial}=="0000:00:1d.7"
    ATTRS{rx_lanes}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{idProduct}=="0002"
    ATTRS{tx_lanes}=="1"
    ATTRS{bcdDevice}=="0504"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{authorized_default}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7':
    KERNELS=="0000:00:1d.7"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci-pci"
    ATTRS{uframe_periodic_max}=="100"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{subsystem_vendor}=="0x1025"
    ATTRS{local_cpulist}=="0-1"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{local_cpus}=="3"
    ATTRS{vendor}=="0x8086"
    ATTRS{subsystem_device}=="0x013c"
    ATTRS{ari_enabled}=="0"
    ATTRS{irq}=="23"
    ATTRS{broken_parity_status}=="0"
    ATTRS{companion}==""
    ATTRS{msi_bus}=="1"
    ATTRS{device}=="0x293a"
    ATTRS{class}=="0x0c0320"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{revision}=="0x03"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

ram@ram-Extensa-5630:/etc/udev/rules.d$ 
  1. In "/etc/udev/rules.d" directory, I created and edited a file called "esp.rules" with following content
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="7523", ATTRS{idVendor}=="1a86", ATTRS{devpath}=="2.2", SYMLINK+="esp1"

SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="7523", ATTRS{idVendor}=="1a86", ATTRS{devpath}=="2.1.4", SYMLINK+="esp2" 
  1. After updating the file "esp.rules", I executed
udevadm control --reload-rules && udevadm trigger

I dont know if the issue is in the steps that I followed or in the USB port. I am using ubuntu 20.04 LTS.

Kindly help me to sort out this. Thank you in advance.

0

The rule looks correct to me and it should work. Only problem I found is with the command you are using for testing/running the rule -- udevadm trigger by default sends change event and your rules are reacting to add so you should use:

udevadm control --reload-rules && udevadm trigger -c add
2
  • Thank you for your time. I tried the command, it still does not work.I will try and let you know once I solve this. Dekuji moc :) – Ram Prasanth Dec 19 '20 at 13:25
  • I found out later that the udev rules written were right and the issue was that I was expecting to see a change of name in /dev directory. Later, I got to know that it is not displayed however the udev rules are applied. Thank you for the answers and help. I hope that this thread could be of some use to someone. – Ram Prasanth Mar 9 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.