From e072234bb08d7cc2f861ffaa99e590dfa028ac4c Mon Sep 17 00:00:00 2001 From: Rob Riggs Date: Sat, 25 Mar 2017 11:20:36 -0500 Subject: [PATCH 1/2] status is a tuple formatting fails with "not all arguments converted." --- dfuse-tool.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dfuse-tool.py b/dfuse-tool.py index c65b50f..46f6aa8 100755 --- a/dfuse-tool.py +++ b/dfuse-tool.py @@ -84,14 +84,14 @@ def flash(args): dfu.erase(image['address']) status = dfu.wait_while_state(dfuse.DfuState.DFU_DOWNLOAD_BUSY) if status[1] != dfuse.DfuState.DFU_DOWNLOAD_IDLE: - raise RuntimeError("An error occured. Device Status: %r" % status) + raise RuntimeError("An error occured. Device Status: %r" % (status)) print("Flashing ...") transfer_size = 1024 dfu.set_address(image['address']) status = dfu.wait_while_state(dfuse.DfuState.DFU_DOWNLOAD_BUSY) if status[1] != dfuse.DfuState.DFU_DOWNLOAD_IDLE: - raise RuntimeError("An error occured. Device Status: %r" % status) + raise RuntimeError("An error occured. Device Status: %r" % (status)) data = image['data'] blocks = [data[i:i + transfer_size] for i in range(0, len(data), transfer_size)] @@ -100,7 +100,7 @@ def flash(args): dfu.write(blocknum, block) status = dfu.wait_while_state(dfuse.DfuState.DFU_DOWNLOAD_BUSY) if status[1] != dfuse.DfuState.DFU_DOWNLOAD_IDLE: - raise RuntimeError("An error occured. Device Status: %r" % status) + raise RuntimeError("An error occured. Device Status: %r" % (status)) print("Done") From 918739c63e64cfc05c1175f9cda4e45afae6bb7c Mon Sep 17 00:00:00 2001 From: Rob Riggs Date: Sat, 25 Mar 2017 11:24:25 -0500 Subject: [PATCH 2/2] Add support for transfer size command-line option. --- dfuse-tool.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dfuse-tool.py b/dfuse-tool.py index 46f6aa8..2c9f23a 100755 --- a/dfuse-tool.py +++ b/dfuse-tool.py @@ -87,7 +87,7 @@ def flash(args): raise RuntimeError("An error occured. Device Status: %r" % (status)) print("Flashing ...") - transfer_size = 1024 + transfer_size = args.size dfu.set_address(image['address']) status = dfu.wait_while_state(dfuse.DfuState.DFU_DOWNLOAD_BUSY) if status[1] != dfuse.DfuState.DFU_DOWNLOAD_IDLE: @@ -128,6 +128,7 @@ def flash(args): devinfo.add_argument('--cfg', action='store', type=int, default=0, help='Device\'s configuration number, default to 0') devinfo.add_argument('--intf', action='store', type=int, default=0, help='Device\'s interface number, defaults to 0') devinfo.add_argument('--alt', action='store', type=int, default=0, help='Device\'s alternate setting number, defaults to 0') +devinfo.add_argument('--size', action='store', type=int, default=1024, help='Transfer size, defaults to 1024') others = parser.add_argument_group('Other Options') others.add_argument('--force', '-f', action='store_true', help='Bypass sanity checks')