Skip to content

Running deterministic from Flash #1

@Traumflug

Description

@Traumflug

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions