0

I was trying to solve my problem looking at other threads such as Why My USB port fixing udev rules are not working and udev rules doesn't work with small number among other several posts regarding udev rules but none of the posts I've checked is helping me to find out why I'm experiencing this issue.

udev rule with bInterfaceNumber doesn't work is a very very similar problem to the one I have, essentially the same, but it doesn't have an answer since 2013 and I think is forgotten by now.

I have the following rules that work perfectly:

SUBSYSTEM=="tty", SUBSYSTEMS=="usb-serial", DRIVERS=="mos7840", ATTRS{port_number}=="0", SYMLINK+="USB-RS232-0", MODE="0777"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb-serial", DRIVERS=="mos7840", ATTRS{port_number}=="1", SYMLINK+="USB-RS232-1", MODE="0777"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb-serial", DRIVERS=="ftdi_sio", ATTRS{port_number}=="0", SYMLINK+="USB-TTL-0", MODE="0777"

The problem is that I have 2 devices that are the same and the only difference between the attributes of the two is the serial number, they even have the same VID/PID, therefore I need to add ATTRS{serial} to the rules to end up having:

SUBSYSTEM=="tty", SUBSYSTEMS=="usb-serial", DRIVERS=="mos7840", ATTRS{port_number}=="0", SYMLINK+="USB-RS232-0", MODE="0777"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb-serial", DRIVERS=="mos7840", ATTRS{port_number}=="1", SYMLINK+="USB-RS232-1", MODE="0777"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb-serial", DRIVERS=="ftdi_sio", ATTRS{port_number}=="0", ATTRS{serial}=="AFYS1HLQ", SYMLINK+="USB-TTL-0", MODE="0777"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb-serial", DRIVERS=="ftdi_sio", ATTRS{port_number}=="0", ATTRS{serial}=="FTV8IUSR", SYMLINK+="USB-TTL-1", MODE="0777"

So after adding ATTRS{serial} to the two last rules then both stop working.

Why is this?

Thanks!!

m4l490n
  • 910

1 Answers1

1

The key piece of information is in this paragraph in the udev(7) man page (my emhpasis):

ATTRS{filename}

Search the devpath upwards for a device with matching sysfs attribute values. If multiple ATTRS matches are specified, all of them must match on the same device. Trailing whitespace in the attribute values is ignored unless the specified match value itself contains trailing whitespace.

So if you have more than one ATTRS rule (as you do), all the properties (filenames) matched must be in the same device directory.

This does not need to be the same device that matches a SUBSYSTEMS or DRIVERS rule.

Toby Speight
  • 5,213