cancel
Showing results for 
Search instead for 
Did you mean: 

use cortex debug support to detect a fault

Posted on October 21, 2015 at 17:36

Hello,

I'm working on a project on a STM32F429 and we experienced every 10 or more days a board reset. Based on the fault handler I detect that somebody is wasting my memory but I cannot get who is wasting it. I left a pc on debug on the board but after many days I cannot trigger while on the 50 boards in the lab I can get a reset almost every day. Considering I cannot use 50 pc in debug I was thinking if it's possible to enable the debug core after program init, manually enable a memory write watchpoint, enable the debug core irq and get in the irq the call stack to know who is wasting my memory, store in non volatile ram and then reset. I guess it should be feasible  but I cannot find anything online.  Can you point me out to some documentation?

Thanks

Michele
2 REPLIES 2
Posted on October 21, 2015 at 18:04

Doing postmortem analysis with a debugger into a hot system can be a challenge. You'll have to practice and figure out what level of visibility you need to figure anything out. I can halt things with a JLink and poke around in memory, but I suspect you want a full-on symbolic debugger.

If you suspect a memory leak within your system, presumably dynamic allocation, then may be you want to instrument the malloc/free, and tag the allocations, so you can figure out where it's going wrong before it fails days later. Is it a problem with heap fragmentation?

Make sure you don't have any exit paths that fail to free memory. At a minimum count the malloc/free and watch for the number diverging. It will quickly show if you're allocating and not freeing, or that you're freeing the same allocation multiple times.

My approach would be to add a ''monitor'' application into the fault handler, so I could interact with the broken system via a serial port, and have functions to scan the heap chain, and dump memory and statistics, etc. At a minimum have the fault handler except a key input, and output a diagnostic log, and sit in a loop that does that.

Use some imagination.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 22, 2015 at 14:20

Hello,

coming back to my question I found how to setup the DWT and I can see the comparator that trigger the event, the problem is that I need or to store the PC or to go in Irq. Actually I'm trying to understand how to do. I see there is the irq 12 that is linked to the debug core but it's hard to find documentation. Is there anybody that can give me some suggestions?

Thanks