cancel
Showing results for 
Search instead for 
Did you mean: 

MPU RASR register write fails intermittently when MPU region registers viewed in debugger

BGo
Associate II

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

  • The used MCU is a STM32H7S3L8H6 on a STM32H7Rx/7Sx Nucleo-144 board (MB1737)
    • Core frequency is 400 MHz.
    • Enabling or disabling the cache has no impact on the problem.
    • The code is executed from the internal flash, the stack and variables are placed on the DTCM.
  • The debugger which I use is a Lauterbach CombiProbe 2 attached to a Power Debug Pro Ethernet. TRACE32 PowerView software version is R.2025.09.000186004.
  • The executed software is a custom operating system which uses the MPU to prevent user-space threads from accessing memory regions not allocated to the threads. For this, one MPU region each is used for ROM, RAM and stack. The MPU is activated before the thread is executed and disabled afterwards. The background region is active.
  • I have not tried to reproduce the error by using similar MCUs or other debuggers.

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.

0 REPLIES 0