STM32 gotchas
5. 'F4/'F2 CCM RAM is not good for DMA, nor for bit-banding, nor for code

In the upper-end STM32F4* family and in STM32F2, there are two or three SRAMs connected to the busmatrix, available for all purposes, including DMA; and they can be also accessed quasi-bit-wise using the Cortex-M4 bit-banding facility. These SRAMs are mapped in one continuous address space, so that many users are not aware that these are separate memories.

However, many users notice, that their size does not add up to the advertized total SRAM size. The reason is, that there is one more 64kB chunk of RAM, which is NOT connected through the bus-matrix, but it is directly connected to the processor's D (Data) port.

This has several consequences:

In particular, if one unknowingly attempts to use CCM RAM at the memory port of DMA, DMA will fail with throwing Transfer Error.

So what's CCM RAM good for? It's really great to keep all the "pure" data in it. The simplest thing to do is to set stack and heap into it; but also data which are not intended for input/output, and/or data upon which extensive calculations are to be made.

* In ST nomenclature, this includes both the Foundation lines and Advanced lines, but excludes the 'F446. It means, 'F405/407/415/417, 'F427/429/437/439, and 'F469/476, all have CCM RAM.