STM32 UART output occurs before code execution starts (Debug > Resume)
Hi everyone,
I'm working on an STM32 project using STM32CubeIDE. I'm using the built-in debugger with ST-LINK and UART (via HTerm) to monitor communication between the STM32 and a host PC.
Here's something odd I noticed:
When I click the "Debug" button in STM32CubeIDE (but before I press "Resume"), I already see some UART output in HTerm, like:
AA 00 40 02 00 00 4D 55
AA 00 50 02 00 00 2A 55
Then, when I press "Resume", the same two messages are sent again. So in total I see them twice.
This seems strange because I wouldn't expect the UART to be transmitting anything before the code is running (i.e., before Resume is hit). But clearly, something is happening during the debugger halt or initialization phase.
Is this normal?
Is it common for STM32CubeIDE to somehow "pre-run" some initialization code before Resume?
Could it be something about HAL_UART_Transmit being called from main() before HAL_Init() fully returns?
Or maybe the ST-LINK somehow triggers this?
The program runs fine otherwise, but I want to understand the root cause — especially to avoid confusing behavior in downstream systems (like GUI apps reacting to these messages).
Thanks in advance!
