AnsweredAssumed Answered

Questions about hardware debug support (DBG)

Question asked by brown.geoffrey.001 on Oct 21, 2016
I have a few questions about the hardware debug support.

1)  Is there a way for software to detect and active SWD connection ?   
2)  Any examples of using the debug monitor exception ?

We're building some small data loggers and plan to use the SWD interface to configure and download data.   The first question relates to using breakpoint instructions to signal the swd debugger -- if one is not connected, we want to skip the bkpt.   (2) seems to offer a way for the debugger hardware to signal the device.   

I've had good luck using the st-util library to attach to a device and access the processor state -- even execute routines in the processor's memory.   But, I'd like to do something a bit more principled.

-------  Edit ----
I found the answer to most of my questions -- yes a running program can tell it a debugger is attached through the  C_DEBUGEN bit in the Debug Halting Control and Status Register  DBCSR.  It looks like a custom "debug monitor" is the way to go for what I want to do.  I can certain enter the debug monitor through polling.  Still trying to understand how to thave the st-link trigger a debug monitor interrupt -- seems doable, but I haven't tried yet.




Outcomes