STLink debugger doesn't come back from deepsleep

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
dolfandringa
Posts: 20
Joined: Wed Jun 03, 2020 3:47 am

STLink debugger doesn't come back from deepsleep

Post by dolfandringa »

Hi all,

I am using the LowPower and STM32RTC libraries for the Arduino Core, using platformio, to put my device into a 1 minute wake/sleep cycle. After 4 sleep cycles there is a problem which I want to debug using my STLink debugger (and gdb).
This is the code to put it to sleep

Code: Select all

    STM32RTC &rtc = STM32RTC::getInstance();
    LowPower.enableWakeupFrom(&rtc, wakeup, &data);
    uint32_t now = rtc.getEpoch();
    rtc.setAlarmEpoch(now + sleep_time);
    LowPower.deepSleep();
This works fine normally, but once I run the code in debug mode using the debugger, the device never comes out of deepSleep. If I abort the code, it seems to be stuck in

Code: Select all

/system/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c:120
120       __asm volatile( "nop" );
Is there any way to get the deepSleep to work with the stlink debugger so I can debug the actual problem that I am having?
User avatar
fpiSTM
Posts: 1164
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 56
Location: Le Mans
Contact:

Re: STLink debugger doesn't come back from deepsleep

Post by fpiSTM »

In debug mode some context are not the same.
This would require some extra configuration.

For example for he STM32F103:
http://www.st.com/st-web-ui/static/acti ... 171691.pdf
dbg_lp.png
dbg_lp.png (12.06 KiB) Viewed 1514 times
dolfandringa
Posts: 20
Joined: Wed Jun 03, 2020 3:47 am

Re: STLink debugger doesn't come back from deepsleep

Post by dolfandringa »

Cool, thanks. That gave me a pointer to search in the source of the arduino core. There is a function HAL_DBGMCU_EnableDBGStopMode (the official name of the LowPower.deepSleep mode is actually STOP mode in STM32 lingo) that I can use to set that register. But that still doesn't solve the issue. Even if I call it before LowPower.deepSleep, the device still hangs at the same place.
Post Reply

Return to “General discussion”