2026-02-04 1:35 AM - last edited on 2026-02-04 3:14 AM by Andrew Neil
Hello,
I stumbled over a weird problem when trying to debug Memory Protection Unit (MPU) settings which I want to document here in case any other people have the same issue:
Setup
Observed Fault
I observed that sometimes the RASR register of a MPU region was not programmed properly and retained its prior value. This lead to memory faults due to the incorrect configuration of either the access permissions or region size. Other incorrect settings were more rarely observed, for example that the RASR value meant for one region was instead written to the next region or that the region address was not programmed correctly. The exact faults were slightly different depending on the algorithm used to program the MPU regions, e.g. programming the regions using the alias registers versus programming the regions one-by-one using the RNR register.
Solution of the Problem
Adding memory barriers, wait loops between register writes or any other attempt to solve the problem did not succeed. After several days debugging I noticed by chance that the problem only occurs when I view the MPU region attributes using the TRACE32 debugger when the code is executing.
Thus, there seems to be an interference between the debug port and the MPU register interface which intermittently prevents writes to the MPU region registers when the debugger reads the values of them.
Lesson
Do not view the MPU region registers while code is executing. Only do this while the core is halted.