We have from time to time our application that hangs shortly after the boot. We are not able to find what make the CPU freeze. The code is initializing peripherals at the time the CPU freeze. What I mean by freeze is that the program execution stops and we are not able to debug or access the CPU in anyway using SWD. (debug attach fails, access to RAM fails, etc..). Only a hard reboot can then exit this state (util, it locks again on the next boot). We can see a few prints over the LPUART before the CPU freeze.
When a program image hand the CPU, this happens 100% of the boots. Changing a little in the image, such as adding "nop" instruction, can change a running image to a "freezing" image and vice-verca. This is really strange, and we have no explanation so far. Compiling on different PC or running the image on different target is consistent.
The actual questions
What can case the SWD debug port to stop working ? What can cause the CPU to go in such a undetermined "freeze" state ?
What was done