Skip to content

SAM4S_EEFC: Report FRDY=0 briefly after command write#198

Open
msarehn wants to merge 1 commit intorenode:masterfrom
MenloSystems:upstream/sam4-eefc-frdy-fix
Open

SAM4S_EEFC: Report FRDY=0 briefly after command write#198
msarehn wants to merge 1 commit intorenode:masterfrom
MenloSystems:upstream/sam4-eefc-frdy-fix

Conversation

@msarehn
Copy link
Copy Markdown

@msarehn msarehn commented Apr 24, 2026

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.

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>
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.

1 participant