SAM4S_EEFC: Report FRDY=0 briefly after command write#198
Open
msarehn wants to merge 1 commit intorenode:masterfrom
Open
SAM4S_EEFC: Report FRDY=0 briefly after command write#198msarehn wants to merge 1 commit intorenode:masterfrom
msarehn wants to merge 1 commit intorenode:masterfrom
Conversation
The EEFC model previously always returned FRDY=1 in the status register. Firmware (e.g. ASF's efc_perform_read_sequence running from RAM) polls EEFC_FSR waiting for the FRDY=0 transition that indicates the flash controller has accepted a command. Without this transition the firmware spins forever. Set a flashBusy flag on command write and return FRDY=0 on the first subsequent status read, then FRDY=1 on the next read. This matches real hardware behaviour where FRDY briefly goes low. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
The EEFC model previously always returned FRDY=1 in the status register. Firmware (e.g. ASF's efc_perform_read_sequence running from RAM) polls EEFC_FSR waiting for the FRDY=0 transition that indicates the flash controller has accepted a command. Without this transition the firmware spins forever.
Set a flashBusy flag on command write and return FRDY=0 on the first subsequent status read, then FRDY=1 on the next read. This matches real hardware behaviour where FRDY briefly goes low.
Note
This is part of a larger effort to properly emulate SAM4E-based devices. I'll create some more PRs related to that; this note applies to all of them so I'll only put it here.
We are in need of SAM4E support in renode. The SAM4S support means it's mostly there, just some fixes here and there. Now I'm not very well versed in emulator development, so I've had Claude have a crack at it while looking at the datasheet and observing our firmware running in renode. It's working pretty well now, but the code is all AI-generated. I'm not sure what your stance on this is; it certainly needs review from someone knowledgable in the area. I've glanced over the code and I think it's okay-ish from my POV. No tests though; and I don't know if you require them.
In any case, we'd be happy to contribute the changes back upstream.