Hi there, I’m struggling with uploading my code to an STM32 successfully on PlatformIO. My issue seems to be quite similar to Error while trying to upload code to BluePIll [SOLVED], except for the fact that my issue likely lies with OpenOCD.
Here is my platformio.ini file:
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
upload_protocol = stlink
debug_tool = stlink
upload_flags = -c set CPUTAPID 0x2ba01477
build_flags =
-Os
-I
-O1
-Wl,--undefined,_printf_float
-Wl,--undefined,_scanf_float
-DPIN_SERIAL_TX=PA9
-DPIN_SERIAL_RX=PA10
lib_deps =
adafruit/Adafruit BNO055 @ ^1.6.3
adafruit/Adafruit BusIO @ ^1.14.5
Wire
SPI
adafruit/Adafruit Unified Sensor @ ^1.1.14
And here is the error I’m getting:
Building in release mode
Checking size .pio\build\bluepill_f103c8\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 8.0% (used 1636 bytes from 20480 bytes)
Flash: [===== ] 52.7% (used 34532 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
Uploading .pio\build\bluepill_f103c8\firmware.elf
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
0x2ba01477
hla_swd
none separate
Warn : UNEXPECTED idcode: 0x1ba01477
Error: expected 1 of 1: 0x2ba01477
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked
*** [upload] Error 1
I’ve re-installed OpenOCD quite a few times now through mingw and added it to my system PATH variables. The OpenOCD command does work on powershell, but I also get this error:
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
embedded:startup.tcl:28: Error: Can't find openocd.cfg
in procedure 'script'
at file "embedded:startup.tcl", line 28
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: Debug Adapter has to be specified, see "adapter driver" command
embedded:startup.tcl:28: Error:
in procedure 'script'
at file "embedded:startup.tcl", line 28
Which I can’t seem to fix no matter what I’ve tried from what I could find online. Like in the other thread I linked up top, I tried connecting to my STM32’s chip through the STM32CubeProg and was able to successfully connect, so I highly suspect this is an issue with OpenOCD.
Any help on how to properly install OpenOCD and get it working with PlatformIO would be greatly appreciated!
