Close

UDEV for linux

A project log for USBShare.exe

Replacing unknown exe with opensource

stephengeorgeweststephengeorgewest 09/18/2021 at 17:482 Comments

Doesn't work on linux. Udev strikes again. udev helper things:

sudo udevadm control --reload-rules
sudo udevadm trigger
journalctl -f
udevadm monitor --environment
udevadm info -q all -a /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-2
udevadm info -q all -a /dev/hidraw1
sudo udevadm control --log-priority=dubug

run udevadm monitor --environment and re-plug:

stephen@AO751h:~$ udevadm info -q all -a /dev/hidraw1

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:1d.0/usb2/2-2/2-2:1.0/0003:1A86:E041.000E/hidraw/hidraw1':
    KERNEL=="hidraw1"
    SUBSYSTEM=="hidraw"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0/0003:1A86:E041.000E':
    KERNELS=="0003:1A86:E041.000E"
    SUBSYSTEMS=="hid"
    DRIVERS=="hid-generic"
    ATTRS{country}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0':
    KERNELS=="2-2:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{authorized}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-2':
    KERNELS=="2-2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="1000"
    ATTRS{bmAttributes}=="80"
    ATTRS{busnum}=="2"
    ATTRS{configuration}==""
    ATTRS{devnum}=="12"
    ATTRS{devpath}=="2"
    ATTRS{idProduct}=="e041"
    ATTRS{idVendor}=="1a86"
    ATTRS{ltm_capable}=="no"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{rx_lanes}=="1"
    ATTRS{speed}=="12"
    ATTRS{tx_lanes}=="1"
    ATTRS{urbnum}=="14"
    ATTRS{version}==" 1.10"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2':
    KERNELS=="usb2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="0504"
    ATTRS{bmAttributes}=="e0"
    ATTRS{busnum}=="2"
    ATTRS{configuration}==""
    ATTRS{devnum}=="1"
    ATTRS{devpath}=="0"
    ATTRS{idProduct}=="0001"
    ATTRS{idVendor}=="1d6b"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 5.4.0-77-generic uhci_hcd"
    ATTRS{maxchild}=="2"
    ATTRS{product}=="UHCI Host Controller"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{rx_lanes}=="1"
    ATTRS{serial}=="0000:00:1d.0"
    ATTRS{speed}=="12"
    ATTRS{tx_lanes}=="1"
    ATTRS{urbnum}=="207"
    ATTRS{version}==" 1.10"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0':
    KERNELS=="0000:00:1d.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="uhci_hcd"
    ATTRS{ari_enabled}=="0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0300"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{d3cold_allowed}=="0"
    ATTRS{device}=="0x8114"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="23"
    ATTRS{local_cpulist}=="0-1"
    ATTRS{local_cpus}=="3"
    ATTRS{msi_bus}=="1"
    ATTRS{revision}=="0x07"
    ATTRS{subsystem_device}=="0x0244"
    ATTRS{subsystem_vendor}=="0x1025"
    ATTRS{vendor}=="0x8086"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
udevadm info -q all -a /dev/hidraw1

Seems that the rule

KERNEL=="hidraw*", ATTR{idVendor}=="1a86", ATTR{idProduct}=="e041", MODE="0666"

doesn't catch vendor/product parameters. I guess I'll stick with

KERNEL=="hidraw*", MODE="0666", GROUP="plugdev"

Discussions

Ken Yap wrote 09/19/2021 at 00:12 point

Hmm? I don't use KERNEL bur rather SUBSYSTEM. My rules look like:

# Set Group for STLink-2
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", GROUP="dialout"

and it works.

  Are you sure? yes | no

stephengeorgewest wrote 09/19/2021 at 20:49 point

Thanks, that got me to a working rule for this device.

I originally had:

SUBSYSTEM=="usb",  ATTR{idVendor}=="1a86", ATTR{idProduct}=="e041", MODE="0666", GROUP="plugdev"

and that worked for WebUSB, which accesses /sys/bus/usb/devices/*, but I needed WebHID, I noticed the ATTR / ATTRS difference so I changed it to:

KERNEL=="hidraw*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e041", MODE="0664", GROUP="plugdev"

and it seems to work.

SUBSYSTEM=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e041", MODE="0666", GROUP="plugdev"

Also seems to work. I guess the differences is between allowing all usb control, or just hidraw*. Now looking at the output of

udevadm info -q all -a /dev/hidraw1

I don't see any ATTR without the S. I guess it is different between the /dev/hidraw* and /sys/bus/usb/devices*?

udevadm info  -q all -a /sys/bus/usb/devices/2-0:1.0

has ATTR without S, but only at the top level, and none of them are vendor/product. Maybe I was just wrong in the from the get go.

  Are you sure? yes | no