PlatformIO で STM32 開発をしていて、特定の DAP-Link を使用すると、以下のようなエラー表示された。
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, serial, stlink
CURRENT: upload_protocol = cmsis-dap
Uploading .pio/build/genericSTM32F103C8/firmware.elf
xPack OpenOCD aarch64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:18)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
swd
Warn : Using CMSIS-DAPv2 interface 1 with wrong class 10 subclass 0 or protocol 0
Warn : could not claim interface: Resource busy
Error: error reading data: Input/Output Error
...
Error: error reading data: Input/Output Error
Error: CMSIS-DAP command CMD_INFO failed.
Error: No Valid JTAG Interface Configured.
*** [upload] Error 255
ある DAP-Link デバイスだと成功したり、PyOCDだとできたにもかかわらずである。
どうも PlatformIO の指している OpenOCD のバージョンが古いようである。以下のように OpenOCD のバージョンに 3.12 を指定すると動作しました。
[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = stm32cube
platform_packages =
toolchain-gccarmnoneeabi@~1.100301.220327
tool-openocd@~3.1200.0
upload_protocol = cmsis-dap
monitor_port = /dev/ttyACM0
monitor_speed = 115200
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, serial, stlink
CURRENT: upload_protocol = cmsis-dap
Uploading .pio/build/genericSTM32F103C8/firmware.elf
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:08)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
swd
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800211c msp: 0x20005000
** Programming Started **
Warn : Adding extra erase range, 0x08002324 .. 0x080023ff
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked
PlatformIO の標準で指し示すバージョンがいろいろ古いのは一体何なんでしょう。。。
参考
Unable to download program through cmsis-dap debugger - General Discussion - PlatformIO Community
https://community.platformio.org/t/unable-to-download-program-through-cmsis-dap-debugger/21826
platformio/tool-openocd: Open On-Chip Debugger. Free and Open On…
https://registry.platformio.org/tools/platformio/tool-openocd/versions