Skip to content

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

Merged
merged 2 commits into from
May 19, 2025

Conversation

xobs
Copy link
Contributor

@xobs xobs commented May 19, 2025

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.

.map_err(FlashError::Core)?;
if !data
.iter()
.all(|v| *v == self.flash_algorithm.flash_properties.erased_byte_value)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@xobs xobs force-pushed the add-blank-check-to-algorithm branch from bbf7746 to de1d515 Compare May 19, 2025 08:00
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Member

@Yatekii Yatekii May 19, 2025

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)

Copy link
Contributor Author

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

@xobs xobs force-pushed the add-blank-check-to-algorithm branch 2 times, most recently from 190a4fa to 8867b4c Compare May 19, 2025 08:53
xobs added 2 commits May 19, 2025 22:00
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>
@xobs xobs force-pushed the add-blank-check-to-algorithm branch from 8867b4c to 4bce6bb Compare May 19, 2025 14:00
Copy link
Contributor

@bugadani bugadani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bugadani bugadani added this pull request to the merge queue May 19, 2025
Merged via the queue into probe-rs:master with commit 85b2a0f May 19, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy