Skip to content

Explicitly handle WriteCountCheck::OnceOnly #1

@JuliDi

Description

@JuliDi

WriteCountCheck::OnceOnly is not handled directly, but only in the "catchall"

mock-flash/src/lib.rs

Lines 214 to 230 in b59a7e4

*word_writable = match (*word_writable, self.write_count_check) {
(v, WriteCountCheck::Disabled) => v,
(Writable::T, _) => Writable::O,
(Writable::O, WriteCountCheck::Twice) => Writable::N,
(Writable::O, WriteCountCheck::TwiceDifferent)
if source_word == &self.data[address..][..BYTES_PER_WORD] =>
{
Writable::O
}
(Writable::O, WriteCountCheck::TwiceDifferent) => Writable::N,
(Writable::O, WriteCountCheck::TwiceWithZero)
if source_word.iter().all(|b| *b == 0) =>
{
Writable::N
}
_ => return Err(MockFlashError::NotWritable(address as u32)),
};

This seems not ideal:
When working with flash that uses ECC, writing twice is not desirable because it disables/breaks ECC.
It is (usually?) not invalid to do so, but a more precise error message like "writing more than once is invalid on this flash" might help with troubleshooting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions