mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-05 22:32:33 +00:00
trezorctl: make wipe_device bootloader aware
This commit is contained in:
parent
73f016c465
commit
2f02b972d1
25
trezorctl
25
trezorctl
@ -282,9 +282,30 @@ def set_u2f_counter(connect, counter):
|
|||||||
|
|
||||||
|
|
||||||
@cli.command(help='Reset device to factory defaults and remove all private data.')
|
@cli.command(help='Reset device to factory defaults and remove all private data.')
|
||||||
|
@click.option('-b', '--bootloader', help='Wipe device in bootloader mode. This also erases the firmware.', is_flag=True)
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def wipe_device(connect):
|
def wipe_device(connect, bootloader):
|
||||||
|
client = connect()
|
||||||
|
if bootloader:
|
||||||
|
if not client.features.bootloader_mode:
|
||||||
|
click.echo('Please switch your device to bootloader mode.')
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
click.echo('Wiping user data and firmware. Please confirm on your device.')
|
||||||
|
else:
|
||||||
|
if client.features.bootloader_mode:
|
||||||
|
click.echo('Your device is in bootloader mode. This operation would also erase firmware.')
|
||||||
|
click.echo('Specify "--bootloader" if that is what you want, or disconnect and reconnect device in normal mode.')
|
||||||
|
click.echo('Aborting.')
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
click.echo('Wiping user data. Please confirm on your device.')
|
||||||
|
|
||||||
|
try:
|
||||||
return connect().wipe_device()
|
return connect().wipe_device()
|
||||||
|
except CallException as e:
|
||||||
|
click.echo('Action failed: {} {}'.format(*e.args))
|
||||||
|
sys.exit(3)
|
||||||
|
|
||||||
|
|
||||||
@cli.command(help='Load custom configuration to the device.')
|
@cli.command(help='Load custom configuration to the device.')
|
||||||
@ -460,7 +481,7 @@ def firmware_update(connect, filename, url, version, skip_check, fingerprint):
|
|||||||
try:
|
try:
|
||||||
return client.firmware_update(fp=io.BytesIO(fp))
|
return client.firmware_update(fp=io.BytesIO(fp))
|
||||||
except CallException as e:
|
except CallException as e:
|
||||||
if e.args[0] == proto.FailureType.FirmwareError:
|
if e.args[0] in (proto.FailureType.FirmwareError, proto.FailureType.ActionCancelled):
|
||||||
click.echo("Update aborted on device.")
|
click.echo("Update aborted on device.")
|
||||||
else:
|
else:
|
||||||
click.echo("Update failed: {} {}".format(*e.args))
|
click.echo("Update failed: {} {}".format(*e.args))
|
||||||
|
Loading…
Reference in New Issue
Block a user