use the proper block count when publishing multipart UF2s

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
Brian S. Stephan 2024-04-15 00:05:54 -05:00
parent 3524e5aa54
commit 7d34a441f8
Signed by: bss
GPG Key ID: 3DE06D3180895FCB
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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('<L', UF2_MAGIC_FINAL) # final magic number
index += 256
block_count += 1
return uf2