multicore flash write with interrupts enabled? #2253
Replies: 2 comments 4 replies
-
There's not a "correct" way since you're basically rolling your own at this point. If you guarantee the other core isn't going to need flash (you can use ROM or routines in RAM) then you can hack out that freeze. Be careful, though, of other possible interrupt sources and any use of standard library routines (even if you're not explicitly calling them...). I think I've put all my ISR routines in RAM in the core, but if you do find something firing that's in flash, a PR would be appreciated. Good luck! |
Beta Was this translation helpful? Give feedback.
-
OK, much to probably nobody's surprise I had a bug in my own code which was causing some hangs as well. (I had some debug output in Having un-snafu'd all that ... DangerFS works now! I should probably stress-test it a bit harder, tho I might burn out the flash on a Feather board if I want to do really significant testing. However, after all that ... I'm still getting the stupid audio glitch during write that was the cause of this whole digression! Something still prevents the audio ISR on core 1 from firing during the flash write executing on core 0. Puzzling. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I can see in
LittleFSImpl::lfs_flash_prog
that during a flash write the writing core pauses the other core and disables interrupts. I get why: you can't have any reads from flash during a write, including through the XIP cache, or there's corruption.But in my current project I have an ISR on core1, a
not_in_flash_func
, that refills an audio buffer. It's just copying samples between buffers in RAM and doing math on them. It's not calling any other functions. It really should not be touching flash. So it ought to be fine to let this run during a flash write, right? Because currently I get a nasty audio glitch during flash writes when core1 is paused.It seems to me that if my ISR is flash-safe, and my
loop1()
is also pinned in RAM, and it runs an empty loop during the write, then it could be safe to write flash without idling the other core. Does that seem plausible? Or what else could go wrong?I can see a hacky way of testing this, where I modify LittleFS.cp to not call
rp2040.idleOtherCore()
. But is there any more "correct" way to try to do it?Thx!
Beta Was this translation helpful? Give feedback.
All reactions