Debugger misses start of the program in STM32CubeIDE
When debugging my firmware using STM32CubeIDE, the debugger seems to miss the start of the program. As an example, when I put breakpoints right at the top of main(), they are ignored. It's not only a couple of lines that are affected, but pretty much all the initialization etc. cannot be debugged because breakpoints there do not have an effect.
It seems to me as if the program would start before the debugger is ready/active, therefore debugging is only possible with a delay.
To confirm this, I put the following code at the top of main:
int test = 1;
while(test)
{
}The while-loop is not left until I manually change the value of test to 0, which then makes it possible to set breakpoints to other lines following, where breakpoints were ignored before.
This is very frustrating, as it makes debugging very cumbersome.
Also, if I add a specific call to my main() (HAL_DMA_DeInit()), I get the following error, which also seems to be related to gdb...?
Open On-Chip Debugger 0.12.0-rc1+dev-00061-g5e9b46d77 (2022-10-20-14:47) [https://github.com/STMicroelectronics/OpenOCD]
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
srst_only srst_pulls_trst srst_gates_jtag srst_open_drain connect_deassert_srst
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : connected to stlink-server
Info : stlink-server API v3, version 2.1.0
Info : STLINK V2J40S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 2.853841
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : clock speed 4000 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x6ba02477
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x6ba02477
Warn : target STM32MP157CAAx.ap2 examination failed
Error: Fail reading CTRL/STAT register. Force reconnect
Warn : target STM32MP157CAAx.axi examination failed
Info : stlink_dap_op_connect(reconnect)
Info : SWD DPIDR 0x6ba02477
Info : STM32MP157CAAx.cpu0: hardware has 6 breakpoints, 4 watchpoints
Info : STM32MP157CAAx.cpu1: hardware has 6 breakpoints, 4 watchpoints
Info : gdb port disabled
Info : gdb port disabled
Info : gdb port disabled
Info : starting gdb server for STM32MP157CAAx.cpu0 on 3334
Info : Listening on port 3334 for gdb connections
Info : starting gdb server for STM32MP157CAAx.cm4 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Error: Target not examined yet
Error executing event gdb-attach on target STM32MP157CAAx.cm4:
Info : New GDB Connection: 1, Target STM32MP157CAAx.cm4, state: examine deferred
Error: Target STM32MP157CAAx.cm4 not examined yet, refuse gdb connection 1!
Error: attempted 'gdb' connection rejected
shutdown command invokedIn this error, it says STM32MP157CAA, even though I am using an STM32MP153AAB3. The project was probably originally created for an STM32MP157, but as I understand the M4 part should be identical, so it should not cause the problem, right?
The error does not occur if I delay the start of the program using the while-loop from above.
As a debug configuration, I use ST-Link (OpenOCD) through Linux Core (Production Mode).
