I’ve been trying to do some debugging with platformio and I’m finding the process to be a little obscure. I ran the debug configuration and I get back
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = stlink
PlatformIO: Initializing remote target...
.pioinit:13: Error in sourced command file:
error starting child process '| "C:/Users/Ya/.platformio/packages/tool-openocd/bin/openocd.exe" -s "C:/Users/Ya/.platformio/packages/tool-openocd" -c "gdb_port pipe; tcl_port disabled; telnet_port disabled" -s "C:/Users/Ya/.platformio/packages/tool-openocd/openocd/scripts" -f "interface/stlink.cfg" -c "transport select hla_swd" -f "target/stm32h7x.cfg"': CreateProcess: No such file or directory
I’m not really sure what this means but I figure it’s probably not actually building with debug flags or something but I’m not really sure what I’m doing wrong.
You seem to be running in the same bug I’ve run into with a GCC 12 toolchain that pipe mode is just broken. See
The solution is to use a lower toolchain version (< 12) or >= 13 one. The latter is not provided by PlatformIO in its registry, so you’d have to download it yourself, add a package.json to it like in C:\Users\<user>\.platformio\packages\toolchain-gccarmnoneeabi\package.json and point to it in the platformio.ini using platform_packages = toolchain-gccarmnoneeabi@symlink://<your new compiler path>.
correct me if I’m wrong, but can’t I just point it directly to a git link instead of downloading manually and then adding a package.json? or does that only work if there is a package.json? I would love to just downgrade my version, but I need something >= 12 to get my C++ project to work properly
Yeah I understand that, what I meant to say was is it possible to simply point platform_packages to git://gcc.gnu.org/git/gcc.git since I’ve seen it done with github links in the documentation, but I guess not. I’ll give the custom package.json a go, although I’ve had trouble in the past.
I also have been reading through the second github issues link you sent, but trying to use the toolchain update linked in that repository seems to break my build entirely. It doesn’t seem to like the idea of using C++20 even though that worked just fine when i was using the 12.xxx version in the registry.
Hmmm, interesting, that exact combo seemed to work back on 12.0, but just getting rid of both the build flags and unbuild flags actually builds this time around for this project. and the debugger is … working more than it was before now, although it still doesn’t quite work. It doesn’t seem to recognize my breakpoints and I get
[stm32h7x.cpu0] halted due to debug-request, current mode: Thread
xPSR: 00000000 pc: 0xf0130300 msp: 0xea414684
[stm32h7x.cpu0] halted due to debug-request, current mode: Thread
xPSR: 00000000 pc: 0xf0130300 msp: 0xea414684
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = tbreak main`
PlatformIO: More configuration options -> https://bit.ly/pio-debug
seems like the debug symbols aren’t included. Is there anything you have to do to the PIO config to get it to build with debug flags? I assumed simply running PIO-debug like in the tutorials (and in my arduino based projects) would get things working.
That looks weird. Can you post the whole platformio.ini and used scripts? The binary should be build in debug mode automatically (-Og -g -ggdb3), unless something destroys it.
[platformio]
; This is the root directory of the STM32CubeIDE project. Platformio can only
; take one source directory, thus we filter the sources using a
; source filter and additional build options to include the headers.
; Do not change this value
src_dir = ./
; The project headers are defined here to be available for the libraries as well
; Do not change this value
include_dir = Core/Inc
lib_dir = Core/Startup
[env:nucleo_h723zg]
platform = ststm32
board = nucleo_h723zg
; build_flags = -std=gnu++2a
; build_unflags= -std=gnu++14
platform_packages =
; use newer gccarm toolchain
toolchain-gccarmnoneeabi@~1.100301.0
extra_scripts = pre:setup_cubemx_env_auto.py
debug_tool = stlink
upload_protocol = stlink
I fixed it, I forgot a step from my last project in which I learned you have to move the linker script from the startup folder to the src folder for it to get used properly. I did that and now although the debugger starts at main for some reason no matter what, it actually debugs properly . What a mission this has been.