Failed to init openocd -- cannot find xxxxx.cfg

While I’m trying to upload my code, the VScode show me that openocd init failed.
I’m using Windows10
STM32F103ZET6,
openocd 0.10.0,
JLink v8.0
and PlatformIO with VScode.

The openocd is failed to find jlink.cfg and all other .cfg files even if I copy the .cfg files to openocd’s root dir

*Here are the error info while I’m using “openocd -f jlink.cfg”:

PS C:\Users\wjb12\Desktop\PIO> openocd -f jlink.cfg
Open On-Chip Debugger 0.10.0 (2018-11-30)
Licensed under GNU GPL v2
For bug reports, read

embedded:startup.tcl:60: Error: Can’t find jlink.cfg
in procedure ‘script’
at file “embedded:startup.tcl”, line 60

*And here’s the platform error info:

Processing genericSTM32F103ZE (platform: ststm32; board: genericSTM32F103ZE; framework: stm32cube)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: ST STM32 > STM32F103ZE (64k RAM. 512k Flash)
HARDWARE: STM32F103ZET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(jlink) EXTERNAL(blackmagic, jlink, stlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder → /bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 0 compatible libraries
Scanning dependencies…
No dependencies
Checking size .pioenvs\genericSTM32F103ZE\firmware.elf
Memory Usage → /bit.ly/pio-memory-usage
DATA: [ ] 0.0% (used 28 bytes from 65536 bytes)
PROGRAM: [ ] 0.2% (used 844 bytes from 524288 bytes)
Configuring upload protocol…
AVAILABLE: blackmagic, dfu, jlink, serial, stlink
CURRENT: upload_protocol = stlink
Uploading .pioenvs\genericSTM32F103ZE\firmware.elf
GNU MCU Eclipse 64-bits Open On-Chip Debugger 0.10.0+dev-00392-gbe9ef0b0 (2018-01-12-15:03)
Licensed under GNU GPL v2
For bug reports, read

hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
IInfo : clock speed 950 kHz
Error: open failed
in procedure ‘program’
in procedure ‘init’ called at file “embedded:startup.tcl”, line 495
in procedure ‘ocd_bouncer’
** OpenOCD init failed **
shutdown command invoked

*** [upload] Error 1

/I deleted the links in the error info because of th limits/

The first error is different to the last error. In the first one you are just invoking some openocd with a config file but the wrong path (interfaces/jlink.cfg) or a missing -s switch for the path to thte scripts/ folder inside openocd.

I’d try re-uploading to the board while holding down the RESET button on the board.

1 Like

Do you use J-Link? See how to change upload protocol/method STM32F103ZE (64k RAM. 512k Flash) — PlatformIO latest documentation

upload_protocol = jlink

Hey , I found similar problem, what I did is press the reboot button during flash and release it during flash. Hope it will work.