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 open device on macos 14 (sonoma) #40

Closed
felipe-op opened this issue Nov 11, 2023 · 5 comments
Closed

Can't open device on macos 14 (sonoma) #40

felipe-op opened this issue Nov 11, 2023 · 5 comments

Comments

@felipe-op
Copy link

felipe-op commented Nov 11, 2023

Hi,

I'm using this lib indirectly from go-ethereum to interface with a Ledger X device and recently I bumped into this error:

hidapi: failed to open device

This started happening in my Mac with macos 14 (sonoma). Debugging it I noticed the usb.DeviceInfo path got an empty string, which then failed when Open is called.

I tried few things such as:

  • Restart host computer
  • Restart device
  • Change cables
  • Run with sudo
  • Allow full disk access to the binary
  • Install libhid and libusd from scratch (not sure if related)

Nothing worked.

I'm consuming the following versions (copied from go.mod):

	github.com/ethereum/go-ethereum v1.13.4

	github.com/karalabe/usb v0.0.3-0.20230918135828-88ad9302fa2c // indirect

Consuming repo: https://github.com/base-org/eip712sign

Thanks for looking into it!

Please let me know if there is anything I can help with.

@felipe-op
Copy link
Author

Also as a side note, cast send --ledger can interface with device.

@felipe-op felipe-op changed the title Enumerate returns a device with empty path, then Open fails on macos 14 (sonoma) Can't open device on macos 14 (sonoma) Nov 11, 2023
@felipe-op
Copy link
Author

Found a homemade solution to this issue.

When I connect my Ledger, it actually enumerate 3 interfaces, but go-ethereum usbwallet hub arbitrarity picks one. So I decided to change go-ethereum and let it pick the other two. It eventually worked.

The solution requires modifying this file:
https://github.com/ethereum/go-ethereum/blob/d14c07d91e565c0d97cfcee3aa84a08ce08d93bf/accounts/usbwallet/hub.go

And changing the fields usageID and endpointID on line 96.

I changed from 0xffa0, 0 to 0, 2.

I tried to find more documentation from Ledger but didn't find anything useful. Not sure if the patch would work for everybody else, so I'm not proposing a public change. Just sharing my own learning.

@felipe-op
Copy link
Author

felipe-op commented Nov 12, 2023

A little bit more context. Here are the three enumerated devices printed with a simple fmt.Printf("enumerate: %#v", infos)

enumerate: []usb.DeviceInfo{

usb.DeviceInfo{Path:"2c97:4015:01", VendorID:0x2c97, ProductID:0x4015, Release:0x0,   Serial:"",     Manufacturer:"",       Product:"",       UsagePage:0x0,    Usage:0x0, Interface:2,  rawDevice:(*usb._Ctype_struct_libusb_device)(0x6000003cc3c0), rawPort:(*uint8)(0x140002e84a8), rawReader:(*uint8)(0x140002e8498), rawWriter:(*uint8)(0x140002e8499)}, 

usb.DeviceInfo{Path:"",             VendorID:0x2c97, ProductID:0x4015, Release:0x201, Serial:"0001", Manufacturer:"Ledger", Product:"Nano X", UsagePage:0xffa0, Usage:0x1, Interface:-1, rawDevice:interface {}(nil), rawPort:(*uint8)(nil), rawReader:(*uint8)(nil), rawWriter:(*uint8)(nil)}, 

usb.DeviceInfo{Path:"",             VendorID:0x2c97, ProductID:0x4015, Release:0x201, Serial:"0001", Manufacturer:"Ledger", Product:"Nano X", UsagePage:0xf1d0, Usage:0x1, Interface:-1, rawDevice:interface {}(nil), rawPort:(*uint8)(nil), rawReader:(*uint8)(nil), rawWriter:(*uint8)(nil)}

}

@felipe-op
Copy link
Author

You can use this version from: https://github.com/felipe-op/go-ethereum/tree/felipe/fix-ledger

@felipe-op
Copy link
Author

Closed since there is no bug/issue in the lib. Proposed a fix on go-ethereum instead: ethereum/go-ethereum#28516

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

1 participant