skip to Main Content

I added an udev rule to generate a separate link to a special tty device. I took the vendor and product id from lsusb:

Bus 001 Device 016: ID abcd:1234 Foo Device

The dmesg output for the device is:

[  369.384850] usb 1-1.1: new full-speed USB device number 4 using xhci_hcd
[  369.470492] usb 1-1.1: New USB device found, idVendor=09d8, idProduct=0420
[  369.470506] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  369.470515] usb 1-1.1: Product: TWN4/B1.06/CCL3.12/PRS1.04
[  369.470522] usb 1-1.1: Manufacturer: OEM
[  369.475188] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device

Normally the Debian system generates an ACM* tty for this device:

$ ls /dev/ttyACM*
/dev/ttyACM0

So I created /ect/udev/rules.d/99-bizrfid.rules:

ACTION=="add", ATTRS{idVendor}=="09d8", ATTRS{idProduct}=="0420", SYMLINK+="ttyMyDevice"

But ls /dev/tty* does not show ttyMyDevice.

What I tried so far without success:

  1. Running udevadm trigger. This should apply the new udev rule.
  2. I did a reboot.
  3. I had a look to udevadm test /dev/ttyACM0. My udevrule is shown at the end. So I am sure that it had not been overridden. But I wonder about the ‘unable to open’ hint. Nevertheless this hint is present for other ttys, such as tty0 or ttyS0, too.
...    
Reading rules file: /lib/udev/rules.d/98-systemd.rules
Reading rules file: /etc/udev/rules.d/99-bizrfid.rules
rules contain 49152 bytes tokens (4096 * 12 bytes), 12883 bytes strings
4240 strings (40079 bytes), 3515 de-duplicated (27922 bytes), 726 trie nodes used
unable to open device '/sys/dev/ttyACM0'
Unload module index
Unloaded link configuration context.
  1. I reconnected the USB device.
  2. I tried another udev rule. This rule is 100% correct because I use this rule already fo other devices. But it does not work for the ttyACM0:
ACTION=="add", KERNEL=="ttyACM*", MODE="0666"

I wonder why this is not working.
How to find reasons why an udev rule is not applied?

2

Answers


  1. Chosen as BEST ANSWER

    According to the comments I the following can be tried to debug the problem:

    Check the driver

    Use dmesg to check the driver you are using and ensure that it is a generic one. If it is a custom compiled one, the problem could be inside your custom implementation. If it is a generic one, go on to step two. I found the driver name in the last line: cdc_acm

    [  369.384850] usb 1-1.1: new full-speed USB device number 4 using xhci_hcd
    [  369.470492] usb 1-1.1: New USB device found, idVendor=09d8, idProduct=0420
    [  369.470506] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
    [  369.470515] usb 1-1.1: Product: TWN4/B1.06/CCL3.12/PRS1.04
    [  369.470522] usb 1-1.1: Manufacturer: OEM
    [  369.475188] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device
    

    Check the user permissions

    Ensure that the permission of your udev rule is correct:

    chmod 644 99-myrule.rules
    chown root:root 99-myrule.rules
    

    Do a test run for the add-action

    Check the output of udevadm test -a add $(udevadm info -q path -n /dev/ttyACM0). My output looks like this:

    calling: test

    version 232
    This program is for debugging only, it does not run any program
    specified by a RUN key. It may show incorrect results, because
    some values may be different, or not available at a simulation run.
    
    === trie on-disk ===
    tool version:          232
    file size:         8447696 bytes
    header size             80 bytes
    strings            1849040 bytes
    nodes              6598576 bytes
    Load module index
    Found container virtualization none
    timestamp of '/etc/systemd/network' changed
    timestamp of '/usr/lib/systemd/network' changed
    timestamp of '/lib/systemd/network' changed
    Parsed configuration file /lib/systemd/network/99-default.link
    Created link configuration context.
    timestamp of '/etc/udev/rules.d' changed
    Skipping overridden file: /lib/udev/rules.d/99-bizrfid.rules.
    Reading rules file: /lib/udev/rules.d/50-firmware.rules
    
    ...
    
    Reading rules file: /lib/udev/rules.d/98-systemd.rules
    Reading rules file: /etc/udev/rules.d/99-bizrfid.rules
    rules contain 49152 bytes tokens (4096 * 12 bytes), 12900 bytes strings
    4244 strings (40114 bytes), 3517 de-duplicated (27942 bytes), 728 trie nodes used
    GROUP 20 /lib/udev/rules.d/50-udev-default.rules:26
    IMPORT builtin 'hwdb' /lib/udev/rules.d/60-serial.rules:7
    IMPORT builtin 'usb_id' /lib/udev/rules.d/60-serial.rules:8
    /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1:1.0: if_class 2 protocol 0
    IMPORT builtin 'hwdb' /lib/udev/rules.d/60-serial.rules:8
    IMPORT builtin 'path_id' /lib/udev/rules.d/60-serial.rules:15
    LINK 'serial/by-path/pci-0000:00:14.0-usb-0:1.1:1.0' /lib/udev/rules.d/60-serial.rules:16
    IMPORT builtin skip 'usb_id' /lib/udev/rules.d/60-serial.rules:19
    LINK 'serial/by-id/usb-OEM_TWN4_B1.06_CCF3.00_PRS1.04-if00' /lib/udev/rules.d/60-serial.rules:23
    LINK 'ttyMyDevice' /etc/udev/rules.d/99-bizrfid.rules:1
    handling device node '/dev/ttyACM0', devnum=c166:0, mode=0660, uid=0, gid=20
    preserve permissions /dev/ttyACM0, 020660, uid=0, gid=20
    preserve already existing symlink '/dev/char/166:0' to '../ttyACM0'
    found 'c166:0' claiming '/run/udev/links/x2fserialx2fby-idx2fusb-OEM_TWN4_B1.06_CCF3.00_PRS1.04-if00'
    creating link '/dev/serial/by-id/usb-OEM_TWN4_B1.06_CCF3.00_PRS1.04-if00' to '/dev/ttyACM0'
    preserve already existing symlink '/dev/serial/by-id/usb-OEM_TWN4_B1.06_CCF3.00_PRS1.04-if00' to '../../ttyACM0'
    found 'c166:0' claiming '/run/udev/links/x2fserialx2fby-pathx2fpci-0000:00:14.0-usb-0:1.1:1.0'
    creating link '/dev/serial/by-path/pci-0000:00:14.0-usb-0:1.1:1.0' to '/dev/ttyACM0'
    preserve already existing symlink '/dev/serial/by-path/pci-0000:00:14.0-usb-0:1.1:1.0' to '../../ttyACM0'
    creating link '/dev/ttyMyDevice' to '/dev/ttyACM0'
    creating symlink '/dev/ttyMyDevice' to 'ttyACM0'
    created db file '/run/udev/data/c166:0' for '/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1:1.0/tty/ttyACM0'
    ACTION=add
    DEVLINKS=/dev/serial/by-path/pci-0000:00:14.0-usb-0:1.1:1.0 /dev/serial/by-id/usb-OEM_TWN4_B1.06_CCF3.00_PRS1.04-if00 /dev/ttyMyDevice
    DEVNAME=/dev/ttyACM0
    DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1:1.0/tty/ttyACM0
    ID_BUS=usb
    ID_MODEL=TWN4_B1.06_CCF3.00_PRS1.04
    ID_MODEL_ENC=TWN4x2fB1.06x2fCCF3.00x2fPRS1.04
    ID_MODEL_FROM_DATABASE=Atom Processor Z36xxx/Z37xxx, Celeron N2000 Series USB xHCI
    ID_MODEL_ID=0420
    ID_PATH=pci-0000:00:14.0-usb-0:1.1:1.0
    ID_PATH_TAG=pci-0000_00_14_0-usb-0_1_1_1_0
    ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
    ID_PCI_INTERFACE_FROM_DATABASE=XHCI
    ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
    ID_REVISION=0200
    ID_SERIAL=OEM_TWN4_B1.06_CCF3.00_PRS1.04
    ID_TYPE=generic
    ID_USB_CLASS_FROM_DATABASE=Communications
    ID_USB_DRIVER=cdc_acm
    ID_USB_INTERFACES=:020201:0a0000:
    ID_USB_INTERFACE_NUM=00
    ID_VENDOR=OEM
    ID_VENDOR_ENC=OEM
    ID_VENDOR_FROM_DATABASE=Intel Corporation
    ID_VENDOR_ID=09d8
    MAJOR=166
    MINOR=0
    SUBSYSTEM=tty
    TAGS=:systemd:
    USEC_INITIALIZED=71480300178
    Unload module index
    Unloaded link configuration context.
    

  2. For the udev rule
    /ect/udev/rules.d/99-bizrfid.rules I would add the SUBSYSTEM:

    ACTION=="add", SUBSYSTEM=="tty", ATTRS{idVendor}=="09d8", ATTRS{idProduct}=="0420", SYMLINK+="ttyMyDevice"
    

    You could add also ATTRS{manufacturer}==, but idVendor and idProduct are sufficient.

    Otherwise it looks correct and the test run creates the symlink:

    creating link '/dev/ttyMyDevice' to '/dev/ttyACM0'

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search