Skip to content

Commit a116f88

Browse files
committed
Correctly pad data to WRITE_SIZE
1 parent 55f8505 commit a116f88

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
include:
2020
# Test MSRV
21-
- rust: 1.36.0
21+
- rust: 1.50.0
2222
TARGET: x86_64-unknown-linux-gnu
2323

2424
# Test nightly but don't fail

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ NOR-flash & NAND-flash, both external and internal.
88

99
## [API reference]
1010

11-
[API reference]: https://docs.rs/embedded-storage
12-
1311
## How-to: add a new trait
1412

1513
This is the suggested approach to adding a new trait to `embedded-storage`
@@ -37,7 +35,7 @@ These issues / PRs will be labeled as `proposal`s in the issue tracker.
3735

3836
## Minimum Supported Rust Version (MSRV)
3937

40-
This crate is guaranteed to compile on stable Rust 1.36.0 and up. It *might*
38+
This crate is guaranteed to compile on stable Rust 1.50.0 and up. It *might*
4139
compile with older versions but that may change in any new patch release.
4240

4341
## License
@@ -55,3 +53,5 @@ at your option.
5553
Unless you explicitly state otherwise, any contribution intentionally submitted
5654
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
5755
dual licensed as above, without any additional terms or conditions.
56+
57+
[API reference]: https://docs.rs/embedded-storage

src/nor_flash.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ where
225225
if is_subset {
226226
// Use `merge_buffer` as allocation for padding `data` to `WRITE_SIZE`
227227
let offset = addr as usize % S::WRITE_SIZE;
228-
let alligned_end = data.len() % S::WRITE_SIZE;
229-
self.merge_buffer[..S::WRITE_SIZE].fill(0xff);
230-
self.merge_buffer[offset..data.len()].copy_from_slice(data);
228+
let aligned_end = data.len() % S::WRITE_SIZE + offset + data.len();
229+
self.merge_buffer[..aligned_end].fill(0xff);
230+
self.merge_buffer[offset..offset + data.len()].copy_from_slice(data);
231231
self.storage
232-
.try_write(addr - offset as u32, &self.merge_buffer[..S::WRITE_SIZE])?;
232+
.try_write(addr - offset as u32, &self.merge_buffer[..aligned_end])?;
233233
} else {
234234
self.storage.try_erase(page.start, page.end())?;
235235
self.merge_buffer[..S::ERASE_SIZE]

0 commit comments

Comments
 (0)