Problem
When attempting to flash a nRF board that uses pyocd as the runner (defined in devices’s baord.cmake) for flashing, the following error occurs.
It doesn’t matter if the external probe is a nrf5xx-dk or a Segger probe.
“pyocd” sees the debug probe correctly.


However, the board can be flashed directly from a nRF Connect session using “west flash -r pyocd”.
The following shows flashing of sample “Blinky” for board “particle_xenon”.

There is a workaround but it requires a change to the board’s “board.cmake”. We shouldn’t have to change a board’s board.cmake in the Zephyr repo.
This issue exists in NCS 3.4.x and 3.x.x and appears to be a bug in “runners.pyocd”.
Also, tried upgrading “pyocd” to the latest version 0.45.1, as NCS 3.4.1 ships with version 0.42. This change didn’t make any difference.
Workaround
The issue has a workaround by changing the order of the runners in board.cmake.
For example, by making one of the other runners in “boards/particle/xenon/board.cmake” the default (first runner in the list)
board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000")
board_runner_args(nrfjprog "--softreset")
board_runner_args(jlink "--device=nRF52840_xxAA" "--speed=4000")
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake)
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
Afterwards, selecting “Flash” from nRF Connect works as per normal.