STM32 Not Entering Deep Sleep

I’m having trouble getting my STM32 NUCLEO-144 board (NUCLEO-F412ZG) to enter deep sleep. When I build the blinky example application, and attempt to monitor the CPU usage, I get this:

Uptime: 538979370 Idle time: 524874270 Sleep time: 524874270 Deep sleep time: 0

I added a mbed_app.json file with the following parameters as well:

{
“target_overrides”: {
“*”: {
“platform.cpu-stats-enabled”: 1,
“platform.stdio-convert-newlines”: true,
“platform.stdio-baud-rate”: 9600
}
},
“macros”: [“MBED_TICKLESS=1”, “MBED_CPU_STATS_ENABLED=1”]
}

None of this seems to help the board go into deep sleep. Also, note that it appears that there is a bug in the deep sleep tracing code for the STM32 that requires a whole bunch of weird workaround that essentially break the ability of the code to deep sleep.

When I use that workaround to get sleep tracing to not crash, I get the following output:

LOCK: SysTimer.cpp, ln: 115, lock count: 1
Sleep locks held:
[id: SysTimer.cpp, count: 1]
UNLOCK: SysTimer.cpp, ln: 154, lock count: 0

Any help with this would be appreciated.

Thanks!

-Dan Fay

So far, it looks like a lot of my problem was that the “Debug” build profile in Mbed Studio disables deep sleep. Using “Develop” instead caused me to start seeing the MCU enter deep sleep.

Hi
I confirm, mbed-os is disabling deep sleep with debug profile.