fix(esp-bootloader-esp-idf): allow FlashRegion::erase up to partition end#5580
Open
adstep wants to merge 1 commit into
Open
fix(esp-bootloader-esp-idf): allow FlashRegion::erase up to partition end#5580adstep wants to merge 1 commit into
adstep wants to merge 1 commit into
Conversation
… end `FlashRegion::erase(from, to)` rejected `to == partition_end` because both `address_to` bounds checks used `Range::contains`, which has half-open [start, end) semantics. The `NorFlash::erase` trait documents `to` as the exclusive end of the range, so erasing an N-byte partition aligned to its start requires passing `to = N` -- which the current implementation refuses. Replace the half-open check with an inclusive upper-bound comparison matching the trait contract, and add a defensive `to < from` guard. The sibling `write`/`read` impls in the same file already use the in-range helper, which does this correctly.
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.
Submission Checklist 📝
cargo xtask fmt-packagescommand to ensure that all changed code is formatted correctly.skip-changelogormanual-changeloglabel as appropriate.Extra:
Pull Request Details 📖
Description
FlashRegion::erase(from, to)rejectsto == partition_endwithError::OutOfBounds, even though that is the natural and correct value for "erase the whole slot."embedded_storage::nor_flash::NorFlash::erasedocuments itstoparameter as the exclusive end of the range, so erasing an N-byte partition aligned to its start needs to passto = N— which today fails.Root cause. The two
address_tobounds checks both useRange::contains, which has half-open[start, end)semantics and rejects exactlyaddress_to == range.end. The siblingwrite/readimpls in the same file use thein_rangehelper, which does the upper bound the right way (address + len <= range.end);eraseis the odd one out.Fix. Replace the half-open check with an inclusive upper-bound comparison, and add a defensive
to < fromguard the original code happened not to have.