platformio / platformio-core

Your Gateway to Embedded Software Development Excellence :alien:
https://platformio.org
Apache License 2.0
7.8k stars 785 forks source link

Debugging with blackmagicprobe crashes at start. #4932

Open positron96 opened 2 months ago

positron96 commented 2 months ago

What kind of issue is this?

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system: Win 10 x64

PlatformIO Version (platformio --version): PlatformIO Core, version 6.1.15

Description of problem

I've setup a project with STM32G030 MCU with blackmagicprobe used as debugger/uploader. The MCU has been programmed and debugged fine for a month, but at some point I noticed that debugging fails right at the start.

The error in VSCode Debug console is

Remote failure reply: EE02000000000000FFFFFFFFFFFFFFFFD0020020FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEE02000000200020DB1B0008B01A00080000006100200020FCFFFFFF00000000

Uploading firmware via BMP from PlatformIO still works. Uploading and debugging with stlink from PlatformIO also works fine. I tried to use GDB to issue commands to BMP directly, and it seems to work fine. At least I was able to connect, select elf, reset, start/stop/step the program manually. Though I don't quite know what commands pio sends when debugging and what command causes the crash.

If I go back in git history, previous versions of my code can be debugged properly, so the problem shows for a combination of specific source + BMP + PlatformIO.

At the moment I would like to not disclose the source code unless absolutely necessary, and it could be tied to my specific BMP hardware/software version. So it will be hard to reproduce, so I am prepared to do some troubleshooting myself (I vaguely remember having GDB communication somewhere in vscode output tabs, but it's not there now. It would be rather useful for troubleshooting).

Steps to Reproduce

  1. In vscode, go to Debug tab and execute "PIO Debug" configuration.

Actual Results

The code is compiled, uploaded, a debugging section is started, "current line" is highlighted in source code editor (it's in initial assembly code)

The error appears in vscode debugging console, no further debug actions are possible except killing the debug session.

Full output of vscode Debug console

``` Reading symbols from d:\Documents\PlatformIO\Projects\motorboard\.pio\build\motorboard\firmware.elf... done. PlatformIO Unified Debugger -> https://bit.ly/pio-debug PlatformIO: debug_tool = blackmagic PlatformIO: Initializing remote target... Target voltage: 3.28V Available Targets: No. Att Driver 1 STM32G03/4 M0+ LL_mDelay (Delay=Delay@entry=1) at C:\Users\positron\.platformio\packages\framework-stm32cubeg0\Drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_utils.c:183 183 while (tmpDelay != 0U) Loading section .isr_vector, size 0xb8 lma 0x8000000 Loading section .text, size 0x2f7c lma 0x80000b8 Loading section .rodata, size 0x1a0 lma 0x8003034 Loading section .init_array, size 0x10 lma 0x80031d4 Loading section .fini_array, size 0x4 lma 0x80031e4 Loading section .data, size 0x88 lma 0x80031e8 Start address 0x8001ba4, load size 12912 Transfer rate: 25 KB/sec, 717 bytes/write. Temporary breakpoint 1 at 0x8001ab0: file src\cube\Core\Src\main.c, line 73. Warning: the current language does not match this frame. PlatformIO: Initialization completed PlatformIO: Resume the execution to `debug_init_break = tbreak main` PlatformIO: More configuration options -> https://bit.ly/pio-debug Note: automatically using hardware breakpoints for read-only addresses. Remote failure reply: EE02000000000000FFFFFFFFFFFFFFFFD0020020FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEE02000000200020DB1B0008B01A00080000006100200020FCFFFFFF00000000 ```

ivankravets commented 1 month ago

Here is the init script https://github.com/platformio/platformio-core/blob/develop/platformio/debug/config/blackmagic.py

Could you help us to debug this issue?

positron96 commented 1 month ago

Yes, I'll try to reproduce the failing setup...