1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-10 15:30:55 +00:00

revert usb reset related commits

As it stands, they cause more harm than good for a point release.
This code will be returned later, when it is more mature
This commit is contained in:
matejcik 2019-02-26 17:59:18 +01:00
parent 0a8b5a08c2
commit 697f86210f
4 changed files with 6 additions and 33 deletions

View File

@ -22,7 +22,6 @@ _At the moment, the project does __not__ adhere to [Semantic Versioning](http://
- Cardano: change `network` to `protocol_magic` - Cardano: change `network` to `protocol_magic`
- tests can run interactively when `INTERACT=1` environment variable is set - tests can run interactively when `INTERACT=1` environment variable is set
- protobuf: improved `to_dict` function - protobuf: improved `to_dict` function
- webusb: issue device reset before connecting (fixes weird device states)
### Deprecated ### Deprecated
- trezorctl: interactive signing with `sign-tx` is considered deprecated - trezorctl: interactive signing with `sign-tx` is considered deprecated

View File

@ -374,8 +374,7 @@ def wipe_device(connect, bootloader):
click.echo("Wiping user data!") click.echo("Wiping user data!")
try: try:
device.wipe(client) return device.wipe(connect())
click.echo("Device wiped")
except tools.CallException as e: except tools.CallException as e:
click.echo("Action failed: {} {}".format(*e.args)) click.echo("Action failed: {} {}".format(*e.args))
sys.exit(3) sys.exit(3)

View File

@ -45,7 +45,6 @@ class TrezorDevice:
@expect(proto.Success, field="message") @expect(proto.Success, field="message")
@session
def apply_settings( def apply_settings(
client, client,
label=None, label=None,
@ -75,7 +74,6 @@ def apply_settings(
@expect(proto.Success, field="message") @expect(proto.Success, field="message")
@session
def apply_flags(client, flags): def apply_flags(client, flags):
out = client.call(proto.ApplyFlags(flags=flags)) out = client.call(proto.ApplyFlags(flags=flags))
client.init_device() # Reload Features client.init_device() # Reload Features
@ -83,7 +81,6 @@ def apply_flags(client, flags):
@expect(proto.Success, field="message") @expect(proto.Success, field="message")
@session
def change_pin(client, remove=False): def change_pin(client, remove=False):
ret = client.call(proto.ChangePin(remove=remove)) ret = client.call(proto.ChangePin(remove=remove))
client.init_device() # Re-read features client.init_device() # Re-read features
@ -96,26 +93,14 @@ def set_u2f_counter(client, u2f_counter):
return ret return ret
def wipe(client) -> bool: @expect(proto.Success, field="message")
"""Initiate device wipe. def wipe(client):
ret = client.call(proto.WipeDevice())
Returns whether it's safe to continue using the client instance.
(see comment in `WebUsbHandle.open`)
"""
# This is not marked @session by design: the subsequent init_device should run
# in a separate session, so that when it triggers a USB error, a subsequent
# re-enumeration fixes it. See comment in WebUsbHandle.open
# XXX this should actually call the USB reset explicitly
client.call(proto.WipeDevice())
try:
client.init_device() client.init_device()
return True return ret
except Exception:
return False
@expect(proto.Success, field="message") @expect(proto.Success, field="message")
@session
def recover( def recover(
client, client,
word_count=24, word_count=24,

View File

@ -53,16 +53,6 @@ class WebUsbHandle:
else: else:
args = () args = ()
raise IOError("Cannot open device", *args) raise IOError("Cannot open device", *args)
self.handle.resetDevice()
# XXX this may fail with LIBUSB_ERROR_NOT_FOUND
# This will usually happen after device wipe, because USB serial has changed,
# and requires re-enumeration and reacquiring of the device.
# I haven't found a reasonable way of handling it here, or in the enumeration
# step. (In particular, it seems impossible to force libusb to re-enumerate
# explicitly, without calling device reset.)
# So now I'm just leaving it here to crash in some cases.
self.handle.claimInterface(self.interface) self.handle.claimInterface(self.interface)
def close(self) -> None: def close(self) -> None: