Skip to content

Commit 7d34a44

Browse files
committed
use the proper block count when publishing multipart UF2s
Signed-off-by: Brian S. Stephan <[email protected]>
1 parent 3524e5a commit 7d34a44

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Included is a summary of changes to the project. For full details, especially on behind-the-scenes code changes and
44
development tools, see the commit history.
55

6+
## v0.8.2
7+
8+
### Bugfixes
9+
10+
* UF2 files made of parts now have the proper block counts.
11+
612
## v0.8.1
713

814
### Improvements

gp2040ce_bintools/storage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def convert_binary_to_uf2(binaries: list[tuple[int, bytearray]]) -> bytearray:
6565
"""
6666
total_blocks = sum([(len(binary) // 256) + 1 if len(binary) % 256 else len(binary) // 256
6767
for offset, binary in binaries])
68+
block_count = 0
6869

6970
uf2 = bytearray()
7071
for start, binary in binaries:
@@ -78,12 +79,13 @@ def convert_binary_to_uf2(binaries: list[tuple[int, bytearray]]) -> bytearray:
7879
0x00002000, # familyID present
7980
0x10000000 + start + index, # address to write to
8081
256, # bytes to write in this block
81-
index // 256, # sequential block number
82+
block_count, # sequential block number
8283
total_blocks, # total number of blocks
8384
UF2_FAMILY_ID) # family ID
8485
uf2 += binary[index:index+256] + bytearray(b'\x00' * pad_count) # content
8586
uf2 += struct.pack('<L', UF2_MAGIC_FINAL) # final magic number
8687
index += 256
88+
block_count += 1
8789
return uf2
8890

8991

0 commit comments

Comments
 (0)