[En-Nut-Discussion] Watchdog Debugging

Timothy M. De Baillie debaillie at ciholas.com
Wed Sep 24 16:41:10 CEST 2008


I was thinking the other day that it would be useful to be able to 
determine which thread / interrupt caused a watchdog.  We have done this 
in our offices before by toggling some output lines after every Yield, 
Sleep, EventWait, EventPost, fflush, and other OS functions that yield.  
I have even recompiled the OS before to do the same thing so that I 
could trace it down well enough.

One idea that crossed my mind would be very simple to implement across 
the OS and user code.  If you could assign a specific piece of memory 
(say 4 bytes of high heap memory) to keep thread flags, upon reboot, 
your program could detect a watchdog reboot and then report the 4 bytes 
back to the user.

The only thing that really keeps this from being super simple to 
implement is that it requires making sure the heap manager (NutHeapAlloc 
/ malloc) NEVER uses this area of memory.  I'm sure we could rewrite the 
DEBUG version of the OS to do that! 

Any thoughts or improvements out there in the ether?

Another thought looking through the OS, the _putf function in crt/putf.c 
should probably have a pointer to a structure that includes all of the 
variables that it declares.  It could dynamically allocate and free the 
memory needed for this structure.  This is the part of fprintf that 
"explodes" your memory usage and causes oh so many stack overflows.

Thanks,

Tim DeBaillie



More information about the En-Nut-Discussion mailing list