-
-
Notifications
You must be signed in to change notification settings - Fork 461
Add blank check to algorithm #3345
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
.map_err(FlashError::Core)?; | ||
if !data | ||
.iter() | ||
.all(|v| *v == self.flash_algorithm.flash_properties.erased_byte_value) |
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.
Just want to note that there are a few chips that have 2-byte erase values. You don't need to do anything about those here, I think we lose that information somewhere in target-gen, but I'll leave this comment here in case someone looks at this PR.
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.
The fallback algorithm is the one that used to be from target-gen/src/commands/test.rs
so there isn't a regression in functionality here.
Such devices could actually benefit from a flash algorithm that runs on the device, or we can add something like erased_u16_value
or erased_short_value
to the flash algorithm definition so we can support those devices in the future.
bbf7746
to
de1d515
Compare
@@ -66,6 +66,9 @@ pub struct RawFlashAlgorithm { | |||
/// Address of the (non-standard) `ReadFlash()` entry point. Optional. | |||
#[serde(serialize_with = "hex_option")] | |||
pub pc_read: Option<u64>, | |||
/// Address of the (non-standard) `BlankCheck()` entry point. Optional. |
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.
BlankCheck
is a standard CMSIS-PACK function. https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/algorithmFunc.html
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.
I had no idea. I'll update the comment.
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's not just the comment. I'd prefer not breaking handwritten flash algos that decide to support "OurBlankCheck" when we decide to support the upstream function, so we should make sure we don't expect this custom addition to be called the same in the flash algo either.
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.
I can rename the function. Currently, flash-algorithm
generates a function called BlankCheck
, but I can submit a patch to update that as well.
What name would you like?
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.
I'm fine with whatever, even BlankCheck2
🫠 so long as it's different from the standard name.
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.
We could use that, but it's a big enough change that perhaps @bugadani didn't want that. I'm fine with either approach.
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.
I just thought we don't know the empty flash pattern upfront and can't use the standard method 🤔 I'd also prefer that, to be fair. The change itself should be largely the same - we just need to call the function with an extra argument.
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 doesn't say the pattern argument has to be used:
The function BlankCheck can be used to check whether the specified block is empty, or whether the content is equal to a specific pattern defined in the argument pat.
I imagine that statement means that a function is free to ignore the third argument if it makes sense.
Let me rework the patch back to the original function name, and make the arguments line up with the CMSIS-DAP implementation.
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.
Algos carry the default erased value: https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/flashAlgorithm.html#AddFPA and we have it present in the target YAMLs :)
(admittedly I have no idea how correct those are)
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.
Alright, blank_check()
now has three arguments that follow the CMSIS-DAP implementation of BlankCheck
190a4fa
to
8867b4c
Compare
Some parts have special requirements for determining whether it is blank. Add functions to perform this operation. Signed-off-by: Sean Cross <sean@xobs.io>
Perform blank checks with the `run_blank_check()` command. Signed-off-by: Sean Cross <sean@xobs.io>
8867b4c
to
4bce6bb
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.
Thanks!
Add blank_check to flash algorithms. This is code that runs on the target, and is used for checking whether flash is blank or not on parts where the blank status isn't a simple pattern. This is common on ECC parts, where frequently a blank flash isn't even valid.