You are not logged in.

#1 2015-04-15 04:30:14

Exershio
Member
Registered: 2008-04-14
Posts: 17

[SOLVED] Custom udev rule only working when triggered manually

I have the following rule created for a USB gamecube controller adapter:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="0337", MODE="0666"

This rule only takes effect when I run udevadm trigger AFTER my device is plugged in. If I then unplug the device, and plug it back in, my device no longer works. My device also doesn't work on boot. I have to plug my device in and then trigger the rules manually.

Any ideas why this is happening? I don't want to have to run udevadm trigger every time I turn my computer on.

Last edited by Exershio (2015-04-15 23:01:19)

Offline

#2 2015-04-15 09:47:36

mpan
Member
Registered: 2012-08-01
Posts: 1,612
Website

Re: [SOLVED] Custom udev rule only working when triggered manually

Have you reloaded the configuration?

# udevadm control --reload

Just asking, since I've scratched my head multiple times already because of that.

If this doesn't help: do you see anything interesting when monitoring udev?

# udevadm monitor

Offline

#3 2015-04-15 21:01:24

Exershio
Member
Registered: 2008-04-14
Posts: 17

Re: [SOLVED] Custom udev rule only working when triggered manually

I tried reloading the configuration but it doesn't affect the issue. As for monitoring udev, this appears when I plug the device in:

KERNEL[3439.476646] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5 (usb)
KERNEL[3439.478441] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0 (usb)
KERNEL[3439.486155] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/0003:057E:0337.0009 (hid)
KERNEL[3439.492319] add      /class/usbmisc (class)
KERNEL[3439.492497] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/usbmisc/hiddev0 (usbmisc)
KERNEL[3439.492602] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/0003:057E:0337.0009/hidraw/hidraw0 (hidraw)
UDEV  [3439.493842] add      /class/usbmisc (class)
UDEV  [3439.494832] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5 (usb)
UDEV  [3439.496365] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0 (usb)
UDEV  [3439.498256] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/usbmisc/hiddev0 (usbmisc)
UDEV  [3439.498378] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/0003:057E:0337.0009 (hid)
UDEV  [3439.499567] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/0003:057E:0337.0009/hidraw/hidraw0 (hidraw)

So it seems udev is detecting the GC adapter being plugged in, but it doesn't apply permissions 0666 to it until I manually run udevadm trigger.

See what happens below, directly after plugging it in:

$ ls -l /dev/bus/usb/004/005
crw-rw-r-- 1 root root 189, 388 Apr 15 16:59 /dev/bus/usb/004/005
$ sudo udevadm trigger
$ ls -l /dev/bus/usb/004/005
crw-rw-rw- 1 root root 189, 388 Apr 15 17:03 /dev/bus/usb/004/005

Okay this is weird. So I appended my udev rule with GROUP="users" to see if that would help, and after reloading the rules, this happens after my device is plugged in:

$ ls -l /dev/bus/usb/004/005
crw-rw-r-- 1 root users 189, 393 Apr 15 17:32 /dev/bus/usb/004/005
$ sudo udevadm trigger
$ ls -l /dev/bus/usb/004/005
crw-rw-rw- 1 root users 189, 393 Apr 15 17:34 /dev/bus/usb/004/005

So it appears the device is taking on GROUP="users" immediately after being plugged in, but it wont set MODE="0666" until after running udevadm trigger

Anyone have any ideas?

Last edited by Exershio (2015-04-15 21:38:15)

Offline

#4 2015-04-15 22:13:57

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [SOLVED] Custom udev rule only working when triggered manually

Exactly which file is this rule in? Because, the rule files are processed in order - this is very important.

A later rule might be overriding your MODE assignation.

I would suggest using the file:  /etc/udev/rules.d/91-local.rules

Offline

#5 2015-04-15 23:00:53

Exershio
Member
Registered: 2008-04-14
Posts: 17

Re: [SOLVED] Custom udev rule only working when triggered manually

That seemed to have solved it! I had it in /etc/udev/rules.d/42-nintendo-gc-adapter.rules. Changing the 42 prefix to 91 fixed the issue. I didn't think it mattered since the only other rule I have in that folder is unrelated. I suppose there might be a default rule that was loading after my custom one.

Thanks everyone for the help.

Offline

Board footer

Powered by FluxBB