-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Just saw your awesome talk on 33C3. There you claim running from Flash isn't clock cycle deterministic, because there's a prefetcher and one would never know when this kicks in.
When implementing an interruptible delay loop for Teacup Firmware I ran into a similar problem. Depending on where the compiler placed the code, the loop would take a longer or shorter execution time. The solution I found is to align code to a 16 byte boundary. This removes the prefetcher from the picture or at least makes it deterministic. Gcc/binutils even features an instruction to enforce such alignment, .balign.
The implementation taking advantage of .balign can be found here: https://github.com/Traumflug/Teacup_Firmware/blob/master/delay-arm.c
Metadata
Metadata
Assignees
Labels
No labels