I am using a Nucleo L031K6 w/ on-board ST-Link, but the following probably applies to other STM32 setups.
With default configuration, flashing the board fails if the STM32 is in a low power mode (I tested in sleep and stop modes). After digging around openocd settings, I’ve found that changing the following line in stm32l0.cfg fixes the problem.
# default configuration - flashing fails when stm32 is in low power mode reset_config srst_nogate # updated configuration - flashing works when stm32 is in low power mode reset_config trst_and_srst srst_nogate connect_assert_srst
I think having this as the default behavior in the .cfg file or providing a flag in platform.ini would be better than having to edit the .cfg file directly.