-
Notifications
You must be signed in to change notification settings - Fork 3k
LPC176X: Fix flash program size #6413
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
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.
it could be as @davidsaada proposed - smaller program page size if it is defined, or what I was initially thinking, was allocating only
copySize
buffer on heap (because that one is used for flashing). It increases the runtime but making it possible to work for any app (1k of heap should be available). ?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.
Not sure it would help in this case. I suspect that the extra allocation of 1024 bytes already pushes this test over the limit. However, it's worth the try.
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.
@0xc0170 @davidsaada In the current code, the reason of the malloc usage is to handle unaligned the data buffer here:
https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_NXP/TARGET_LPC176X/device/flash_api.c#L132-L137
However, there is an alignment check logic here before calling the HAL driver:
https://github.com/ARMmbed/mbed-os/blob/master/drivers/FlashIAP.cpp#L101
I think therefore, the malloc in the flash_program_page() is not required and it should just check the size of flash data.
I am going to modify this and create new commit for review next week.
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.
@toyowata You can still check the alignment for the (unlikely) case this code is not called from the driver (or if the driver logic is changed for some reason), and only then perform the malloc + memcpy. In the likely aligned case, you can point to the user buffer.