Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for transfer size command-line option. #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dfuse-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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:
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)]
Expand All @@ -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")

Expand Down Expand Up @@ -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')
Expand Down