2

I'm trying to write a udev rule to change the group on my MSP-FET430UIF USB programmer. This is what I have so far (filename /etc/udev/rules.d/40-ti-fet430.rules):

SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="f430", MODE="0660", GROUP="plugdev", RUN+="/tmp/test.sh"

The run command (which just redirects date into /tmp/test) is working. However, the group and permissions of the /dev/ttyUSB0 device is not getting changed:

$ ls -l /dev/ttyUSB0
crw------- 1 root root 188, 0 May 18 13:05 /dev/ttyUSB0

This is the output of udevadm test /device/blabla:

$ udevadm test `udevadm info -q path -n /dev/ttyUSB0 `
calling: test
version 216
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.

load module index
timestamp of '/etc/systemd/network' changed
timestamp of '/lib/systemd/network' changed
Parsed configuration file /lib64/systemd/network/99-default.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Reading rules file: /lib64/udev/rules.d/40-gentoo.rules
Reading rules file: /etc/udev/rules.d/40-ti-fet430.rules
Reading rules file: /lib64/udev/rules.d/42-usb-hid-pm.rules
Reading rules file: /lib64/udev/rules.d/50-firmware.rules
Reading rules file: /lib64/udev/rules.d/50-udev-default.rules
Reading rules file: /etc/udev/rules.d/52-digilent-usb.rules
Reading rules file: /lib64/udev/rules.d/56-hpmud.rules
Reading rules file: /lib64/udev/rules.d/60-cdrom_id.rules
Reading rules file: /lib64/udev/rules.d/60-drm.rules
Reading rules file: /lib64/udev/rules.d/60-keyboard.rules
Reading rules file: /lib64/udev/rules.d/60-persistent-alsa.rules
Reading rules file: /lib64/udev/rules.d/60-persistent-input.rules
Reading rules file: /lib64/udev/rules.d/60-persistent-serial.rules
Reading rules file: /lib64/udev/rules.d/60-persistent-storage-tape.rules
Reading rules file: /lib64/udev/rules.d/60-persistent-storage.rules
Reading rules file: /lib64/udev/rules.d/60-persistent-v4l.rules
Reading rules file: /lib64/udev/rules.d/61-accelerometer.rules
Reading rules file: /run/udev/rules.d/61-dev-root-link.rules
Reading rules file: /lib64/udev/rules.d/64-btrfs.rules
Reading rules file: /lib64/udev/rules.d/70-udev-acl.rules
Reading rules file: /lib64/udev/rules.d/75-net-description.rules
Reading rules file: /lib64/udev/rules.d/75-probe_mtd.rules
Reading rules file: /lib64/udev/rules.d/75-tty-description.rules
Reading rules file: /lib64/udev/rules.d/78-sound-card.rules
Reading rules file: /lib64/udev/rules.d/80-drivers.rules
Reading rules file: /lib64/udev/rules.d/80-net-setup-link.rules
Reading rules file: /lib64/udev/rules.d/80-udisks2.rules
Reading rules file: /lib64/udev/rules.d/85-regulatory.rules
Reading rules file: /lib64/udev/rules.d/90-alsa-restore.rules
Reading rules file: /lib64/udev/rules.d/90-network.rules
Reading rules file: /lib64/udev/rules.d/95-udev-late.rules
Reading rules file: /lib64/udev/rules.d/95-upower-battery-recall-dell.rules
Reading rules file: /lib64/udev/rules.d/95-upower-battery-recall-fujitsu.rules
Reading rules file: /lib64/udev/rules.d/95-upower-battery-recall-gateway.rules
Reading rules file: /lib64/udev/rules.d/95-upower-battery-recall-ibm.rules
Reading rules file: /lib64/udev/rules.d/95-upower-battery-recall-lenovo.rules
Reading rules file: /lib64/udev/rules.d/95-upower-battery-recall-toshiba.rules
Reading rules file: /lib64/udev/rules.d/95-upower-csr.rules
Reading rules file: /lib64/udev/rules.d/95-upower-hid.rules
Reading rules file: /lib64/udev/rules.d/95-upower-wup.rules
Reading rules file: /lib64/udev/rules.d/97-hid2hci.rules
rules contain 49152 bytes tokens (4096 * 12 bytes), 12512 bytes strings
2501 strings (28205 bytes), 1749 de-duplicated (16446 bytes), 753 trie nodes used
IMPORT builtin 'path_id' /lib64/udev/rules.d/60-persistent-serial.rules:9
LINK 'serial/by-path/pci-0000:00:13.0-usb-0:2:2.0-port0' /lib64/udev/rules.d/60-persistent-serial.rules:11
IMPORT builtin 'usb_id' /lib64/udev/rules.d/60-persistent-serial.rules:13
/sys/devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0: if_class 255 protocol 0
LINK 'serial/by-id/usb-Texas_Instruments_MSP-FET430UIF_JTAG_Tool_TUSB3410172ECD5EF754FF89-if00-port0' /lib64/udev/rules.d/60-persistent-serial.rules:18
IMPORT builtin skip 'usb_id' /lib64/udev/rules.d/75-tty-description.rules:6
IMPORT builtin 'hwdb' /lib64/udev/rules.d/75-tty-description.rules:6
handling device node '/dev/ttyUSB0', devnum=c188:0, mode=0600, uid=0, gid=0
preserve permissions /dev/ttyUSB0, 020600, uid=0, gid=0
preserve already existing symlink '/dev/char/188:0' to '../ttyUSB0'
found 'c188:0' claiming '/run/udev/links//serial/by-id/usb-Texas_Instruments_MSP-FET430UIF_JTAG_Tool_TUSB3410172ECD5EF754FF89-if00-port0'
creating link '/dev/serial/by-id/usb-Texas_Instruments_MSP-FET430UIF_JTAG_Tool_TUSB3410172ECD5EF754FF89-if00-port0' to '/dev/ttyUSB0'
preserve already existing symlink '/dev/serial/by-id/usb-Texas_Instruments_MSP-FET430UIF_JTAG_Tool_TUSB3410172ECD5EF754FF89-if00-port0' to '../../ttyUSB0'
found 'c188:0' claiming '/run/udev/links//serial/by-path/pci-0000:00:13.0-usb-0:2:2.0-port0'
creating link '/dev/serial/by-path/pci-0000:00:13.0-usb-0:2:2.0-port0' to '/dev/ttyUSB0'
preserve already existing symlink '/dev/serial/by-path/pci-0000:00:13.0-usb-0:2:2.0-port0' to '../../ttyUSB0'
unable to create temporary db file '/run/udev/data/c188:0.tmp': Permission denied
.ID_PORT=0
ACTION=add
DEVLINKS=/dev/serial/by-id/usb-Texas_Instruments_MSP-FET430UIF_JTAG_Tool_TUSB3410172ECD5EF754FF89-if00-port0 /dev/serial/by-path/pci-0000:00:13.0-usb-0:2:2.0-port0
DEVNAME=/dev/ttyUSB0
DEVPATH=/devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0/ttyUSB0/tty/ttyUSB0
ID_BUS=usb
ID_MODEL=MSP-FET430UIF_JTAG_Tool
ID_MODEL_ENC=MSP-FET430UIF JTAG Tool
ID_MODEL_FROM_DATABASE=MSP-FET430UIF JTAG Tool
ID_MODEL_ID=f430
ID_PATH=pci-0000:00:13.0-usb-0:2:2.0
ID_PATH_TAG=pci-0000_00_13_0-usb-0_2_2_0
ID_REVISION=0101
ID_SERIAL=Texas_Instruments_MSP-FET430UIF_JTAG_Tool_TUSB3410172ECD5EF754FF89
ID_SERIAL_SHORT=TUSB3410172ECD5EF754FF89
ID_TYPE=generic
ID_USB_CLASS_FROM_DATABASE=Vendor Specific Class
ID_USB_DRIVER=ti_usb_3410_5052
ID_USB_INTERFACES=:ff0000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Texas_Instruments
ID_VENDOR_ENC=Texas Instruments
ID_VENDOR_FROM_DATABASE=Texas Instruments, Inc.
ID_VENDOR_ID=0451
MAJOR=188
MINOR=0
SUBSYSTEM=tty
USEC_INITIALIZED=33057949
unload module index
Unloaded link configuration context.

(I have to confess I'm not sure what I should be seeing in the udevadm test output).

In summary, why isn't the group getting changed?

P.S. There was a rule setting the group to uucp, but I commented out that rule for simplicity. It was in the /lib64/udev/rules.d/50-udev-default.rules file, so if I understand correct my rule would've had precedence anyway.

Output of udevadm info -a /dev/ttyUSB0:

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0/ttyUSB0/tty/ttyUSB0':
    KERNEL=="ttyUSB0"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0/ttyUSB0':
    KERNELS=="ttyUSB0"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="ti_usb_3410_5052_1"
    ATTRS{port_number}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0':
    KERNELS=="2-2:2.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="ti_usb_3410_5052"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{bNumEndpoints}=="03"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:13.0/usb2/2-2':
    KERNELS=="2-2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="2"
    ATTRS{idVendor}=="0451"
    ATTRS{speed}=="12"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="2"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{busnum}=="2"
    ATTRS{devnum}=="3"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="100mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="a0"
    ATTRS{bNumConfigurations}=="2"
    ATTRS{maxchild}=="0"
    ATTRS{bcdDevice}=="0101"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="TUSB3410172ECD5EF754FF89"
    ATTRS{version}==" 1.10"
    ATTRS{urbnum}=="13"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Texas Instruments"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="f430"
    ATTRS{bDeviceClass}=="ff"
    ATTRS{product}=="MSP-FET430UIF JTAG Tool"

  looking at parent device '/devices/pci0000:00/0000:00:13.0/usb2':
    KERNELS=="usb2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="0"
    ATTRS{idVendor}=="1d6b"
    ATTRS{speed}=="12"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{authorized_default}=="1"
    ATTRS{busnum}=="2"
    ATTRS{devnum}=="1"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="0mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="2"
    ATTRS{bcdDevice}=="0318"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="0000:00:13.0"
    ATTRS{version}==" 1.10"
    ATTRS{urbnum}=="49"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 3.18.12-gentoo ohci_hcd"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="0001"
    ATTRS{bDeviceClass}=="09"
    ATTRS{product}=="OHCI PCI host controller"

  looking at parent device '/devices/pci0000:00/0000:00:13.0':
    KERNELS=="0000:00:13.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ohci-pci"
    ATTRS{irq}=="16"
    ATTRS{subsystem_vendor}=="0x1028"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0310"
    ATTRS{driver_override}=="(null)"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{local_cpus}=="ffffffff"
    ATTRS{device}=="0x4387"
    ATTRS{enable}=="1"
    ATTRS{msi_bus}=="1"
    ATTRS{local_cpulist}=="0-31"
    ATTRS{vendor}=="0x1002"
    ATTRS{subsystem_device}=="0x01fc"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
  • Do you in fact have a plugdev group in /etc/group? Which distribution and version are you using (Gentoo) ? – Jonathan Ben-Avraham May 18 '15 at 21:05
  • @JonathanBen-Avraham Yes, I've checked, I do have a plugdev group (also happen to already be a member of it w/ the user I want). And yes, I'm a gentoo user. – CrazyCasta May 20 '15 at 8:04
  • @CrazyCasta, does commenting that rule solved your problem? – user.dz Jul 12 '15 at 17:10
  • @Sneetsher No, commenting it out changed the group back to the default (root) but my rule still had no effect. – CrazyCasta Jul 13 '15 at 14:38
  • @CrazyCasta, Could you post output of udevadm info -a /dev/ttyUSB0? – user.dz Jul 13 '15 at 14:44
1
  • You target the wrong node. Your current rule:

    SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="f430"
    

    matches this node:

    /devices/pci0000:00/0000:00:13.0/usb2/2-2
    
  • Where you should target the leaf node which match your device /dev/ttyUSB0 ie:

    /devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0/ttyUSB0/tty/ttyUSB0
    

    or may be:

    /devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0/ttyUSB0
    

    Try this one:

    KERNEL=="ttyUSB[0-9]*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f430", MODE="0660", GROUP="plugdev", RUN+="/tmp/test.sh"
    

    Note the difference between SUBSYSTEMS, ATTRS and SUBSYSTEM, ATTR. Check man udev

  • Well, your new rule:

    SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f430", MODE="0660", GROUP="plugdev", RUN+="/tmp/test.sh"
    

    will be triggered for all these nodes:

    /devices/pci0000:00/0000:00:13.0/usb2/2-2
    /devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0
    /devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0/ttyUSB0
    /devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0/ttyUSB0/tty/ttyUSB0
    

|improve this answer|||||
  • 1
    I dropped the KERNEL== part and used SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f430", MODE="0660", GROUP="plugdev", RUN+="/tmp/test.sh" and it worked. Just seeing if I understand the man page correct, is it saying that SUBSYSTEMS and ATTRS are basically recursive or w/e you want to call it and SUBSYSTEM and ATTR have to match the exact device node? – CrazyCasta Jul 13 '15 at 17:49
  • @CrazyCasta, Yes, but only toward child nodes. let me update answer – user.dz Jul 13 '15 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.