Search code examples
linuxlinux-kernelusbttyudev

How to find reasons why an udev rule is not applied?


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?


Solution

  • 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'