STM32 gotchas
324.In Cortex-M7, processor may reorder Normal-memory accesses around Device/Strongly-ordered

In Cortex-M0/M0+/M3/M4, accesses to any memory area are executed exactly in the order, as they are written 1.

This is not the case in Cortex-M7, which is free to reorder accesses to Normal memory areas around accesses to Device (or Strongly-ordered) memory areas. The former are usually memories such as RAM and FLASH, and the latter are usually peripheral registers.

Ordering of execution is usually important in context of interrupts and the related concepts of atomicity. Users can regain control e.g. by using barriers (DMB instruction), or marking part of the RAM as Device in MPU and allocate related variables in that portion of memory.

This again is part of the price paid for the higher performance of the Cortex-M7.

This issue has been discussed for example here.


1. By "written" here, the order of machine instructions is meant. Note, that high-level language (e.g. C/C++) compilers/optimizers are usually free to reorder accesses as long as they are not explicitly marked as non-reorderable (e.g. in C/C++ by keyword volatile).