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):

If otherwise have the MPU definition:

If the MPU macro is not defined:

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).