-
Notifications
You must be signed in to change notification settings - Fork 3k
NVStore: fix area calculation function #9445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@davidsaada, thank you for your changes. |
sector_map[num_sectors++] = flash_addr; | ||
if (user_config) { | ||
flash_addr = flash_start_addr; | ||
while (left_size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while (left_size) does not seems safe. Maybe int left_size = flash_size; and while (left_size>0)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do, though:
- Will probably need a few casts as all the rest of the variables are of
size_t
types. - The scenario you're afraid of is pretty erroneous: It can only happen if the flash driver exposes a flash size which is not a sum of its own sectors.
Hi
No, I'm sorry...
|
Ugh... Will work with you offline on this. |
68cefcd
to
e6ed079
Compare
Pushed a fix to the tests, as it seems that this change worsened the state of test in low memory boards. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All green!
Thx
e6ed079
to
8d2bb17
Compare
Don't allocate the sector map array in this function, as it was buggy and redundant. Separate user config vs. automatic allocation cases instead (which was essentially the case anyway). In addition, fix tests to get over failures in low end boards
8d2bb17
to
765b483
Compare
Thanks @jeromecoutant for verifying that. Description and commit message modified. |
Maybe we can start CI ? :-) |
CI started |
Test run: SUCCESSSummary: 12 of 12 test jobs passed |
Description
NVStore includes a function (
calc_validate_area_params
) that either calculates or validates the addresses and sizes of both areas. This function allocates a sector map array used in both calculation/validation of areas. While this generally worked, it had a few problems: First of all, it allocated and deallocated the sector map inside the function, while a more efficient code wouldn't need it. Second, it had a potential bug - number of of entries in the array was calculated according to the first sector size, but in case of a variant sector size, with a large first sector, the array size could have been smaller than required (this probably will never happen, but it's still a bug).This PR removes the allocation and usage of sector map array. Instead it traverses the flash sectors on the fly (forwards in the validation case, backwards in the calculation case).
In addition, fix tests to get over failures in low end boards.
Tested with K64F (both default and user configured), K82F, K66F, NUCLEO_F429ZI and UBLOX_EVK_ODIN_W2.
Resolves #8513.
Pull request type
Reviewers
@jeromecoutant