View previous topic :: View next topic |
Author |
Message |
pgu l33t
Joined: 30 Jul 2009 Posts: 722 Location: Oslo, Norway
|
Posted: Sun Jan 14, 2018 3:09 pm Post subject: [SOLVED] udev symlink does not trigger |
|
|
I have several USB serial port devices. I have some udev rules to symlink them so I can connect to them by name. This seem to work fine with the exception of one serial device.
I can access it by the /dev/ttyUSBXX name. The vendor and product id is the same, but the serial number is different.
This shows up in /dev/sockit
Code: | ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A1WK2TWY", SYMLINK+="sockit",MODE="666", GROUP="uucp"
|
This one does not appear in /dev/pmod
Code: | ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A503VSRN", SYMLINK+="pmod",MODE="666", GROUP="uucp"
|
I observe the serial number in the kernel log if I re-plug the device:
Code: | # dmesg |egrep A503VSRN\|A1WK2TWY
[ 3.170846] usb 8-1.2.3: SerialNumber: A503VSRN
[ 3.327788] usb 4-3: SerialNumber: A1WK2TWY
[ 7736.053376] usb 8-1.2.3: SerialNumber: A503VSRN
[ 8127.989317] usb 8-1.2.3: SerialNumber: A503VSRN
[ 8221.959670] usb 4-3: SerialNumber: A1WK2TWY
[ 9363.440782] usb 8-1.2.3: SerialNumber: A503VSRN
# ls -l /dev/sockit /dev/pmod
ls: cannot access '/dev/pmod': No such file or directory
lrwxrwxrwx 1 root root 7 Jan 14 15:21 /dev/sockit -> ttyUSB1
|
Is there a way to debug the symlink creation and rule parsing?
[Moderator edit: added [code] tags to preserve dmesg+ls output layout. -Hu]
Last edited by pgu on Sun Jan 14, 2018 9:20 pm; edited 1 time in total |
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Sun Jan 14, 2018 3:58 pm Post subject: |
|
|
I think your both rules are just not working like you think.
I'm not sure if udev rules mandate space after "," your both rules miss it, and even udev accept other properties of your rule, and accept to create the /dev/sockit symlink, you can clearly see the full rule wasn't apply.
Because with MODE="666", GROUP="uucp" you should had end with /dev/socket set to root:uucp and 666 mode, which it is not.
And i think you were also lucky udev has apply it to your /dev/socket device, because i don't think ATTRS{serial} exists too.
You should Code: | udevadm info -qall /dev/ttyUSB1 |
And you see real properties names and know what ATTRS to use to match a serial number. |
|
Back to top |
|
|
pgu l33t
Joined: 30 Jul 2009 Posts: 722 Location: Oslo, Norway
|
Posted: Sun Jan 14, 2018 4:33 pm Post subject: |
|
|
Thanks. Good point about the uucp group not being set. I should have spotted that.
I added the missing space. Now all devices belong to the uucp group, but the symlink is still not created.
Code: | # ls -l /dev/pmod /dev/sockit /dev/ttyUSB*
ls: cannot access '/dev/pmod': No such file or directory
lrwxrwxrwx 1 root root 7 Jan 14 16:42 /dev/sockit -> ttyUSB1
crw-rw---- 1 root uucp 188, 0 Jan 14 16:45 /dev/ttyUSB0
crw-rw-rw- 1 root uucp 188, 1 Jan 14 16:42 /dev/ttyUSB1
crw-rw---- 1 root uucp 188, 2 Jan 14 16:42 /dev/ttyUSB2
| And also USB1 does not have 666 even though sockit is created. There is clearly something I don't understand about how rules are processed.
However, the "udevadm info" doesn't tell me anything about the parsing/processing of the rule. Only the result.
[EDIT: USB1 does have 666, but USB0 don't] |
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Sun Jan 14, 2018 5:07 pm Post subject: |
|
|
udevadm is use to query information on the device, but could also be use to test rules.
and if you wonder "why" query information, because you are writing a rule, your rule try to set a symlink only to the device base on its "serial" attribute, if there is no "serial" attribute, then your rule is aiming at something that just doesn't exists.
So you should: query information on all attributes use by the device and see if really that "serial" attribute exists.
And you can then test the device to see all rules apply to it, and see if "the rule you have set" is apply to the device.
If you want an example: if you set ATTRS{mac_address} to change the mac address of the /dev/eth0 device, this will not work, because you have no "mac_address" attribute. Code: | udevadm info -qall --attribute-walk /sys/class/net/*
looking at device '/devices/pci0000:00/0000:00:19.0/net/eth0':
...
ATTR{address}=="f0:79:59:69:c8:76"
|
So to set a rule for that eth0 device, base on its mac address, the right property to use is ATTRS{address}="..."
and to test if your rule is use and is not overwrite by another one:
Code: | udevadm test /devices/pci0000:00/0000:00:19.0/net/eth0
...
NAME 'eth0' /etc/udev/rules.d/70-persistent-net.rules:11
...
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:19.0/net/eth0
...
|
|
|
Back to top |
|
|
pgu l33t
Joined: 30 Jul 2009 Posts: 722 Location: Oslo, Norway
|
Posted: Sun Jan 14, 2018 8:11 pm Post subject: |
|
|
They both have serial attributes. Here's the problematic one:
Code: | looking at parent device '/devices/pci0000:00/0000:00:15.2/0000:06:00.0/usb8/8-1/8-1.2/8-1.2.3':
KERNELS=="8-1.2.3"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceClass}=="00"
ATTRS{manufacturer}=="FTDI"
ATTRS{bmAttributes}=="a0"
ATTRS{bConfigurationValue}=="1"
ATTRS{version}==" 2.00"
ATTRS{devnum}=="13"
ATTRS{bMaxPower}=="90mA"
ATTRS{idProduct}=="6001"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{urbnum}=="15"
ATTRS{bDeviceSubClass}=="00"
ATTRS{maxchild}=="0"
ATTRS{bcdDevice}=="0600"
ATTRS{bMaxPacketSize0}=="8"
ATTRS{idVendor}=="0403"
ATTRS{product}=="FT232R USB UART"
ATTRS{speed}=="12"
ATTRS{removable}=="unknown"
ATTRS{ltm_capable}=="no"
ATTRS{serial}=="A503VSRN"
ATTRS{bNumConfigurations}=="1"
ATTRS{busnum}=="8"
ATTRS{authorized}=="1"
ATTRS{quirks}=="0x0"
ATTRS{configuration}==""
ATTRS{devpath}=="1.2.3"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bNumInterfaces}==" 1"
|
And the sockit one:
Code: | looking at parent device '/devices/pci0000:00/0000:00:12.0/usb4/4-3':
KERNELS=="4-3"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceClass}=="00"
ATTRS{manufacturer}=="FTDI"
ATTRS{bmAttributes}=="a0"
ATTRS{bConfigurationValue}=="1"
ATTRS{version}==" 2.00"
ATTRS{devnum}=="7"
ATTRS{bMaxPower}=="90mA"
ATTRS{idProduct}=="6001"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{urbnum}=="16"
ATTRS{bDeviceSubClass}=="00"
ATTRS{maxchild}=="0"
ATTRS{bcdDevice}=="0600"
ATTRS{bMaxPacketSize0}=="8"
ATTRS{idVendor}=="0403"
ATTRS{product}=="FT232R USB UART"
ATTRS{speed}=="12"
ATTRS{removable}=="unknown"
ATTRS{ltm_capable}=="no"
ATTRS{serial}=="A1WK2TWY"
ATTRS{bNumConfigurations}=="1"
ATTRS{busnum}=="4"
ATTRS{authorized}=="1"
ATTRS{quirks}=="0x0"
ATTRS{configuration}==""
ATTRS{devpath}=="3"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bNumInterfaces}==" 1"
|
|
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Sun Jan 14, 2018 8:20 pm Post subject: |
|
|
than look at "test" to see why first get the rule and second doesn't |
|
Back to top |
|
|
pgu l33t
Joined: 30 Jul 2009 Posts: 722 Location: Oslo, Norway
|
Posted: Sun Jan 14, 2018 9:20 pm Post subject: |
|
|
Thanks! The "test" command was what I was looking for:
Code: | udevadm test -a -p $(udevadm info -q path /dev/ttyUSB1) |
The problem was that it was not loading the rule file at all due to a misspelled .rules postfix |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|