Skip to content

Commit 8fb95d6

Browse files
committed
tools/pydfu.py: Increase download packet size to full 2048 bytes.
The ST DFU bootloader supports a transfer size up to 2048 bytes, so send that much data on each download (to device) packet. This almost halves total download time.
1 parent 24c416c commit 8fb95d6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tools/pydfu.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,17 @@ def write_memory(addr, buf, progress=None, progress_addr=0, progress_size=0):
168168
print ("Addr 0x%x %dKBs/%dKBs..." % (xfer_base + xfer_bytes,
169169
xfer_bytes // 1024,
170170
xfer_total // 1024))
171-
if progress and xfer_count % 256 == 0:
171+
if progress and xfer_count % 2 == 0:
172172
progress(progress_addr, xfer_base + xfer_bytes - progress_addr,
173173
progress_size)
174174

175175
# Set mem write address
176176
set_address(xfer_base+xfer_bytes)
177177

178178
# Send DNLOAD with fw data
179-
chunk = min(64, xfer_total-xfer_bytes)
179+
# the "2048" is the DFU transfer size supported by the ST DFU bootloader
180+
# TODO: this number should be extracted from the USB config descriptor
181+
chunk = min(2048, xfer_total-xfer_bytes)
180182
__dev.ctrl_transfer(0x21, __DFU_DNLOAD, 2, __DFU_INTERFACE,
181183
buf[xfer_bytes:xfer_bytes + chunk], __TIMEOUT)
182184

0 commit comments

Comments
 (0)