Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Enumeration returns multiple devices for Model T (Windows 10) #223

Closed
mocmocamoc opened this issue Mar 2, 2018 · 6 comments
Closed

Enumeration returns multiple devices for Model T (Windows 10) #223

mocmocamoc opened this issue Mar 2, 2018 · 6 comments
Assignees
Labels
Milestone

Comments

@mocmocamoc
Copy link

Connecting a Model T to my Windows 10 machine causes two devices to appear in Device Manager:
-a USB device with Hardware ID USB\VID_1209&PID_53C1&REV_0200&MI_00
-a HID device with Hardware ID HID\VID_1209&PID_53C1&REV_0200&MI_01

Calling TrezorDevice.enumerate() returns both of these devices, but calling open() on the HID device fails while calling open() on the USB device succeeds.

One workaround is to change WebUsbTransport.enumerate() to check whether dev.getProduct() returns successfully and discard the device if it does not.

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from trezorlib.device import TrezorDevice
>>> devs = TrezorDevice.enumerate()
>>> devs
[<trezorlib.transport_webusb.WebUsbTransport object at 0x00000299B3D76630>, <trezorlib.transport_webusb.WebUsbTransport object at 0x00000299B3D767F0>]
>>> hex(devs[0].device.getVendorID()), hex(devs[0].device.getProductID())
('0x1209', '0x53c1')
>>> devs[0].open()
Traceback (most recent call last):
...
usb1.USBErrorNotSupported: LIBUSB_ERROR_NOT_SUPPORTED [-12]
>>> hex(devs[1].device.getVendorID()), hex(devs[1].device.getProductID())
('0x1209', '0x53c1')
>>> devs[1].open()
>>>
@matejcik
Copy link
Contributor

matejcik commented Mar 5, 2018

I swear I saw the problem on Friday, but today I can't reproduce. I see both devices just as you say, but enumerate is returning only the correct one.

I tried to install about eleventy different libusb drivers at once, maybe it's a problem with a specific one that is not in use now?
I'm using libusb 1.0.21 DLL and libusbK driver. What are you using?

@mocmocamoc
Copy link
Author

I'm also using libusb 1.0.21. I haven't installed libusbK, the devices are using the drivers that Windows automatically installed for them, so winusb.sys for the USB instance.

@matejcik matejcik self-assigned this Mar 5, 2018
@matejcik
Copy link
Contributor

matejcik commented Mar 5, 2018

Huh.
I managed to reproduce. It only happens when another HID device (apart from Trezor) is connected. I couldn't see it earlier because I'm testing in a VM and the bug only appeared when I connected Trezor 1, which is also a HID device... I presume that on normal setups, there's going to be a keyboard and mouse to trigger the problem :)

This seems to be a libusb bug in any case. But perhaps your proposed workaround is a good idea anyway.

@mocmocamoc
Copy link
Author

I've just built libusb 1.0.22-rc3 and the issue does not happen with that version, so I guess they've already caught and fixed this!

@matejcik
Copy link
Contributor

matejcik commented Mar 6, 2018

I implemented the workaround you proposed here: https://github.com/matejcik/python-trezor/commit/9f2583f893ebf206d72025f4041d55b212992c1b

this will be merged as part of #226

@karelbilek
Copy link
Contributor

karelbilek commented Mar 13, 2018

See the linked issue in trezor-core

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

No branches or pull requests

3 participants