[STLINK-V3PWR] Debug adapter doesn't support 'hla_swd' transport

Hi,

So i move few days ago on platformio, and i try to upload my program to a STM32L031K6, custom board with a STLINK-V3PWR.
First i update openocd to the last openocd (dirty way, copying all file inside the tool-openocd, i find no way to use “pio pkg install”). Now i can connect to the STM32L0x :

openocd.exe -f interface\stlink.cfg -f target\stm32l0.cfg
xPack Open On-Chip Debugger 0.12.0+dev-01850-geb6f2745b-dirty (2025-02-07-10:08)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
Info : auto-selecting first available session transport “dapdirect_swd”. To override use ‘transport select ’.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V4J5B1S0 (API v3) VID:PID 0483:3757
Info : Target voltage: 3.293187
Info : Unable to match requested speed 300 kHz, using 200 kHz
Info : Unable to match requested speed 300 kHz, using 200 kHz
Info : clock speed 200 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x0bc11477
Info : [stm32l0.cpu] Cortex-M0+ r0p1 processor detected
Info : [stm32l0.cpu] target has 4 breakpoints, 2 watchpoints
Info : [stm32l0.cpu] Examination succeed
Info : [stm32l0.cpu] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections

But i still can’t upload under platformio :

Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [= ] 14.2% (used 1164 bytes from 8192 bytes)
Flash: [==== ] 42.0% (used 13748 bytes from 32768 bytes)
Configuring upload protocol…
AVAILABLE: blackmagic, cmsis-dap, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
Uploading .pio\build\nucleo_l031k6\firmware.elf
xPack Open On-Chip Debugger 0.12.0+dev-01850-geb6f2745b-dirty (2025-02-07-10:08)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
debug_level: 1
Debug adapter doesn’t support ‘hla_swd’ transport
*** [upload] Error 1

So, i tried to change the debug_server under platformio.ini :

; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
[env:nucleo_l031k6]
platform = ststm32
board = nucleo_l031k6
framework = arduino
check_skip_packages = yes

upload_protocol = stlink
debug_tool = custom
debug_server =
${platformio.packages_dir}/tool-openocd/bin/openocd
-s ${platformio.packages_dir}/tool-openocd/scripts
-f interface\stlink.cfg
-c “transport select dapdirect_swd”
-f target\stm32l0x.cfg
-c “reset_config none”

But it change nothing, i still get an error. I don’t understand where the “hla_swd” parameter is set, i try to search all the find and change the .platformio\packages\framework-arduinoststm32\debugger\select_hla.cfg to blank but sill get the error.

Any idea about that ?

Thanks in advance,

with -v option :

AVAILABLE: blackmagic, cmsis-dap, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
openocd -d2 -s C:\Users\Froggy.platformio\packages\tool-openocd/openocd/scripts -f interface/stlink.cfg -c “transport select hla_swd” -f target/stm32l0.cfg -c “program {.pio\build\nucleo_l031k6\firmware.elf} verify reset; shutdown;”
xPack Open On-Chip Debugger 0.12.0+dev-01850-geb6f2745b-dirty (2025-02-07-10:08)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
debug_level: 2
Debug adapter doesn’t support ‘hla_swd’ transport
*** [upload] Error 1

File a bug report in https://github.com/platformio/platform-ststm32/issues if uploading to a STM32L0 is not working by default for your new STLink.

The hla_swd is added in

So you may just comment out lines 199 and 200 in your local C:\Users\Froggy\.platformio\platforms\ststm32\platform.py file to test that out.

Thanks for your help,

I finally find a way to, and it can help me for specific PWR from STLINK-V3PWR :

I add :

extra_scripts = upload_target.py

upload_protocol = custom

To plaformio.ini

and create upload_target.py at the root of the project :

Import(‘env’)
environ = env[‘ENV’]
env.Replace(UPLOADCMD=‘openocd -d2 -s C:\Users\Froggy\.platformio\packages\tool-openocd\openocd\scripts -f interface\stlink.cfg -f target\stm32l0.cfg -c “program {.pio/build/nucleo_l031k6/firmware.elf} verify reset; shutdown;”’)

So i get :

AVAILABLE: blackmagic, cmsis-dap, custom, jlink, mbed, stlink
CURRENT: upload_protocol = custom
openocd -d2 -s C:\Users\Froggy.platformio\packages\tool-openocd\openocd\scripts -f interface\stlink.cfg -f target\stm32l0.cfg -c “program {.pio/build/nucleo_l031k6/firmware.elf} verify reset; shutdown;”
xPack Open On-Chip Debugger 0.12.0+dev-01850-geb6f2745b-dirty (2025-02-07-10:08)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
debug_level: 2
Info : auto-selecting first available session transport “dapdirect_swd”. To override use ‘transport select ’.
Info : STLINK V4J5B1S0 (API v3) VID:PID 0483:3757
Info : Target voltage: 3.293187
Info : Unable to match requested speed 300 kHz, using 200 kHz
Info : Unable to match requested speed 300 kHz, using 200 kHz
Info : clock speed 200 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x0bc11477
Info : [stm32l0.cpu] Cortex-M0+ r0p1 processor detected
Info : [stm32l0.cpu] target has 4 breakpoints, 2 watchpoints
Info : [stm32l0.cpu] Examination succeed
Info : [stm32l0.cpu] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections
Info : Unable to match requested speed 300 kHz, using 200 kHz
Info : Unable to match requested speed 300 kHz, using 200 kHz
[stm32l0.cpu] halted due to breakpoint, current mode: Thread
xPSR: 0xf1000000 pc: 0x1ff00220 msp: 0x20000ca0
STM32L0: Enabling HSI16
** Programming Started **
Info : Device: STM32L0xx (Cat. 2)
Info : STM32L flash size is 32kb, base address is 0x8000000
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
Info : Unable to match requested speed 300 kHz, using 200 kHz
Info : Unable to match requested speed 300 kHz, using 200 kHz
shutdown command invoked

I actually don’t try the program because it don’t do anything visible without an oscilloscope, but if it upload, it should work :smiley:

Now, need to add some power_on in the script, because the STLINK-V3PWR don’t poweron on startup by itself. And using the stm32cubemonitor is little bit borring. There is some command thrue COM5 to send.

Debug seems to work too, so here is the full plaformio.ini :

; PlatformIO Project Configuration File

;

; Build options: build flags, source filter

; Upload options: custom upload port, speed and extra flags

; Library options: dependencies, extra library storages

; Advanced options: extra scripting

;

; Please visit documentation for the other options and examples

; Redirecting...

[env:nucleo_l031k6]

platform = ststm32

board = nucleo_l031k6

framework = arduino

check_skip_packages = yes

;upload_protocol = stlink

extra_scripts = upload_target.py

upload_protocol = custom

debug_tool = custom

debug_server =

c:\Users\Froggy.platformio\packages\tool-openocd\bin\openocd.exe

-s c:\Users\Froggy.platformio\packages\tool-openocd\scripts

-f \interface\stlink.cfg

-c “transport select dapdirect_swd”

-f \target\stm32l0.cfg

-c “reset_config none”

And the final upload_target.py with autopower on : Import(‘env’)

import serial

import time

environ = env[‘ENV’]

stlink_v3pwr = serial.Serial(port=‘COM5’, baudrate=19200)

stlink_v3pwr.write(b’pwr on\r’)

stlink_v3pwr.close()

time.sleep(1)

env.Replace(UPLOADCMD=‘openocd -d2 -s C:\Users\Froggy\.platformio\packages\tool-openocd\openocd\scripts -f interface\stlink.cfg -f target\stm32l0.cfg -c “program {.pio/build/nucleo_l031k6/firmware.elf} verify reset; shutdown;”’)