-
Notifications
You must be signed in to change notification settings - Fork 3k
FlashIAP: Fix problem of programming source buffer not aligned to 4 #6864
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
// 1. Size is not page aligned | ||
// 2. Source buffer is not aligned to uint32_t. This is not supported by many targets (although | ||
// the pointer they accept is of uint8_t). | ||
if (unaligned_src || (chunk < page_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.
Thoughts on just copying to the internal buffer for all program calls?
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 very efficient. I suspect that the vast majority of calls will have both buffer and size aligned.
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.
Looks good to me 👍
/morph build |
@@ -22,6 +22,7 @@ | |||
#include "utest/utest.h" | |||
#include "unity/unity.h" | |||
#include "greentea-client/test_env.h" | |||
#include <algorithm> |
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.
What exactly is this importing? This is the first time I've ever seen a system file simply called "algorithm".
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 is actually used quite a lot. It imports the std::min and std::max functions.
Build : SUCCESSBuild number : 1978 Triggering tests/morph test |
Exporter Build : FAILUREBuild number : 1629 |
Test : SUCCESSBuild number : 1791 |
Morph exporter needs to be restarted. Looks like failure is due related to tools. |
/morph export-build |
Exporter Build : SUCCESSBuild number : 1632 |
Description
This PR resolves a problem (found by @yossi2le) when programming the internal flash via FlashIAP: The
program
API receives aconst void *buffer
parameter as the source buffer to program. As such, the program buffer can point to data of any kind, without alignment restrictions. However, many of the target specific flash drivers assume this buffer is aligned touint32_t
and thus cast it touint32_t*
.Freescale's
flash_api
module shows a typical example for that. Other targets do the same as well.Solution is by using an aligned buffer for this case in FlashIAP. This was already implemented for unaligned program sizes. Same code is now used for the unaligned source buffer case.
This PR also modifies the FlashIAP programming test code, as the previous one was quite trivial and didn't check this scenario as well.
This fix also resolves issue #6706.
Pull request type