Yes, I use fresh drivers and STLink is shown in Device manager as STM32 STLink
I also updated the STLink firmware.
P.S. I doesn’t look like a problem of rights to access device. I just tested it: replaced the board with BluePill and selected the board as bluepill_f103c8, and programming was successful.
Aha so the error suddenly changed and now it does find the STLink v2 probe. Can you try to connect the NRST signal of the STLink to the R pin (reset) of the target board and retry?
> Executing task: C:\Users\UserName\.platformio\penv\Scripts\platformio.exe run --target upload <
Processing disco_f401vc (platform: ststm32; board: disco_f401vc; framework: mbed)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/disco_f401vc.html
PLATFORM: ST STM32 5.7.0 > ST 32F401CDISCOVERY
HARDWARE: STM32F401VCT6 84MHz, 64KB RAM, 256KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
PACKAGES: toolchain-gccarmnoneeabi 1.70201.0 (7.2.1), framework-mbed 5.51401.191023 (5.14.1), tool-stm32duino 1.0.2, tool-openocd 2.1000.190707 (10.0), tool-dfuutil 1.9.190708
Collecting mbed sources...
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 4 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\disco_f401vc\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
DATA: [= ] 5.7% (used 3768 bytes from 65536 bytes)
PROGRAM: [== ] 18.1% (used 47412 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, jlink, stlink
CURRENT: upload_protocol = stlink
Uploading .pio\build\disco_f401vc\firmware.elf
xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:28)
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: timed out while waiting for target halted
embedded:startup.tcl:449: Error: ** Unable to reset target **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 474
at file "embedded:startup.tcl", line 449
*** [upload] Error 1
============================================================================== [FAILED] Took 7.45 seconds ==============================================================================
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
Long:
PS C:\Users\UserName\Documents\PlatformIO\Projects\blink> pio run -t upload -v
Processing disco_f401vc (platform: ststm32; board: disco_f401vc; framework: mbed; upload_protocol: stlink)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/disco_f401vc.html
PLATFORM: ST STM32 5.7.0 > ST 32F401CDISCOVERY
HARDWARE: STM32F401VCT6 84MHz, 64KB RAM, 256KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
PACKAGES: toolchain-gccarmnoneeabi 1.70201.0 (7.2.1), framework-mbed 5.51401.191023 (5.14.1), tool-stm32duino 1.0.2, tool-openocd 2.1000.190707 (10.0), tool-dfuutil 1.9.190708
Collecting mbed sources...
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 4 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".pio\build\disco_f401vc\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
DATA: [= ] 5.7% (used 3768 bytes from 65536 bytes)
PROGRAM: [== ] 18.1% (used 47412 bytes from 262144 bytes)
.pio\build\disco_f401vc\firmware.elf :
section size addr
.text 44628 134217728
.ARM.exidx 8 134262356
.data 2776 536871320
.bss 992 536874096
.heap 57264 536875088
.ARM.attributes 46 0
.comment 126 0
.debug_info 348082 0
.debug_abbrev 51867 0
.debug_loc 64539 0
.debug_aranges 7056 0
.debug_ranges 8856 0
.debug_line 84716 0
.debug_str 64362 0
.debug_frame 23444 0
Total 758762
<lambda>(["upload"], [".pio\build\disco_f401vc\firmware.elf"])
AVAILABLE: blackmagic, jlink, stlink
xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:28)
CURRENT: upload_protocol = stlink
Licensed under GNU GPL v2
openocd -d2 -s "C:\Users\UserName\.platformio\packages\tool-openocd/scripts" -f board/stm32f4discovery.cfg -c "program {.pio\build\disco_f401vc\firmware.elf} verify reset; shutdown;"
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 2000 kHz
Info : STLINK V2J33S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 6.392157
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Error: timed out while waiting for target halted
embedded:startup.tcl:449: Error: ** Unable to reset target **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 474
at file "embedded:startup.tcl", line 449
*** [upload] Error 1
============================================================================== [FAILED] Took 7.49 seconds ==============================================================================
P.S. Interesting observation. I also have original Nucleo-F411RE. If I’m wiring its ST-Link part to target board : uploads from VS Code works (only if reset pin is connected). External ST-Link - no.
Okay let’s try a few reset configurations. Can you go in C:\Users\UserName\.platformio\packages\tool-openocd\scripts\board\ in the file stm32f4discovery.cfg, instead of the line reset_config srst_only, test these options in sequence:
I have similiar issue like OP just the circumstances are different. I have a windows machine with freshly installed VSCode and PlatformIO running the remote agent. A Nucleo L432KC board is attached to this machine.
I am trying to remote upload a firmware to the Nucleo board from a different machine (which has fresh VSCode and PlatformIO installed, also I am able to program the nucleo board directly from this machine).
When I try to upload remotely the firmware I am getting the libusb_open()… error message in the terminal of the host machine.
On the remote machine, there is no error message and the last message is: “Remote command received: run”
Could someone help me out, how to resolve this problem? There is not much information in the wild or I just failed to find them…
One question remained from my side: sometimes when I try to program the chip the “init mode failed” error message appears in the terminal during uploading. I can resolve this by clearing the chip with CubeProgrammer, but it need physical intervention for this (holding the reset button on the board while connecting with the programmer).
Do you know what can be the root cause so I could avoid this in the future?
Please use the following command to install the driver for the ST-Link: sudo apt -y install stlink-tools . By doing so, it should start working properly.