Wie man PlatformIO-Fehler behebt: libusb_open() failed with LIBUSB_ERROR_ACCESS
Problem
Wenn Sie versuchen, Ihre Firmware mit PlatformIO zu flashen, sehen Sie eine Fehlermeldung wie
platformio_libusb_error.txt
Building in release mode
Checking size .pio/build/nucleo_h743zi/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 7.4% (used 38876 bytes from 524288 bytes)
Flash: [ ] 3.2% (used 67004 bytes from 2097152 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
Uploading .pio/build/nucleo_h743zi/firmware.elf
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:03)
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: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: open failed
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked
*** [upload] Error 1
======================================================================= [FAILED] Took 1.45 seconds =======================================================================Lösung
Ihr aktueller Systembenutzer hat keinen Zugriff auf USB-Geräte. Um dies zu beheben, verwenden Sie
add_user_to_plugdev.sh
sudo usermod -a -g plugdev $USERBeachten Sie, dass die Änderung erst wirksam wird, nachdem Sie sich ab- und wieder angemeldet haben, oder nach einem Neustart.
Zusätzlich müssen Sie die aktuellen PlatformIO-udev-Regeln installieren:
install_platformio_udev_rules.sh
curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rulesund starten Sie dann udev neu:
restart_udev.sh
sudo systemctl restart udevDanach ziehen Sie das USB-Kabel zum Mikrocontroller ab und schließen Sie es wieder an, oder starten Sie Ihr System neu.
Nachdem Sie all das getan haben, sollte Ihr Upload funktionieren:
platformio_upload_success.txt
Checking size .pio/build/nucleo_h743zi/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 7.4% (used 38876 bytes from 524288 bytes)
Flash: [ ] 3.2% (used 67004 bytes from 2097152 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
Uploading .pio/build/nucleo_h743zi/firmware.elf
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:03)
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
[stm32h7x.cpu0] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800a0d0 msp: 0x24080000
** Programming Started **
Warn : Adding extra erase range, 0x08010880 .. 0x0801ffff
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked
=========================Check out similar posts by category:
PlatformIO
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow