2020-03-09 11:16 AM
Hello,
I have a Nucleo-G474RE with a simple blinker program mostly in WFI, awaking every Millisecond. I can can warm connect with STlinkV2 e.g. by pyOCD, but with on-board StlinkV2 pyOCD reports
Exception reading AP#0 IDR: STLink error (5): No device connected
I can connect when the program does not use WFI.
2020-03-09 04:18 PM
Enable the DBG_SLEEP bit in DBGMCU_CR register.
2020-03-10 03:36 AM
To enable DBG_SLEEP you need AP access. But as the error above tells, V3 fails to create the AP. So no chance to for any access! B.t.w. you first need to halt the CPU with DHCSR before you can write DBGMCU. But again, writing DHCSR needs AP access.
2020-03-21 11:38 AM
Enable it in code for debug builds before any WFI is executed! :) For example, system initialization is a good place.
2020-03-21 01:48 PM
Other debuggers can attach to the device in that situation. So it is some shortcoming of the StlinkV3.
2020-03-21 08:42 PM
For example SEGGER J-Link sets DBG_STANDBY | DBG_STOP|DBG_SLEEP bits before your code can execute WFI. ST-LINK (at least the on-board V2-1) doesn't do that. Apart form waiting on ST for a decades on simple things, another option is to add a debugger script.
# Enable Debug connection in low power modes (DBGMCU->CR)
set 0xE0042004 = (0xE0042004) | 0x7
http://blog.atollic.com/automate-your-gdb-debug-sessions-cortex-m-development
2020-03-22 06:48 AM
I knowe about those bits. But that changes nothing with the situation that e.g. pyOcd with StlinkV2 _can_ attach, while STLINKV3 does _not_ attach. This is a shortcoming of the StlinkV3 i.m.h.o.