Add SafeBoot recovery handling for Spansion/Cypress OSPI NOR flash de…#35
Open
cristisalcie wants to merge 1 commit into
Open
Add SafeBoot recovery handling for Spansion/Cypress OSPI NOR flash de…#35cristisalcie wants to merge 1 commit into
cristisalcie wants to merge 1 commit into
Conversation
…vices when interrupted non-volatile register writes leave the flash in a corrupted state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add SafeBoot recovery handling for Spansion/Cypress OSPI NOR flash devices when interrupted non-volatile register writes leave the flash in a corrupted state.
Problem
If a hardware reset occurs while a non-volatile register write operation is still in progress, the flash device may enter a corrupted or SafeBoot state.
This can happen, for example, when:
In this state:
Solution
Add SafeBoot detection and recovery handling during
Flash_norOspiOpen().The implementation introduces:
Flash_corrupted()Flash_recover()Flash_setDefaultCfr4x()Recovery Flow
Probe flash state during initialization
0x00)If corruption is detected:
After protocol initialization:
CFR4N/CFR4Vvalues (0xA8) if requiredDetails
Flash_corrupted()Detects SafeBoot/corrupted state using:
Flash_recover()Performs:
ReadId()attemptsFlash_setDefaultCfr4x()Restores default
CFR4values after recovery.This is required because software reset recovery does not restore
CFR4to datasheet default values.Motivation
The implementation follows the SafeBoot behavior described in the flash device documentation and improves driver robustness against:
Without recovery handling, the flash may remain inaccessible until manually reconfigured or power-cycled.
Tested
Tested by intentionally interrupting non-volatile register writes using hardware reset before flash ready completion.
Verified: