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

TREZOR T is displayed twice on Windows 10 in libusb listing, with the same path #165

Closed
karelbilek opened this issue Mar 11, 2018 · 7 comments

Comments

@karelbilek
Copy link
Contributor

karelbilek commented Mar 11, 2018

TREZOR T is displayed twice on Windows in libusb listing, with the same path. One of the listed devices then don't work (sometimes first and sometimes second, it seems random).

This behaviour doesn't happen in TREZOR Model One with the WebUSB enabled (from master).

This is observable in python-trezor, or in TREZOR Bridge that uses libusb. TREZOR Bridge currently fails in around 50% of cases because of this.

It is fixable in TREZOR Bridge (trezor/trezord-go#28), but it should be fixed here.

I have made a simple GUI tool in go, that displays the number of TREZOR devices that libusb lists. This tool should work on GNU/Linux and macOS, but there is no reason for that currently.

package main

import (
	"strconv"
	"time"

	"github.com/andlabs/ui"
	"github.com/trezor/trezord-go/usb"
)

func main() {
	check(ui.Main(func() {

		status := ui.NewLabel("0")
		box := ui.NewVerticalBox()

		box.Append(status, false)
		window := ui.NewWindow("Trezor Detect", 50, 50, false)
		window.SetMargined(true)
		window.SetChild(box)

		window.OnClosing(func(*ui.Window) bool {
			ui.Quit()
			return true
		})
		window.Show()

		w, err := usb.InitWebUSB()
		check(err)
		go func() {
			for {
				devs, err := w.Enumerate()
				check(err)

				status.SetText(strconv.Itoa(len(devs)))
				time.Sleep(500 * time.Millisecond)
			}
		}()

	}))

}

func check(e error) {
	if e != nil {
		panic(e)
	}
}

This correctly displays 1 in TREZOR T bootloader and TREZOR Model One with WebUSB enabled. It displays 2 with TREZOR T regular firmware.

(Note that the tool starts showing 1 with the linked trezord-go PR)

@karelbilek karelbilek changed the title TREZOR T is displayed twice on Windows 10 in Libusb listing, with the same path TREZOR T is displayed twice on Windows 10 in libusb listing, with the same path Mar 11, 2018
@karelbilek
Copy link
Contributor Author

This is binary of the GUI script, if you don't want to go through the pain of setting golang + git + gcc on windows

bridgebug.zip

@karelbilek
Copy link
Contributor Author

Some users after several wipes/resets apparently start seeing this correctly, with just one device. Which makes this bug still non-deterministic and not easily debuggable.

@karelbilek
Copy link
Contributor Author

From my experimentation, Chrome with WebUSB turned on is similarly non-deterministic, sometimes the device is seen correctly, sometimes it's not. (Again only with TREZOR T)

@slush0 slush0 added the bug label Mar 12, 2018
@mocmocamoc
Copy link

See trezor/python-trezor#223
The problem doesn't seem to happen with libusb 1.0.22-rc3 so it appears to be a libusb bug.

@slush0
Copy link

slush0 commented Mar 13, 2018

Workaround implemented in trezor/trezord-go#28

@slush0
Copy link

slush0 commented Mar 13, 2018

This clearly describes the problem we've been facing: libusb/libusb@71a779d#diff-eaebe812fd3cec44f65977933b49ec6a

Also, trezord seems to work well with libusb rc3, but we need to test it for all platforms first. Implemented workaround is a quick fix which shouldn't have any side effects.

@karelbilek
Copy link
Contributor Author

I am closing this issue here because it is not trezor-core issue

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

No branches or pull requests

4 participants