Many ARM processors have on-chip memory management systems, such as MMUs or MPUs. These devices are normally set up and enabled during system startup. Therefore, the initialization sequence of processors with local memory systems requires special consideration.
The C library initialization code in
responsible for setting up the execution time memory map of the
image. Therefore, the run-time memory view of the processor must
be set up before branching to
__main. This means
that any MMU or MPU must be set up and enabled in the reset handler.
TCMs must also be enabled before branching to
normally before MMU/MPU setup, because you generally want to scatter-load
code and data into TCMs. You must be careful that you do not have
to access memory that is masked by the TCMs when they are enabled.
You also risk problems with cache coherency if caches are
enabled before branching to
__main. Code in
code regions from their load address to their execution address, essentially
treating instructions as data. As a result, some instructions can
be cached in the data cache, in which case they are not visible
to the instruction path.
To avoid these coherency problems, enable caches after the C library initialization sequence finishes executing.