-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
storage/stream: fix possible unaligned write on buffer flush request #25584
storage/stream: fix possible unaligned write on buffer flush request #25584
Conversation
4aa4b5e
to
bb5dc9f
Compare
I was wondering if a regression test for this would not be good. |
bb5dc9f
to
1885501
Compare
All checks are passing now. checkpatch (informational only, not a failure)
Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
1885501
to
514b6b8
Compare
Yes it is possible. |
* should be erased in order to get the erased | ||
* byte-value. | ||
*/ | ||
rc = flash_read(ctx->fdev, |
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.
This is side note: We should consider adding some API call for returning the 'erased' byte value for the device. It is at least second time when I see that the value is needed and is either read from device (here) or predefined in code, e.g. in mcuboot.
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.
have this on my API request change list
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.
Notes left. otherwise I think that the solution is fine.
92ba864
to
69d9656
Compare
@nandojve Test added |
7d120b3
to
64d46a4
Compare
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.
There is a typo in the last commit "steram" -> "stream"
4e0b926
to
46b5abd
Compare
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.
After apply changes, the board disco_l475_iot1 started to work properly.
In the last commit added note on requirements for size of the stream buffer. |
On buffer flush request it is very probably that write buffer contains amount of data which is non write-block-size aligned. Flash memory need to be write at minimal by write-block-size chunks. This patch addresses mechanism which ensure such behavior by adding missing bytes. fixes zephyrproject-rtos#25471 streamer buffer size should be multiple write-block-size of the flash device in order to avoid unaligned flash write request. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Added test for check proper service of flush-write when buffer contains unaligned amount of data. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Implementation requires that streamer buffer size must be multiple of the flash device wbs. This patch reflects this in API documentation Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
d7ab2dc
to
d8956a3
Compare
… flush On buffer flush request it is very probably that write buffer contains amount of data which is non write-block-size aligned. Flash memory need to be write at minimal by write-block-size chunks. This patch addresses mechanism which ensure such behavior by adding missing bytes. fixes #25471 streamer buffer size should be multiple write-block-size of the flash device in order to avoid unaligned flash write request. upstream: zephyrproject-rtos/zephyr#25584 Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
… test Added test for check proper service of flush-write when buffer contains unaligned amount of data. upstream: zephyrproject-rtos/zephyr#25584 Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
requirements Implementation requires that streamer buffer size must be multiple of the flash device wbs. This patch reflects this in API documentation upstream: zephyrproject-rtos/zephyr#25584 Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
… flush On buffer flush request it is very probably that write buffer contains amount of data which is non write-block-size aligned. Flash memory need to be write at minimal by write-block-size chunks. This patch addresses mechanism which ensure such behavior by adding missing bytes. fixes #25471 streamer buffer size should be multiple write-block-size of the flash device in order to avoid unaligned flash write request. upstream: zephyrproject-rtos/zephyr#25584 Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no> (cherry picked from commit 642dc37)
… test Added test for check proper service of flush-write when buffer contains unaligned amount of data. upstream: zephyrproject-rtos/zephyr#25584 Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no> (cherry picked from commit 911bc79)
…rements Implementation requires that streamer buffer size must be multiple of the flash device wbs. This patch reflects this in API documentation upstream: zephyrproject-rtos/zephyr#25584 Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no> (cherry picked from commit b7e535c)
… flush On buffer flush request it is very probably that write buffer contains amount of data which is non write-block-size aligned. Flash memory need to be write at minimal by write-block-size chunks. This patch addresses mechanism which ensure such behavior by adding missing bytes. fixes #25471 streamer buffer size should be multiple write-block-size of the flash device in order to avoid unaligned flash write request. upstream: zephyrproject-rtos/zephyr#25584 Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no> (cherry picked from commit 642dc37)
… test Added test for check proper service of flush-write when buffer contains unaligned amount of data. upstream: zephyrproject-rtos/zephyr#25584 Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no> (cherry picked from commit 911bc79)
…rements Implementation requires that streamer buffer size must be multiple of the flash device wbs. This patch reflects this in API documentation upstream: zephyrproject-rtos/zephyr#25584 Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no> (cherry picked from commit b7e535c)
On buffer flush request it is very probably that write buffer
contains amount of data which is non write-block-size aligned.
Flash memory need to be write at minimal by write-block-size chunks.
This patch addresses mechanism which ensure such behavior by adding
missing bytes.
fixes #25471
Signed-off-by: Andrzej Puzdrowski andrzej.puzdrowski@nordicsemi.no