STM32 gotchas
318. On 'F7 and some 'H7, Data Cache in Write-Through is unusable (due to Cortex-M7 erratum)

While the Cortex-M7 processor core has high performance (thanks to architectural perks like partially-dual-issue ALU, (speculative) prefetch and branch prediction, 64-bit AXIM bus and, perhaps foremost, core-coupled instruction and data caches), its complexity is also much higher than of other Cortex-M processors. This complexity comes with some unexpected side effects, and also implementation errors. These are described in ARM's errata. Some more serious processor errata are also copied into the model-specific STM32 errata.

One of such errata is the Data corruption in a sequence of Write-Through stores and loads Category A (most serious) erratum, #1259864. While the erratum contains a detailed description of the combination of events which leads to the problem, the practical consequence is, that Data Cache should not be set to Write-Through mode, either through the default memory map 1, or explicitly through MPU, or by using the special processor flags which force this mode for Data Cache.

Only processors with revisions up to r1p1 are affected; revision r1p2 has fixed this problem. It's an extra challenge to find out the revision for given model, as ST does not post it in DS/RM nor has a list of core versions used in individual models. If one has access to given STM32, it can be deciphered from the CPUID core register. AN4891 in Table 7 says, that cores in 'F7 are of either r0p1 or r1p0 revision, so all 'F7 are affected. 'H74x/75x has core rev.r1p1, so that's affected, too. It may well be that that is the only 'H7 model affected as probably all other 'H7 are based on the fixed r1p2 core 2.


1.In default memory map, areas 0x0000'0000-0x1FFF'FFFF and 0x8000'0000-0x9FFF'FFFF are set as Cacheable, Write-Through. The former is mostly used for code (FLASH and ITCM RAM - and note that TCM is never cached) so it's probably not a concern here. The latter is used mostly for FMC and QSPI. If these areas are to be used for data with caching enabled, in the affected models it has to be set in MPU as Write-Back.

2.As a curiosity, the 'H7A/'H7B model returns CPUID indicating r1p1, however, it's in fact r1p2, as witnessed by errata ES0478.