-
Notifications
You must be signed in to change notification settings - Fork 3k
MCUXpresso: Update LPC Flash driver program page function #8528
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
Handle the case where the number of bytes to write is not aligned to page size Signed-off-by: Mahesh Mahadevan <[email protected]>
Hi Mahesh - thanks for this PR! Just to confirm, this does not seem to support writes where the address is not aligned to 256 bytes, right? So this will be an important consideration to the calling functions - they will need to ensure they are writing to addresses on 256 byte boundaries. I will speak with the cloud client team about this. |
Non-page aligned addresses is not supported by the flash controller. |
@maclobdell Will you let is know when you've heard back from the cloud client team (or better yet, invite them into this PR conversation)? |
FlashIAP::program checks alignment to the page size here https://github.com/ARMmbed/mbed-os/blob/master/drivers/FlashIAP.cpp#L100 |
@0xc0170 Based on the checks implemented inside FlashIAP driver do we need to add this code inside the HAL layer? @maclobdell Is Pelion not using the FlashIAP driver? |
Is it possible that someone was not using the program method correctly (assumed that HAL should support it) ? |
@0xc0170 . Based on the checks available inside the FlashIAP driver do you think I can get rid of support for non-page aligned sizes for the program function. |
@ARMmbed/mbed-os-storage
|
@mmahadevan108 - I don't know if this PR is necessary. There is a separate issue with the cloud client trying to write to non-page aligned addresses. This is discussed in PelionIoT/mbed-cloud-client#18, with @adamelhakham having a fix and potentially making a PR soon. That should address the problem in the cloud client code without a need to modify the flash driver. |
@maclobdell @mmahadevan108 My fix is a fix only in the SOTP feature of mbed-cloud-client which is equivalent to the mbed-os nvstore feature (that stores items in the internal flash). my fix makes sure that the writes (using the sotp feature) are aligned to the flash write unit. Using the mbed-os nvstore feature will do the same, so you may use it if you wish. |
|
||
if (num_of_bytes) { | ||
/* First write page size aligned bytes of data */ | ||
status = FLASHIAP_CopyRamToFlash(address, (uint32_t *)data, num_of_bytes, SystemCoreClock); |
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.
The comment for FLASHIAP_CopyRamToFlash() says it can handle num_of_bytes:
"The addresses should be a 256 byte boundary and the number of bytes should be 256 | 512 | 1024 | 4096."
Here num_of_bytes can be any number aligned to 256. Its worth double checking whether 256|512|1024|4096 also includes other multiplies of 256... e.g. 768
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.
I modified the test to set the test_size to be page_size * 3, the tests passed.
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.
I appreciate it - thanks!
@maclobdell - I believe this fix is required for the driver... others than cloud client may use the driver |
Anything more needed for this PR? |
@offirko Can you finilize the review? Needs approval/request changes if there's anything left. |
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.
LGTM
Note: This PR is now a part of a rollup PR (#8686). No further work is needed here, as once that PR is merged, this PR will also be closed and marked as merged. If any more commits are made in this PR, this PR will remain open and have to go through CI on its own. |
Description
Handle the case where the number of bytes to write is not aligned to page size.
The mbed-os flash tests do not check this use-case, maybe some additional tests are required for the scenarios where the write size is less than page size and greater than page size.
Pull request type