Environment:
Host OS: macOS 11.6.1 Big Sur
PlatformIO Core: 5.2, Home: 3.3.4
Issue:
Unable to upload code to STM32 (blackpill_f411ce) over STLink-V2.
Uploads to STM32 over STLink-V2 work fine under
macOS 10.14.6 Mojave, PlatformIO Core 5.2.4 - Home 3.4.0
macOS 10.15.7 Catalina, PlatformIO Core 5.2.4 - Home 3.4.0
I’m not sure if the problem is related to PlatformIO Core/Home version being older on macOS 11.6.1. I’m unable to upgrade PlatformIO to the latest Core/Home version under macOS 11.6.1
I get the following message when attempting to upgrade.
$ pio upgrade
Please wait while upgrading PlatformIO ...
PlatformIO has been successfully upgraded to 5.2.0
Release notes: https://docs.platformio.org/en/latest/history.html
The libusb-1.0.0.dylib at ~/.platformio/packages/tool-openocd/libexec in macOS 11.6.1 matches the corresponding file in macOS 10.15.7/macOS 10.14.6.
I’d appreciate any feedback on possible cause and how I can fix the issue. Thank you.
Error messages:
> Executing task in folder xenon_arduino_w5500_webclient: platformio run --target upload <
Processing stm32 (platform: ststm32; board: blackpill_f411ce; framework: arduino)
----------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/blackpill_f411ce.html
PLATFORM: ST STM32 (15.1.0) > WeAct Studio BlackPill V2.0 (STM32F411CE)
HARDWARE: STM32F411CEU6 100MHz, 128KB RAM, 512KB Flash
DEBUG: Current (stlink) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
- framework-arduinoststm32 4.20100.211028 (2.1.0)
- framework-cmsis 2.50700.210515 (5.7.0)
- tool-dfuutil 1.9.200310
- tool-openocd 2.1100.211028 (11.0)
- tool-stm32duino 1.0.1
- toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Ethernet> 2.0.0
| |-- <SPI> 1.0
|-- <SPI> 1.0
Building in release mode
Checking size .pio/build/stm32/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 3.3% (used 4384 bytes from 131072 bytes)
Flash: [= ] 7.6% (used 39720 bytes from 524288 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, serial, stlink
CURRENT: upload_protocol = stlink
Uploading .pio/build/stm32/firmware.elf
dyld: Library not loaded: @loader_path/../libexec/libusb-1.0.0.dylib
Referenced from: /Users/quark11/.platformio/packages/tool-openocd/bin/openocd
Reason: Incompatible library version: openocd requires version 4.0.0 or later, but libusb-1.0.0.dylib provides version 3.0.0
*** [upload] Error -6
======================================= [FAILED] Took 2.98 seconds =======================================
Environment Status Duration
------------- -------- ------------
stm32 FAILED 00:00:02.980
================================= 1 failed, 0 succeeded in 00:00:02.980 =================================
The terminal process "platformio 'run', '--target', 'upload'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
CC @ivankravets is this a fault in the Mac version of tool-openocd that the wrong libusb dynamic library is packaged with it? Or is it a case of “wrong libusb version installed in OS”?
@ivankravets What versions of macOS are you running?
For me, STM32 uploads work fine on macOS 10.14.6 and macOS 10.15.7. The STM32 upload issue occurs only on macOS 11.6.1.
All other platform uploads (nRF52, ESP32, RP2040, AVR) work fine on macOS 11.6.1, macOS 10.14.6 and macOS 10.15.7.
For me, the issue is on macOS 11.6.1. The STM32 uploads work fine only Macs with macOS 10.14.6 & macOS 10.15.7.
I’m going to use locate (from terminal) to find all installs of libusb-1.0.0.dylib on the MBP running macOS 11.6.1, then check their hash & compare with the ones on macOS 10.14.6 & macOS 10.15.7. It’s possible the wrong version of libusb-1.0.0.dylib is being pickup up.
Which libusb-1.0.0.dylib does PlatformIO use when attempting a STM32 upload?
My PATH has /usr/local/bin first, so the brew version of libusb-1.0.0.dylib should get invoked.
There are several locations where libusb-1.0.0.dylib resides or is sym-linked.
/usr/local/lib/libusb-1.0.0.dylib. (symlinks to /usr/local/Cellar/libusb/1.0.24/lib/libusb-1.0.0.dylib)
/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/Drivers/FirmwareUpgrade/native/mac_x64/libusb-1.0.0.dylib
/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin/libusb-1.0.0.dylib
/opt/nordic/ncs/v1.7.0/toolchain
Both macOS versions of .platformio/packages/tool-openocd/libexec/libusb-1.0.0.dylib have version 4.0.0 compatibility, so pio openocd should load the libexec/libusb-1.0.0.dylib.
Does this mean that the PlatformIO version of openocd is not being invoked for STM32 / STLInkv2 upload?
Using Xcode, I’ve built executables for the MacDependency tool (A GUI version of otool utility, similar to Windows Dependency Walker, that shows all dependent libraries and frameworks of a given executable, dynamic library or framework on macOS. MacDependency tool was built separately using Xcode 12.4 on macOS 10.15.7 & Xcode 13.1 on macOS 11.6.1.
From the pio openocd results, it appears that on macOS 11.6.1, some of the dependencies are not being satisfied (MacDependency entries in red below are missing). I have no idea what application (STMProgrammerCube?) installs these missing items. I’m not sure on the their importance. It just could be a red herring!
I’m not sure what to try next. Perhaps a small fresh install of macOS 11.6.x, PlatformIO, and STM32CubeProgrammer on a separate external drive.
This problem exists only in PlatformIO / macOS 11.6.1 for STM32 / STLinkV2 uploads, as I am able to upload code to blackpill_f411ce in Arduino IDE1.8.16 using STLinkV2.
Max, @ivankravets - I performed a fresh install of macOS 10.16, PlatformIO, and STM32CubeProgrammer (SetupSTM32CubeProgrammer-2.9.0). I got the exact same error message as before when attempting uploads to a STM32 blackpill_f411ce board using STLinkV2.
I tried another test, this time installed PlatformIO and VScode but no STM32CubeProgrammer (SetupSTM32CubeProgrammer-2.9.0) in a fresh macOS 11.6 VM.
I can confirm that STM32 uploads to a blackpill_f411ce board using STLinkV2 were successful. It’s possible that the latest STM32CubeProgrammer installer conflicts somehow or it could be some other libusb conflict.
I’ll run some further tests on the macOS 11.6 VM to rule out possible conflict with the STM32CubeProgrammer installer, though I have my doubts. The libusb conflict may be elsewhere.
I’m not quite sure how I’ll fix the issue on my main macOS 11.6 system.
There must be something wrong with the LDPATH or the order thereof. I’m not good enough on Mac to know what the loading order and priorities are though – or if STM32CubeProgrammer somehow intereferes with it. I had another person check it with no STM32CubeProgrammer installed and there were no problems. (https://github.com/CommunityGD32Cores/ArduinoCore-GD32/issues/55#issuecomment-996730655)
I’ll try to rule out STM32CubeProgrammer (v2.9) in some further testing over the weekend, though I have it installed on macOS 10.4.6 & macOS 10.15.7 where I don’t have any STM32 upload issues. The STM32CubeProgrammer is needed by Arduino IDE for STLink uploads.
@ivankravets Would you or one of your Dev colleagues know what may be incorrect with the LDPATH?