diff --git a/src/Emulator/Peripherals/Peripherals/Miscellaneous/SAM4S_EEFC.cs b/src/Emulator/Peripherals/Peripherals/Miscellaneous/SAM4S_EEFC.cs index 2e47b6560..fc25a33a0 100644 --- a/src/Emulator/Peripherals/Peripherals/Miscellaneous/SAM4S_EEFC.cs +++ b/src/Emulator/Peripherals/Peripherals/Miscellaneous/SAM4S_EEFC.cs @@ -266,6 +266,7 @@ private void DefineRegisters() return; } + flashBusy = true; ExecuteFlashCommand((Commands)command.Value, (int)argument.Value); IRQ.Set(generateInterrupt.Value); }) @@ -273,7 +274,17 @@ private void DefineRegisters() Registers.Status.Define(this) .WithFlag(0, FieldMode.Read, name: "FRDY", - valueProviderCallback: _ => true) + valueProviderCallback: _ => + { + // After a command write, report busy once so firmware + // sees the FRDY=0 transition, then ready on next read. + if(flashBusy) + { + flashBusy = false; + return false; + } + return true; + }) .WithTaggedFlag("FCMDE", 1) .WithFlag(2, out triedWriteLocked, FieldMode.ReadToClear, name: "FLOCKE") .WithFlag(3, out commandError, FieldMode.ReadToClear, name: "FLERR") @@ -289,6 +300,7 @@ private void DefineRegisters() private IFlagRegisterField generateInterrupt; private IFlagRegisterField triedWriteLocked; private IFlagRegisterField commandError; + private bool flashBusy; private readonly IMemory underlyingMemory; private readonly uint flashIdentifier;