MPU Interfering with Tracing

ARM Cortex-M3 and higher processors include a memory protection unit (MPU) that allows marking some regions of memory non-executable. This can interfere with trace programs placed into RAM.

If you see a warning about the MPU interference with tracing, and the tracepoints are not working, consider adding one of the following lines at the beginning of main():

If using Zephyr (e.g. nRFConnect):

ARM_MPU_Disable();

If otherwise have the MPU definition:

MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;

If the MPU macro is not defined:

*((unsigned *)0xE000ED94) = 0;

This will disable the memory protection unit for the runtime of the program, allowing it to run trace programs from memory. Once done tracing, you can comment out the added line, or make it conditional to debug configurations (#ifdef DEBUG).