platform-ststm32: board disco_l072cz_lrwan1 - [upload] Error 1 (OpenOCD init failed)

Configuration

Windows 10 Installed drivers: ST-Link drivers v2.0.1

Platformio version: Core 4.2.2a3, Home 3.1.1 Platform: ST STM 6.0.0 Framework: Arduino Board: disco_l072cz_lrwan1

In Device Manager the board is recognized as: COM port: STMicroelectronics STLink Virtual COM Port (COM17) USB device: ST-Link Debug In System Tray the board is visible as USB device: STM32 STLink, with drive DIS_L072Z (F:) So far this all looks normal.

Problem

When trying to upload a sketch I get the following error

Configuring upload protocol...
AVAILABLE: blackmagic, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
Uploading .pio\build\discovery-l072z-lrwan1\firmware.elf
xPack OpenOCD, 32-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-07:34)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

srst_only separate srst_nogate srst_open_drain connect_deassert_srst

Error: init mode failed (unable to connect to the target)
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked

*** [upload] Error 1

upload_protocol = stlink should be fine and is the default for this board.

I tried reconnecting the board, reboot and restart VScode several times but none made any difference.

What could go possibly wrong here? Is this a bug or did I overlook something?

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

To my understanding if application code was developed for/with Arduino Core STM32, it should also run just fine when using PlatformIO (with its STM32 and Arduino framework support). Or is this not true because of implementation differences.

It’s true, the code developed with Arduino Core STM32 should work with PlatformIO without modifications (except .ino files, that need to be converted to proper cpp in order to use intellisense in the IDE). The framework, build flags, linker scripts are identical. What may differ is build workflow (using static libs or objects directly, order of these libs when linking, etc) and upload methods,

Isn’t it just weird that its maintainer is not aware how PlatformIO has implemented its Arduino support

No, the core is dedicated for Arduino environment not for PIO. The core is open source and freely usable. All contribution are welcome :wink; PIO provide a way to use it and this is fine anyway I don’t have to know how it is integrated or used. The core is used in several other env or SDK and I always welcome any contribution if it can help to integration/use while it does not break Arduino compatibility and usage in the Arduino IDE. Finally, I would like to thanks @valeros and @ivankravets for their great work and effort. I know how it is sometimes hard to support/integrate several framework in an all in one environment. 👏

@lnlp

To my understanding Arduino Core STM32 was meant to support the Arduino framework in general with an implementation for Arduino IDE, but also that the framework implementation would be re-usable for other environments/IDE’s like PlatformIO. Is that assumption incorrect?

STM32duino GitHub organization support only the official Arduino ecosystem (Arduino IDE, arduino-cli, …) then it follows the Arduino API references, core and libraries specification for its ecosystem. Several of those specifications are not followed by other env/plugin/SDK. Ex: pre/post build recipe, packages dependencies, tools,…