Skip to content

Commit

Permalink
Pad chunks to alignment (fix #25)
Browse files Browse the repository at this point in the history
  • Loading branch information
bessman committed Nov 1, 2023
1 parent e08993b commit a668b9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [7.0.6] - 2023-11-01

### Changed

- Reformat changelog per Common Changelog style

### Fixed

- Actually use bincopy for alignment ([#25](https://github.com/bessman/mcbootflash/issues/25))

## [7.0.5] - 2023-10-31

_Maintanence release._
Expand Down
3 changes: 2 additions & 1 deletion src/mcbootflash/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ def flash(
chunk_size -= chunk_size % self._write_size
chunk_size //= hexdata.word_size_bytes
total_bytes = len(hexdata) * hexdata.word_size_bytes
total_bytes += (self._write_size - total_bytes) % self._write_size
written_bytes = 0
align = self._write_size // hexdata.word_size_bytes

for chunk in hexdata.segments.chunks(chunk_size, align):
for chunk in hexdata.segments.chunks(chunk_size, align, b"\x00\x00"):
self._write_flash(chunk)
written_bytes += len(chunk.data)
_logger.debug(
Expand Down

0 comments on commit a668b9d

Please sign in to comment.