execuc / u2if

USB to interfaces implementing MicroPython "machine" module functionalities on a computer.
Other
155 stars 27 forks source link

Udev rule not working #1

Open pak-man opened 3 years ago

pak-man commented 3 years ago

For any reason, it seems the udev rule is not working, which is weird because it´s syntactically correct. Whenever I change manually the rights on /dev/hidraw1 I can execute some code but as soon as the code ends, the rights are changed back to 600. changing the udev rule to: SUBSYSTEM=="usbhid", ATTR{idVendor}=="cafe", ATTR{idProduct}=="4005", MODE="0666" has no effect. When adding an action to the rule, the script is not interpreted. Here is what udevadm monitor says when I plug-unplug the RP2040 board flashed running the u2if firmware, compiled from source, (af31706)

KERNEL[10776.365159] add /devices/pci0000:00/0000:00:14.0/usb2/2-6 (usb) KERNEL[10776.367501] change /devices/pci0000:00/0000:00:14.0/usb2/2-6 (usb) KERNEL[10776.367759] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 (usb) KERNEL[10776.368106] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/tty/ttyACM0 (tty) KERNEL[10776.368192] bind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 (usb) KERNEL[10776.368253] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.1 (usb) KERNEL[10776.368310] bind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.1 (usb) KERNEL[10776.368560] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2 (usb) KERNEL[10776.369569] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022 (hid) KERNEL[10776.369618] add /class/usbmisc (class) KERNEL[10776.369759] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/usbmisc/hiddev0 (usbmisc) KERNEL[10776.370026] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022/hidraw/hidraw1 (hidraw) KERNEL[10776.370091] bind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022 (hid) KERNEL[10776.370144] bind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2 (usb) KERNEL[10776.370200] bind /devices/pci0000:00/0000:00:14.0/usb2/2-6 (usb) UDEV [10776.370576] add /class/usbmisc (class) UDEV [10776.381484] add /devices/pci0000:00/0000:00:14.0/usb2/2-6 (usb) UDEV [10776.394132] change /devices/pci0000:00/0000:00:14.0/usb2/2-6 (usb) UDEV [10776.398635] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 (usb) UDEV [10776.398980] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.1 (usb) UDEV [10776.401738] bind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.1 (usb) UDEV [10776.401890] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2 (usb) UDEV [10776.403834] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/tty/ttyACM0 (tty) UDEV [10776.405416] bind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 (usb) UDEV [10776.405779] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/usbmisc/hiddev0 (usbmisc) UDEV [10776.411430] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022 (hid) UDEV [10776.415320] add /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022/hidraw/hidraw1 (hidraw) UDEV [10776.416902] bind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022 (hid) UDEV [10776.417782] bind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2 (usb) UDEV [10776.422553] bind /devices/pci0000:00/0000:00:14.0/usb2/2-6 (usb) KERNEL[10850.835526] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/tty/ttyACM0 (tty) KERNEL[10850.835582] unbind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.1 (usb) KERNEL[10850.835611] unbind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 (usb) KERNEL[10850.835642] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 (usb) KERNEL[10850.835672] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.1 (usb) KERNEL[10850.835820] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/usbmisc/hiddev0 (usbmisc) KERNEL[10850.835844] remove /class/usbmisc (class) KERNEL[10850.835867] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022/hidraw/hidraw1 (hidraw) KERNEL[10850.835893] unbind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022 (hid) KERNEL[10850.835922] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022 (hid) KERNEL[10850.835946] unbind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2 (usb) KERNEL[10850.835975] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2 (usb) KERNEL[10850.836487] unbind /devices/pci0000:00/0000:00:14.0/usb2/2-6 (usb) KERNEL[10850.836564] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6 (usb) UDEV [10850.838048] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/tty/ttyACM0 (tty) UDEV [10850.838755] unbind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.1 (usb) UDEV [10850.839523] remove /class/usbmisc (class) UDEV [10850.839890] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.1 (usb) UDEV [10850.840796] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/usbmisc/hiddev0 (usbmisc) UDEV [10850.842037] unbind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 (usb) UDEV [10850.842621] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022/hidraw/hidraw1 (hidraw) UDEV [10850.843225] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 (usb) UDEV [10850.843259] unbind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022 (hid) UDEV [10850.843839] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2/0003:CAFE:4005.0022 (hid) UDEV [10850.844845] unbind /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2 (usb) UDEV [10850.845521] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.2 (usb) UDEV [10850.846463] unbind /devices/pci0000:00/0000:00:14.0/usb2/2-6 (usb) UDEV [10850.847146] remove /devices/pci0000:00/0000:00:14.0/usb2/2-6 (usb)

The error thrown is always the same: HIDException: unable to open device The Correct VID and PID is passed to the python HID lib, but no serial.

Well, and I´m using the Python example in a venv with jupyter-lab on Debian 11. (kernel 5.10.06) I´ve tested the udev rule on Fedora 33 (kernel 5.11.11) and it´s same: the correct rights never are applied.

execuc commented 3 years ago

Hello, I'm very sorry if it doesn't work. I am far from being an expert in udev but I will try to help.

Indeed, the connection to the firmware is done in two stages:

The serial number is used in the event that there is more than one pico with this firmware connected at the same time.

I have a Debian 10 and in my case /dev/ttyACM0 is created but with the rights crw-rw ---- + 1 root dialout 166. If it returns the same, you could check with the "groups" command if you are in the "dialout" group. I am also in the tty group but I do not know if it is useful in this case.

For the /dev/hidraw, I don't know how it works, because it doesn't seem to have the rights to be opened but it still works with the udev rules. Without this I had to run the python script as root.