2020-04-03 01:03 AM
Dear people,
I do not understand the following behavior of the STM32H755ZI:
I implemented a stack test by configuring a safety zone with MPU. When the stack overflows, the MemManage Handler is called. So far so good.
In this MemManage Handler I only save the exception info in a "noinit" section and then trigger a NVIC SystemReset.. The MCU does not reset, it directly falls into HardFault Handler.
The saving of the exception info needs another access to the stack which actually again is a MemManage Fault., so the command NVIC_SystemReset never gets reached.
Could this second Memory Fault in MemManage Handler leads to the HardFault?
Thanks a lot .
Kind regards
Michael
2020-04-03 06:27 AM
If your error handlers causes errors and calls itself, you're screwed. You could implement a valid memory check in MemManage handler to ensure data you're accessing is in a valid range.
2020-04-03 07:04 AM
AFAIK if the stack overflows into the protected area, then the values written there are lost, don't try to recover them.
You can set up separate stack pointers (PSP and MSP) for the application and the interrupt handlers, right in the Reset_Handler(). See the Programming manuals for details on each core. It won't solve the problem if there is a stack overflow in an interrupt handler, so you might still have to rewrite the MemManage_Handler() with a stack pointer check in assembly to be more robust.
2020-04-03 07:19 AM
Thanks a lot for your answers. :)
I'm going to check the stack pointer in MemManage_Handler() and try to catch it if necessary.
Have a nice weekend