From 7d34a441f8320aedb27e2aec313468b7497f47c1 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Mon, 15 Apr 2024 00:05:54 -0500 Subject: [PATCH] use the proper block count when publishing multipart UF2s Signed-off-by: Brian S. Stephan --- CHANGELOG.md | 6 ++++++ gp2040ce_bintools/storage.py | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd98243..0358664 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ Included is a summary of changes to the project. For full details, especially on behind-the-scenes code changes and development tools, see the commit history. +## v0.8.2 + +### Bugfixes + +* UF2 files made of parts now have the proper block counts. + ## v0.8.1 ### Improvements diff --git a/gp2040ce_bintools/storage.py b/gp2040ce_bintools/storage.py index 55e4d34..f38d2f6 100644 --- a/gp2040ce_bintools/storage.py +++ b/gp2040ce_bintools/storage.py @@ -65,6 +65,7 @@ def convert_binary_to_uf2(binaries: list[tuple[int, bytearray]]) -> bytearray: """ total_blocks = sum([(len(binary) // 256) + 1 if len(binary) % 256 else len(binary) // 256 for offset, binary in binaries]) + block_count = 0 uf2 = bytearray() for start, binary in binaries: @@ -78,12 +79,13 @@ def convert_binary_to_uf2(binaries: list[tuple[int, bytearray]]) -> bytearray: 0x00002000, # familyID present 0x10000000 + start + index, # address to write to 256, # bytes to write in this block - index // 256, # sequential block number + block_count, # sequential block number total_blocks, # total number of blocks UF2_FAMILY_ID) # family ID uf2 += binary[index:index+256] + bytearray(b'\x00' * pad_count) # content uf2 += struct.pack('