From 02f6dd96816150b8a5c16241a4e387e97692c574 Mon Sep 17 00:00:00 2001 From: slush0 Date: Sat, 12 Oct 2013 17:40:48 +0200 Subject: [PATCH] Command firmware_update --- cmd.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd.py b/cmd.py index bf6eaee579..311bcf5778 100755 --- a/cmd.py +++ b/cmd.py @@ -112,7 +112,15 @@ class Commands(object): seed = ' '.join(args.seed) return self.client.load_device(seed, args.pin) - + + def firmware_update(self, args): + fp = open(args.file, 'r') + if fp.read(4) != 'TRZR': + raise Exception("Trezor firmware header expected") + + fp.seek(0) + return self.client.firmware_update(fp=open(args.file, 'r'), force=args.force) + list.help = 'List connected Trezor USB devices' ping.help = 'Send ping message' get_address.help = 'Get bitcoin address in base58 encoding' @@ -123,7 +131,8 @@ class Commands(object): set_label.help = 'Set new wallet label' set_coin.help = 'Switch device to another crypto currency' load_device.help = 'Load custom configuration to the device' - + firmware_update.help = 'Upload new firmware to device (must be in bootloader mode)' + get_address.arguments = ( (('n',), {'metavar': 'N', 'type': int, 'nargs': '+'}), ) @@ -151,6 +160,11 @@ class Commands(object): (('-n', '--pin'), {'type': str, 'default': ''}), ) + firmware_update.arguments = ( + (('-f', '--file'), {'type': str}), + (('-o', '--force'), {'type': bool, 'default': False}) + ) + def list_usb(): from trezorlib.transport_hid import HidTransport devices = HidTransport.enumerate()