Hello,
I’m trying to debug a project for STM32 F4 using PlatformIO and I’m getting when I select option “Start Debugging” the following error:
Assembler messages:
Fatal error: unknown option `-g2'
Compiling .pio/build/stm32cubef4/src/adc.o
*** [.pio/build/stm32cubef4/src/Startup/startup_stm32f407vetx.o] Error 1
When building and uploading the release version, works fine and I can upload and run properly.
I’ve setup the project to compile for ST STM32 in “Bare Metal way”:
platformio.ini:
[platformio]
default_envs = stm32cubef4
[env:stm32cubef4]
platform = ststm32
board = genericSTM32F407VET6
board_build.stm32cube.custom_config_header = yes
board_build.ldscript = $PROJECT_DIR/STM32F407VETX_FLASH.ld
upload_protocol = stlink
platform_packages =
toolchain-gccarmnoneeabi @ 1.120301.0
extra_scripts = pre:compile_flags.py
build_flags =
-Iinclude
-Isrc/CMSIS/Device/ST/STM32F4xx/Include
-Isrc/CMSIS/Include
-Isrc/STM32F4xx_HAL_Driver/Inc
-Isrc/STM32F4xx_HAL_Driver/Inc/Legacy
-Isrc/BSP/Components/lan8742
lib_archive = no
If add the following line to remove default debug flags it works, but then I see assembly code instead the C code:
debug_build_flags =
Another strange thing, if I don’t fix the toolchain version with following file, for some reason Platformio picks are version old version of the toolchain, 7.2.1 even though I’m using the latest version of the ststm32 platform:
platform_packages =
toolchain-gccarmnoneeabi @ 1.120301.0
Any idea where -g2 flag is coming from or what are the debug default flags?