Uploading to STM32F104C8 via ST-Link - LIBUSB_ERROR_ACCESS

Hi there,
I am moving from playing with Atmel to STM32, and because I really like PlatformIO i would to continue also with STM32 under pio.

When I upload my project using stlink as upload protocol, it ends up with:

Linking .pio\build\bluepill_f103c8\firmware.elf
Checking size .pio\build\bluepill_f103c8\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [ ] 4.1% (used 844 bytes from 20480 bytes)
Flash: [== ] 15.2% (used 9932 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 OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-00378-ge5be992df (2020-06-26-09:29)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
debug_level: 1

hla_swd
none separate

Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: open failed
in procedure ‘program’
** OpenOCD init failed **
shutdown command invoked

*** [upload] Error 1

Does not matter if NRST is connected, it is ending the same in both ways.
Firmware of my clone is updated. I can upload a project via Arduino IDE with no faults. So I believe there is must be something wrong with my configuration.

My conf - plaformio.ini

platform = ststm32
board = bluepill_f103c8
framework = arduino
upload_protocol = stlink

Any tips ?

Are you able to connect to the chip using the ST-Link Utility? This also installs the drivers if you haven’t before.

I’ve also seen two instances on this forum where stlink errors were due to having an outdated version of the driver installed, in which a uninstall and install of the latest version helped.

1 Like

Hi Max,
yes I am able to connect and program chip with ST-Link Utility. I downloaded official and lastest drivers from ST.com inluding the firmware for ST-link adapter.
I’ve seen other threads on this forum, but nothing from that helped me.
For me it is wondering that Arduino IDE have no issues with using ST-link with same driver versions that is not possible for PlatformIO to work with.

This is shown, when I use verbose upload - short version.:

debug_level: 2

hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate

Info : clock speed 1000 kHz
Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: open failed
in procedure ‘program’
** OpenOCD init failed **
shutdown command invoked

*** [upload] Error 1

Have you any other idea ?

The particular one I’m refering to is (SOLVED) Cannot Upload to STM32F103 "BluePill" using ST Link on Nucleo Board - #28 by Hop. The situation there is pretty similiar to works, Arduino IDE upload works, OpenOCD does not find the device.

Was there any old version installed before that that you uninstalled?

AFAIK it also uses a different program to flash the firmware, STM32CubeProgrammer CLI, as opposed to OpenOCD. But with the latest driver, both shouhld work.

@maxgerhardt I ordered a original ST-link V2, before I used a clone. So it works now !
Thank you for support.