-
Notifications
You must be signed in to change notification settings - Fork 40
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
update hidapi, use hidraw
on linux (instead of libusb)
#43
Conversation
With the latest code (in this PR), plus switching to linux-specifc code instead of generic, a Ledger Nano X is identified as follows:
On
|
Re "using linux-specific code on linux" -- it's not so simple. As stated in https://github.com/libusb/hidapi#hidapi-has-four-back-ends , what this PR does is switch from 3 to 2. Is that preferrable? I am not 100% sure. Docs say "There are tradeoffs, and the functionality supported is slightly different. ", but doesn't go into more details. 🤷 HIDAPI has four back-ends:
On Linux, either the hidraw or the libusb back-end can be used. There are tradeoffs, and the functionality supported is slightly different. Both are built by default. It is up to the application linking to hidapi to choose the backend at link time by linking to either libhidapi-libusb or libhidapi-hidraw. Note that you will need to install an udev rule file with your application for unprivileged users to be able to access HID devices with hidapi. Refer to the 69-hid.rules file in the udev directory for an example. Linux/hidraw (linux/hid.c):This back-end uses the hidraw interface in the Linux kernel, and supports both USB and Bluetooth HID devices. It requires kernel version at least 2.6.39 to build. In addition, it will only communicate with devices which have hidraw nodes associated with them. Keyboards, mice, and some other devices which are blacklisted from having hidraw nodes will not work. Fortunately, for nearly all the uses of hidraw, this is not a problem. Linux/FreeBSD/libusb (libusb/hid.c):This back-end uses libusb-1.0 to communicate directly to a USB device. This back-end will of course not work with Bluetooth devices. |
With this PR I'm seeing about the exact same output as you. Only difference appears to be how the OS Path is represented
|
hidraw
on linux (instead of libusb)
I tested this in go-ethereum: diff --git a/go.mod b/go.mod
index 8f99a00754..54bf9780b1 100644
--- a/go.mod
+++ b/go.mod
@@ -141,3 +141,4 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
+replace github.com/karalabe/usb => /home/user/go/src/github.com/karalabe/usb Ledger nano X discovery / derivation worked fine. It will match on the same device, |
Note to self: need to add back the dummy.go files |
Closing this in favour of a pure-hid-update in either karalabe/hid#44 (and then use hid in go-ethereum), OR ethereum/go-ethereum#28901 |
This is work in progress.
libudev
when building)