Debugger did not start from main - using st-util & arm-none-eabi-gdb
See original GitHub issueHi, I’m trying to use VSCode along with this extension, st-util, and arm-none-eabi-gdb to debug my stm32 board.
But every time I start the debug sesion, it won’t stop at “main”. Instead, it will run for a random amount of cycles then pause.
It will ignore any break point before while(1) loop. And for the break point inside the while(1) function, it will not stop but not at the first iteration. Therfore, I assume it stopped after running for a while.
the arm-none-eabi-gdb version is 11.2-2022.02 (GNU gdb (Linaro_GDB-2019.12) 11.2.90.20220202-git) The arm gnu toolchain I use is installed from source following the release note instruction. https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads
the st-util version is v1.7.0-186-gc4762e6 https://github.com/stlink-org/stlink
I’m on Ubuntu 20.04
And below is my settiong.json:
{
"makefile.extensionOutputFolder": "./.vscode",
"files.associations": {
"main.h": "c"
},
"cortex-debug.gdbPath": "/home/ben/stm32_tools/abe_build/builds/destdir/x86_64-pc-linux-gnu/bin/arm-none-eabi-gdb",
"cortex-debug.stutilPath": "/usr/local/bin/st-util"
}
And below is my launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ST-Link Debug",
"cwd": "${workspaceFolder}",
"executable": "./build/CPP_Test.elf",
"device": "STM32F407VE",
"request": "launch",
"type": "cortex-debug",
"runToEntryPoint": "main",
"servertype": "stutil",
"interface": "swd"
}
]
}
And below is my main function:
int main(void)
{
int n = 0;
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
MX_GPIO_Init();
MX_USART2_UART_Init();
while (1)
{
n++;
}
}
And below is my debug console output:
Reading symbols from /home/ben/stm32_tools/abe_build/builds/destdir/x86_64-pc-linux-gnu/bin/arm-none-eabi-objdump --syms -C -h -w /home/ben/stm32_ws/CPP_Test/build/CPP_Test.elf
Reading symbols from /home/ben/stm32_tools/abe_build/builds/destdir/x86_64-pc-linux-gnu/bin/arm-none-eabi-nm --defined-only -S -l -C -p /home/ben/stm32_ws/CPP_Test/build/CPP_Test.elf
Launching GDB: /home/ben/stm32_tools/abe_build/builds/destdir/x86_64-pc-linux-gnu/bin/arm-none-eabi-gdb -q --interpreter=mi2 /home/ben/stm32_ws/CPP_Test/build/CPP_Test.elf
Set "showDevDebugOutput": true in your "launch.json" to see verbose GDB transactions here. Helpful to debug issues or report problems
Launching gdb-server: /usr/local/bin/st-util -p 50000 --no-reset
Please check TERMINAL tab (gdb-server) for output from /usr/local/bin/st-util
Finished reading symbols from objdump: Time: 35 ms
Finished reading symbols from nm: Time: 41 ms
Reading symbols from /home/ben/stm32_ws/CPP_Test/build/CPP_Test.elf...
Warning: 'set target-async', an alias for the command 'set mi-async', is deprecated.
Use 'set mi-async'.
0x08004250 in main () at Core/Src/main.cpp:98
98 n++;
Program stopped, probably due to a reset and/or halt issued by debugger
Note: automatically using hardware breakpoints for read-only addresses.
Run to 'main' timed out. Trying to pause program
Thank you for making such gread extension! And Thank you in advance for helping me solve this issue ~~
Issue Analytics
- State:
- Created a year ago
- Comments:17
Top Related StackOverflow Question
Confused me too and wasted a LOT of my time a couple of years ago. You have to ask ST 😃
I see!! Then I’ll use STLink then.
The CubeIDE solution work perfectly! Thank you~ I just thought that ST-Link server contains ST-LINK GDB server! May I ask what ST-Link server is for? It seems very similar to “STM32CubeProgrammer”. All I can see is that they can flash binary into board and read memory.
OK I will keep that in mind!! I see!! Thank you for explaining to me ~~