Nucleo-WL55JC2 - Not able to upload via USB on a Mac

I am on a Mac and trying to get the Nucleo WL55JC2 dev board up and running but have been unable to upload to it via USB, getting the error:

OpenOCD init failed

My platform.ini file is as follows:

[env:nucleo_wl55jc]
platform = ststm32
board = nucleo_wl55jc
framework = arduino
debug_tool = stlink
upload_protocol = stlink

I’ve tried other upload_protocols with no success:
mbed, cmsis_dap, jlink

USB Enumerating Successfully:
I can check via the Mac, General->About->System Report->More Info and can verify the board is showing up there as “STLINK-V3”

Confirmed communications via USB:
I installed STM32CubeProgrammer to see if I could connect to the dev board. If I selected any of the options STLink, UART, USB, etc and click “Connect”…it is never successful. However, if select STLink, it will show the firmware version of the board, suggesting there is some communication happening. Also, there’s a ‘Firmware Upgrade’ button that when clicked can be followed up by clicking the ‘Open in update mode’. I am then able to update the board’s firmware successfully. So communication via USB cable is possible.

It seems that others experiencing similar issues years ago were on Windows.

What would you suggest I try next?

I worked with the Nucleo WL55JC some time ago and found the PlatformIO-supplied official OpenOCD to not have good support for STM32WL chips. There is a STM32 modified OpenOCD version that fares better. Still, there are a few possibilities here:

  1. OpenOCD is not using the right reset method (software/hardware) with respect to the board or the firmware that’s running on the board right now. If the currently loaded firmware goes into deepsleep, it shuts off the debugging and flashing capabilities via SWD. You can bypass that if you hold down the reset button on the Nucleo board, start the upload, and release it at the right time when the OpenOCD text shows up.
  2. OpenOCD itself is too outdatd / buggy. You can download https://github.com/xpack-dev-tools/openocd-xpack/releases and try to use the same upload command (Project tasks → Advanced → Verbose Upload) but with that newer openocd version.

If OpenOCD is too old, perhaps st-link (brew install stlink) will work? I use this:

upload_protocol = custom
upload_command = st-flash --connect-under-reset $UPLOAD_FLAGS write $SOURCE 0x08000000

The “connect under reset” option gets uploads working even when the µC is in deep sleep or has disabled the SWD pins.

@maxgerhardt & @jcw Thank you for your suggestions.

Ultimately, this is an issue with the dev board’s USB 2.0 not working with the USB chip on the Macbook Air M2 (other macs have this problem too). Using a USB 3.0 hub solved the problem:

Nucleo Dev Board → USB 3.0 Hub → Macbook Air M2

See my ST Community post:

Prior to discovering the solution, I did update the OpenOCD to the latest release. As a newbie, it took me some time, with the help of Copilot, to get Platform IO to use the latest release I installed. Addtionally, as @jcw suggested, I installed stlink, after installing Homebrew.

In the end…here is what my platformio.ini looks like:

[env:nucleo_wl55jc]
platform = ststm32
board = nucleo_wl55jc
framework = arduino
debug_tool = stlink
upload_protocol = stlink
upload_command = /Users/vikingvoltage/Documents/PlatformIO/tools/xpack-openocd-0.12.0-6/bin/openocd -f interface/stlink.cfg -f target/stm32wlx.cfg -c "adapter speed 200" -c "program .pio/build/nucleo_wl55jc/firmware.elf verify reset exit"
openocd-0.12.0-6/bin/openocd
upload_port = dev/cu.usbmodem1103
monitor_port = /dev/cu.usbmodem1103
monitor_speed = 115200

lib_deps = 
	stm32duino/STM32duino Low Power@^1.4.0
	jgromes/RadioLib@^7.1.2

Just to be informative for others, this is what the output looks like when uploading a program:

Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   3.2% (used 2100 bytes from 65536 bytes)
Flash: [==        ]  19.0% (used 49816 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
Uploading .pio/build/nucleo_wl55jc/firmware.elf
xPack Open On-Chip Debugger 0.12.0+dev-01850-geb6f2745b-dirty (2025-02-07-12:10)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "dapdirect_swd". To override use 'transport select <transport>'.
none separate
Info : STLINK V3J15M7 (API v3) VID:PID 0483:374E
Info : Target voltage: 3.247619
Info : Unable to match requested speed 500 kHz, using 200 kHz
Info : Unable to match requested speed 500 kHz, using 200 kHz
Info : clock speed 200 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x6ba02477
Info : [stm32wlx.cpu0] Cortex-M4 r0p1 processor detected
Info : [stm32wlx.cpu0] target has 6 breakpoints, 4 watchpoints
Info : [stm32wlx.cpu0] Examination succeed
Info : [stm32wlx.cpu0] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections
Info : Unable to match requested speed 500 kHz, using 200 kHz
Info : Unable to match requested speed 500 kHz, using 200 kHz
[stm32wlx.cpu0] halted due to breakpoint, current mode: Thread 
xPSR: 0x01000000 pc: 0x0800a22c msp: 0x20010000
** Programming Started **
Info : device idcode = 0x10036497 (STM32WLE/WL5x - Rev 'unknown' : 0x1003)
Info : RDP level 0 (0xAA)
Info : flash size = 256 KiB
Info : flash mode : single-bank
Info : Padding image section 1 at 0x0800c414 with 4 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x0800c418 .. 0x0800c7ff
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
Info : Unable to match requested speed 500 kHz, using 200 kHz
Info : Unable to match requested speed 500 kHz, using 200 kHz
shutdown command invoked
--- Terminal on /dev/cu.usbmodem1103 | 115200 8-N-1

The "Info: Unable to match requested speed… " can be ignored. It is not an issue. I tried using -c ‘adapter speed 200’ in the .ini to set the speed to suppress these messages:

upload_command = /Users/vikingvoltage/Documents/PlatformIO/tools/xpack-openocd-0.12.0-6/bin/openocd -f interface/stlink.cfg -f target/stm32wlx.cfg -c "adapter speed 200" -c "program .pio/build/nucleo_wl55jc/firmware.elf verify reset exit" -c "adapter speed 200"

…but that will only suppress the first set of “Info: Unable to match requested speed…” My understanding, and experience so far, is that it is a non-issue.