2022-02-10 08:03 AM
When an empty STM32G041 (others may have the same problem, couldn'T test) is flashed with an application, an real power-cylce is needed to actually start the application. Until this power-cycle, ever reset (HW or SW) will jump to the bootloader.
After a power-cycle each an every reset will jump to the application.
This can be reproduced with Erase-All and then PowerCycling.
When starting a debug-session, application is called (by the debugger?), but the VTOR-Reg points still to 0x1FFFxxxx causing a freeze on the first IRQ (i.e. SysTick).
Tested with CubeIDE and IAR, aswell as with a JLINK and a STLINK/v2.
Any comments/solutions/help?
Thanks and regards!
2022-02-10 08:13 AM
Working as intended. You can launch option bytes to reset the "empty flash" flag. Otherwise, need to do a reset power cycle.
https://community.st.com/s/article/Empty-check-mechanism-on-SMT32
2022-02-10 08:26 AM
Yes, this is a known behaviour.
It goes to ease of programming blank devices in newly manufactured boards, and a means of protecting against glitching and other mechanisms to break device security.
Your code can set the VTOR / memory mapping in the Reset_Handler, supposed also to be doing it in SystemInit() if following proper CMSIS guidelines any way.
ST in the past has had code snippets in startup.s for some CM0 parts, where VTOR isn't implemented, and they enable the SYSCFG clock, and set the FLASH mapping.