Can't flash, getting openocd error: Can't find target/stm32w55xx.cfg

I’m getting this error so I searched and found a similar problem here:

Unfortunately the solution of deleting openOCD from the packages doesn’t work. I delete it and it redownloads the packages, but the problem remains. Does anybody have a different solution?

Here is the error message.

Linking .pio\build\nucleo_wb55rg_p\firmware.elf
Checking size .pio\build\nucleo_wb55rg_p\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 836 bytes from 196608 bytes)
Flash: [          ]   3.1% (used 16240 bytes from 524288 bytes)        
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, jlink, stlink
CURRENT: upload_protocol = stlink
Uploading .pio\build\nucleo_wb55rg_p\firmware.elf
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:19)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

hla_swd
embedded:startup.tcl:26: Error: Can't find target/stm32w55xx.cfg       
in procedure 'script'
at file "embedded:startup.tcl", line 26

Seems like a bug in platform-ststm32. The board file dictates

but looking in my C:\Users\<user>\.platformio\packages\tool-openocd\scripts\target folder I just get

grafik

So no stm32w55xx.cfg file. But since the chip is named wb55rg I think they meant to use stm32wbx.cfg.

Please add

board_debug.openocd_target = stm32wbx

in the platformio.ini and try debugging again. Does it change anything?

in the board script there is this:

#
# Configuration for STM32WB55 Nucleo board (STM32WB55RGV6)
#

source [find interface/stlink.cfg]

transport select hla_swd

source [find target/stm32wbx.cfg]

reset_config srst_only

adding this line

board_debug.openocd_target = stm32wbx

Has no effect. It is still looking for the other device. It can be seen in as one of the target flags in the verbose output.

CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_wb55rg_p.html
PLATFORM: ST STM32 (15.4.0) > P-Nucleo WB55RG
HARDWARE: STM32WB55RG 64MHz, 192KB RAM, 512KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES: 
 - framework-arduinoststm32 @ 4.20200.220530 (2.2.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.2 
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 11 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".pio\build\nucleo_wb55rg_p\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 836 bytes from 196608 bytes)
Flash: [          ]   3.1% (used 16240 bytes from 524288 bytes)
.pio\build\nucleo_wb55rg_p\firmware.elf  :

section              size        addr

.isr_vector           316   134217728

.text               14632   134218044

.rodata              1496   134232676

.ARM                    8   134234172

.init_array            16   134234180

.fini_array             8   134234196

.data                 112   536870916

.bss                  724   536871028

.noinit                 0   536871752

._user_heap_stack    1536   536871752

.ARM.attributes        48           0

.comment              102           0

.debug_frame          940           0

Total               19938
<lambda>(["upload"], [".pio\build\nucleo_wb55rg_p\firmware.elf"])
AVAILABLE: blackmagic, cmsis-dap, jlink, stlink
CURRENT: upload_protocol = stlink
openocd -d2 -s C:\Users\Tiago\.platformio\packages\tool-openocd/scripts -f interface/stlink.cfg -c "transport select hla_swd" -f target/stm32w55xx.cfg -c "program {.pio\build\nucleo_wb55rg_p\firmware.elf}  verify reset; shutdown;"
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:19)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

hla_swd
embedded:startup.tcl:26: Error: Can't find target/stm32w55xx.cfg       
in procedure 'script'
at file "embedded:startup.tcl", line 26
*** [upload] Error 1

Ohh, I see, there is a tool-openocd\scripts\board\st_nucleo_wb55.cfg. Now that looks like a much better candidate.

Please overwrite the content of C:\Users\<user>\.platformio\platforms\ststm32\boards\nucleo_wb55rg_p.json with

{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m4",
    "extra_flags": "-DSTM32WB55xx",
    "f_cpu": "64000000L",
    "mcu": "stm32wb55rg",
    "product_line": "STM32WB55xx",
    "variant": "STM32WBxx/WB55R(C-E-G)V"
  },
  "connectivity": [
    "bluetooth"
  ],
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "openocd_board": "st_nucleo_wb55",
    "jlink_device": "STM32WB55xx",
    "onboard_tools": [
      "stlink"
    ]
  },
  "frameworks": [
    "arduino"
  ],
  "name": "P-Nucleo WB55RG",
  "upload": {
    "maximum_ram_size": 196608,
    "maximum_size": 524288,
    "protocol": "stlink",
    "protocols": [
      "jlink",
      "cmsis-dap",
      "stlink",
      "blackmagic"
    ]
  },
  "url": "https://www.st.com/en/evaluation-tools/p-nucleo-wb55.html",
  "vendor": "ST"
}

And remove the previous platformio.ini modificaiton. Does it work now?

1 Like

That line has to be this:

"openocd_board": "st_nucleo_wb55",

and it works!

Thanks for your help

Ah I confused board name with the actual .cfg file, corrected now, thanks. Will PR.

Will be fixed by Fix OpenOCD config for nucleo_wb55rg_p by maxgerhardt · Pull Request #631 · platformio/platform-ststm32 · GitHub.