Skip to content

Commit

Permalink
handle bootloader serial write of all 0s
Browse files Browse the repository at this point in the history
  • Loading branch information
bradjc committed Mar 4, 2024
1 parent 4119893 commit f41ff5b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tockloader/bootloader_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,13 @@ def flash_binary(self, address, binary, pad=True):
):
valid_pages.append(i)

# Make sure that there is at least one valid page. If we are only trying
# to write 0s then all pages would have been removed. In that case, we
# want to write all requested pages.
if len(valid_pages) == 0:
for i in range(len(binary) // self.page_size):
valid_pages.append(i)

# Make sure to always include one blank page (if exists) after the end
# of a valid page. There might be a usable 0 on the next page. It's
# unlikely there is more than entire page of valid 0s on the next page.
Expand Down

0 comments on commit f41ff5b

Please sign in to comment.