Repository navigation
Conversation
`erase` built page boundaries with `range(start, end, erase_size)` and erased each consecutive pair. Since `range` excludes `end`, the final pair `(end - erase_size, end)` was never produced, so the last page of the program memory range was left unerased but still written to. Iterate over page start addresses instead, so that every page in `[start, end)` is erased. Reject ranges which are not a multiple of the erase size up front, as `erase_flash` does. The test_cli recordings are updated with the additional erase command and its SUCCESS response for the final page.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #99.
erase()built page boundaries withrange(start, end, erase_size)and erased each consecutive pair.rangeexcludesend, so the final page(end - erase_size, end)was never erased, althoughflash()still writes to it.Changes:
(page_start, page_start + erase_size)for each one, so all N pages in[start, end)are erased.total_pagesis now N, so the progress bar is correct.BadAddressworkaround still erases(page_start - erase_size, end), the same range as before.ValueErrorup front if the range is not a multiple oferase_size, the same checkerase_flashmakes. Before, a trailing partial page was silently skipped.pairwisebackport, which is no longer used.Tests:
erase()(witherase_flashandprint_progressmonkeypatched): all pages are erased including the last, the number of erase commands equals the number of pages, progress ends at 100 %, a misaligned range is rejected, and theBadAddressworkaround still covers the range throughend. All of them fail on currentmain.test_cli[...]recordings now include the extraERASE_FLASHcommand for page0x2A000and itsSUCCESSresponse. I don't have the test device, so I spliced these in by hand rather than re-recording them. The bytes follow the recorded response to the previous page's erase, but you may want to re-record withpytest --record -k test_cli.Local results:
pytest23 passed, and black, isort andmypy --strictare clean.ruff check .shows 7 findings with ruff 0.17.1 (CPY001on every module andRUF036inmain), and currentmainshows the same 7.Note:
tox -e testrunspytest --replay, but pytest-reserial 0.6 dropped--replay(replay is now the default), so that command fails with a fresh install. I rancoverage run -m pytestinstead and lefttox.inialone.🤖 Generated with Claude Code