fix(PeriphDrivers): MAX32650 (ME10) Flash Address Fix #1354
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.
Corrected a bug in how the flash physical address (relative to flash base) was calculated which caused a block of pages' addresses to be incorrectly masked. This ultimately caused issues when doing single page erases whenever bit 20 of the Flash address was set.
In the original implementation, -1 was done on the FLASH_MEM_SIZE to presumably get a valid mask. This works when the memory size is a power of 2. However, since the memory on the MAX32650 is 3MB (0x300000), subtracting 1 results in a mask of 0x2FFFFF, where Bit 20 is 0. All pages with Bit 20 set to 1 will have an incorrect address calculated.
The solution was to just subtract the base address, since the range was already validated in the if block. This is the same implementation that the MAX32690 (also with 3MB of Flash) does.