Skip to content

boot: bootutil: avoid full erase on BOOT_MAGIC_BAD in boot_set_next #2316

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ofirshe
Copy link

@ofirshe ofirshe commented May 22, 2025

Previously, boot_set_next() would perform a full slot erase when
BOOT_MAGIC_BAD was detected. This is no longer done, as the
decision on how to handle a corrupted image should be left to user code.

@ofirshe ofirshe requested a review from davidvincze as a code owner May 22, 2025 16:56
@ofirshe
Copy link
Author

ofirshe commented May 23, 2025

@de-nordic

Copy link
Collaborator

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

this is from the user application side, the image would not be scrambled because this function does not run from MCUboot

@de-nordic
Copy link
Collaborator

de-nordic commented May 23, 2025

this is from the user application side, the image would not be scrambled because this function does not run from MCUboot

Shouldn't we leave the decision what to do to a user code? User may want to just re-start DFU so will erase or attempt to erase the area anyway. We report here bad image, so user will know that there is a problem.

Previously, boot_set_next() would perform a full slot erase when
BOOT_MAGIC_BAD was detected. This is no longer done, as the
decision on how to handle a corrupted image should be left to user code.

Signed-off-by: Ofir Shemesh <[email protected]>
@ofirshe ofirshe force-pushed the ofirshe-bootutil-avoid-full-erase-bad-magic branch from 4f3d019 to 9f73145 Compare May 23, 2025 09:39
@ofirshe
Copy link
Author

ofirshe commented May 23, 2025

this is from the user application side, the image would not be scrambled because this function does not run from MCUboot

@nordicjm You're right - this function runs from the user application, so the image won't be scrambled at that point. What I meant is that the invalid image will be detected on the next reboot, and MCUboot will take the appropriate action.
I agree with @de-nordic that the decision on how to handle this should be left to the user, which is the motivation behind this PR. I've changed the commit message accordingly.

@ofirshe ofirshe requested a review from nordicjm May 23, 2025 09:42
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