Debugger did not start from main - using st-util & arm-none-eabi-gdb

See original GitHub issue

Hi, 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:closed
  • Created a year ago
  • Comments:17

github_iconTop GitHub Comments

1reaction
haneefdmcommented, May 16, 2022

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.

Confused me too and wasted a LOT of my time a couple of years ago. You have to ask ST 😃

0reactions
Benasking7124commented, May 16, 2022

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 ~~

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: spawn arm-none-eabi-gdb ENOENT #8 - GitHub
Could not start debugger process, does the program exist in filesystem? Error: spawn arm-none-eabi-gdb ENOENT. Terminal: Andreys-Mac-Pro:Dev ...
Read more >
Debugging STM32F4 from SRAM - ST Community
I use TrueStudio to generate ld script to compile and assemble for SRAM. BOOT0 and BOOT1 pins are pulled HIGH. Then I start...
Read more >
Problem with GDB arm debugging - C / C++ IDE (CDT) - Eclipse
I am using GNU Arm tools to build the project, ST-Util or OpenOCD for the target gdb server, and GNU's arm-none-eabi-gdb for debugging....
Read more >
arm-none-eabi-gdb on stm32: warning - Stack Overflow
I compile an elf and bin file with debug support and upload the bin to the stm32. It is a simple LED blink...
Read more >
Debugging in studio works but not in VSCode - Mbed Forum
The problem I'm facing however is that I can't debug the executing code. My launch.json is as follows: { "version": "0.2.0", "configurations": [ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found