MSP-FET430UIF USB 프로그래머에서 그룹을 변경하기 위해 udev 규칙을 작성하려고 합니다. 이것이 내가 지금까지 가지고 있는 것입니다(파일 이름 /etc/udev/rules.d/40-ti-fet430.rules
):
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="f430", MODE="0660", GROUP="plugdev", RUN+="/tmp/test.sh"
실행 명령(날짜만 /tmp/test로 리디렉션)이 실행 중입니다. 그러나 /dev/ttyUSB0 장치의 그룹 및 권한은 변경되지 않습니다.
$ ls -l /dev/ttyUSB0
crw------- 1 root root 188, 0 May 18 13:05 /dev/ttyUSB0
이것은 다음의 출력입니다 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.
udevadm test
( 출력에서 무엇을 봐야 할지 확신할 수 없다는 점을 인정해야 합니다 ).
대체적으로 그룹은 왜 바뀌지 않았나요?
PS 그룹을 uucp로 설정하는 규칙이 있지만 단순화를 위해 이를 주석 처리했습니다. /lib64/udev/rules.d/50-udev-default.rules
파일 에 있으므로 올바르게 이해하면 어쨌든 내 규칙이 우선 적용됩니다.
출력 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==""
답변1
잘못된 노드를 타겟팅하고 있습니다. 현재 규칙:
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="f430"
다음 노드와 일치:
/devices/pci0000:00/0000:00:13.0/usb2/2-2
/dev/ttyUSB0
장치 와 일치하는 리프 노드를 어디에서 찾아야 합니까 ?/devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0/ttyUSB0/tty/ttyUSB0
아니면:
/devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:2.0/ttyUSB0
이 시도:
KERNEL=="ttyUSB[0-9]*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f430", MODE="0660", GROUP="plugdev", RUN+="/tmp/test.sh"
SUBSYSTEMS
ATTRS
, 및SUBSYSTEM
의 차이점에 유의하세요ATTR
. 확인하다man udev
좋습니다. 새로운 규칙은 다음과 같습니다.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f430", MODE="0660", GROUP="plugdev", RUN+="/tmp/test.sh"
다음 모든 노드에 대해 트리거됩니다.
/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