Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access blink device via hidraw if it's been opened with libusb #28

Open
normanr opened this issue Jun 6, 2020 · 3 comments
Open

Comments

@normanr
Copy link
Contributor

normanr commented Jun 6, 2020

I thought that the 2.1.0 release can't find mk1 devices:

$ blink1-tool-v2.1.0 --list
no blink(1) devices found

The 2.0.5 release shows it fine:

$ blink1-tool-v2.0.5 --list
blink(1) list: 
id:0 - serialnum:<omitted> (mk1) fw version:100

but if I re-plug the device then the 2.1.0 release works fine:

$ ./blink1-tool-v2.1.0 --list
blink(1) list: 
id:0 - serialnum:<omitted> (mk1) fw version:100

The device appears as:

$ dmesg
usb 1-3.3.1: New USB device found, idVendor=27b8, idProduct=01ed, bcdDevice= 1.00
usb 1-3.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-3.3.1: Product: blink(1)
usb 1-3.3.1: Manufacturer: ThingM
usb 1-3.3.1: SerialNumber: <omitted>
hid-led 0003:27B8:01ED.01A8: hidraw4: USB HID v1.01 Device [ThingM blink(1)] on usb-0000:00:14.0-3.3.1/input0
hid-led 0003:27B8:01ED.01A8: ThingM blink(1) v1 initialized
$ ls /dev/hidraw4
crw-rw---- 1 root plugdev 248, 4 Jun  5 16:50 /dev/hidraw4
$ ls /sys/class/leds/thingm*
'/sys/class/leds/thingm4:blue':
brightness  device  max_brightness  power  subsystem  trigger  uevent

'/sys/class/leds/thingm4:green':
brightness  device  max_brightness  power  subsystem  trigger  uevent

'/sys/class/leds/thingm4:red':
brightness  device  max_brightness  power  subsystem  trigger  uevent

but after running the v2.0.5 binary (nothing extra appears in dmesg):

$ ls /dev/hidraw4
ls: cannot access '/dev/hidraw4': No such file or directory
$ ls /sys/class/leds/thingm*
ls: cannot access '/sys/class/leds/thingm*': No such file or directory

Re-plugging the device is fine if you have one or two of them, not if you have many. Luckily it looks like the device can be re-bound to re-create the hidraw devices:

$ echo -n "1-3.3.1:1.0" | sudo tee /sys/bus/usb/drivers/usbhid/bind > /dev/null

I assume there's not much the blink1-tool could do about this (particularly if running as a non-root user), but the documentation could call this out, and maybe the no blink(1) devices found error message could be updated to suggest running the above command (the hard part is figuring out the device id to rebind)?

@todbot
Copy link
Owner

todbot commented Sep 13, 2020

Hi @normanr
If this is for a blink(1) mk1 (the one the with silver top and a single LED), then it may be an issue with the mk1. If you'd like a blink(1) mk3 to test with, send us an email at blink1 at thingm.com with your shipping address and we'll mail one off to you at no cost.

@normanr
Copy link
Contributor Author

normanr commented Sep 14, 2020

Thank you for the offer. I've sent you an email.

@normanr
Copy link
Contributor Author

normanr commented Sep 21, 2020

I've received the mk3, and the issue reported also applies to it too.

It seems that this is a 'well known' issue, eg: https://skyboo.net/2018/10/binding-unbinding-usb-drivers-a-k-a-who-stole-my-hidraw1-device-file/. I can't figure out if it's libusb or the kernel usb driver that's unbinding the hidraw driver, but I don't think it matters too much. I think it's still worth calling out in the 2.1.0 release notes where hidraw is mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants