-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Description of defect
STM32G474RE (NUCLEO-G474RE) gets hardfault when in debug mode and sleep mode is entered. Seems to be similar to #12294 and #12717. It only happens if debug build type is used or debugger connected once until power cycle. As I understand it happens because DBGMCU register values are not reset by hardware reset.
Target(s) affected by this defect ?
STM32G474RE (Nucleo board), but most probably whole G4 series.
Toolchain(s) (name and version) displaying this defect ?
I've tested two different configs (Windows):
- PlatformIO (toolchain-gccarmnoneeabi @ 1.90201.191206)
- GNU Arm Embedded Toolchain 10.3-2021.10
What version of Mbed-os are you using (tag or sha) ?
mbed-os-6.17.0
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
- PlatformIO 6.1.10 (framework-mbed @ 6.61700.0, tool-openocd @ 3.1200.0)
- Latest mbed-cli with latest openOCD.
How is this defect reproduced ?
To reproduce the bug you have to put device into sleep mode. In my case the following snippet is enough:
main.cpp
#include "mbed.h"
int main()
{
ThisThread::sleep_for(1000ms);
while (true) {}
}
The device puts crash info into VCP and led starts blinking as mbed enters mbed_die
function.
Solution
According to the errara sheet (2.2.8) it is enough to add ISB insruction after WFI in targets\TARGET_STM\TARGET_STM32G4\STM32Cube_FW\STM32G4xx_HAL_Driver\stm32g4xx_hal_pwr.c
line 475. Don't know whether it is needed at line 566, because it works after adding ISB after 475 line.