mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 03:50:58 +00:00
trezorctl: add USB reset command for stuck devices
This commit is contained in:
parent
50fe0d96bb
commit
34052af9db
12
trezorctl
12
trezorctl
@ -774,6 +774,18 @@ def self_test(connect):
|
|||||||
return debuglink.self_test(connect())
|
return debuglink.self_test(connect())
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
def usb_reset():
|
||||||
|
"""Perform USB reset on a stuck device.
|
||||||
|
|
||||||
|
This can fix LIBUSB_ERROR_PIPE and similar errors when connecting to a device
|
||||||
|
in a messed state.
|
||||||
|
"""
|
||||||
|
from trezorlib.transport.webusb import WebUsbTransport
|
||||||
|
|
||||||
|
WebUsbTransport.enumerate(usb_reset=True)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Basic coin functions
|
# Basic coin functions
|
||||||
#
|
#
|
||||||
|
@ -106,7 +106,7 @@ class WebUsbTransport(ProtocolBasedTransport):
|
|||||||
return "%s:%s" % (self.PATH_PREFIX, dev_to_str(self.device))
|
return "%s:%s" % (self.PATH_PREFIX, dev_to_str(self.device))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def enumerate(cls) -> Iterable["WebUsbTransport"]:
|
def enumerate(cls, usb_reset=False) -> Iterable["WebUsbTransport"]:
|
||||||
if cls.context is None:
|
if cls.context is None:
|
||||||
cls.context = usb1.USBContext()
|
cls.context = usb1.USBContext()
|
||||||
cls.context.open()
|
cls.context.open()
|
||||||
@ -128,6 +128,11 @@ class WebUsbTransport(ProtocolBasedTransport):
|
|||||||
devices.append(WebUsbTransport(dev))
|
devices.append(WebUsbTransport(dev))
|
||||||
except usb1.USBErrorNotSupported:
|
except usb1.USBErrorNotSupported:
|
||||||
pass
|
pass
|
||||||
|
except usb1.USBErrorPipe:
|
||||||
|
if usb_reset:
|
||||||
|
handle = dev.open()
|
||||||
|
handle.resetDevice()
|
||||||
|
handle.close()
|
||||||
return devices
|
return devices
|
||||||
|
|
||||||
def find_debug(self) -> "WebUsbTransport":
|
def find_debug(self) -> "WebUsbTransport":
|
||||||
|
Loading…
Reference in New Issue
Block a user