Hello Guys,
just to let you know, I am a first time user of PlatformIO inside Visual Code Studio, before i only used Arduino together with SMT32duino to program STM32 boards.
I currently have a problem with uploading to a STM32G071GBU6N.
PlatformIO.ini:
[env:Generic_G071GBUxN]
platform = ststm32
framework = arduino
board = Generic_G071GBUxN
lib_archive = false
upload_protocol = stlink
debug_tool = stlink
debug_port = 127.0.0.1:5555
board_build.ldscript = ./boards/ldscript.ld
Error message:
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:04)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
hla_swd
Error: init mode failed (unable to connect to the target)
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked
*** [upload] Error 1
What did i try:
- uploading to the STM with a StLink programmer included in a Nucelo board
What did i do:
- Install newest STM32CubeProgrammer tool includijng drivers
- make a custom board definition to program the unsupported board
- try different debug_ports and tools
First of all It works flawlessly in Arduino and in STM32CubeProgrammer. I can connect to the G071 without problems, can erase and program it.
Second: it also works with:
PlatformIO.ini:
upload_protocol = mbed
So i am very certain that the connections are correct.
Third: It also works the first time.
I can erase the chip with STM32CubeProgrammer and than get a single chance to upload with PlatformIO. The upload “fails” with the same “Error 1” but actually uploads the code.
After that I only get the above error message and cant reupload.
I have read that this might be an issue regarding post upload debug connection which cant be established, so in tried some random debug settings but nothing works.
What i want to to:
- upload with STLink and upload_protocol = stlink for faster uploads
- debug with STLink
Any suggestions how i can do that/what i am doing wrong?
I also have no idea how to get debugging working.
I am on Windows 11 BTW.
Just to have everything in one post, here is the custom board definition which might also be wrong?
{
"build": {
"core": "stm32",
"cpu": "cortex-m0plus",
"extra_flags": "-DSTM32G0xx -DSTM32G071xx",
"f_cpu": "64000000L",
"framework_extra_flags": {
"arduino": "-D__CORTEX_SC=0 -DARDUINO_GENERIC_G071GBUXN"
},
"mcu": "stm32g071gbuxn",
"product_line": "STM32G071xx",
"variant": "STM32G0xx/G071G(8-B)UxN_G081GBUxN"
},
"debug": {
"default_tools": [
"stlink"
],
"jlink_device": "STM32G071GBUxN",
"onboard_tools": [
"stlink"
],
"openocd_target": "stm32g0x",
"svd_path": "STM32G071.svd"
},
"frameworks": [
"arduino",
"cmsis",
"libopencm3",
"stm32cube",
"zephyr"
],
"name": "Generic_G071GBUXN",
"upload": {
"maximum_ram_size": 36864,
"maximum_size": 131072,
"protocol": "stlink",
"protocols": [
"stlink",
"jlink",
"cmsis-dap",
"blackmagic",
"mbed"
]
},
"url": "https://www.st.com/en/evaluation-tools/nucleo-g071rb.html",
"vendor": "ST"
}