diff --git a/boards/raspberrypi/rpi_pico2/board.cmake b/boards/raspberrypi/rpi_pico2/board.cmake index c57bc2b04d87bcc..686fbd9d40e354e 100644 --- a/boards/raspberrypi/rpi_pico2/board.cmake +++ b/boards/raspberrypi/rpi_pico2/board.cmake @@ -1,5 +1,18 @@ # SPDX-License-Identifier: Apache-2.0 +if ("${RPI_PICO_DEBUG_ADAPTER}" STREQUAL "") + set(RPI_PICO_DEBUG_ADAPTER "cmsis-dap") +endif() + +board_runner_args(openocd --cmd-pre-init "source [find interface/${RPI_PICO_DEBUG_ADAPTER}.cfg]") +board_runner_args(openocd --cmd-pre-init "source [find target/rp2350.cfg]") + +# The adapter speed is expected to be set by interface configuration. +# The Raspberry Pi's OpenOCD fork doesn't, so match their documentation at +# https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html#debugging-with-swd +board_runner_args(openocd --cmd-pre-init "set_adapter_speed_if_not_set 5000") + board_runner_args(uf2 "--board-id=RP2350") -include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake) \ No newline at end of file +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake) diff --git a/boards/raspberrypi/rpi_pico2/rpi_pico2_defconfig b/boards/raspberrypi/rpi_pico2/rpi_pico2_defconfig index 16d269697d035b5..d47066f1a8a1af5 100644 --- a/boards/raspberrypi/rpi_pico2/rpi_pico2_defconfig +++ b/boards/raspberrypi/rpi_pico2/rpi_pico2_defconfig @@ -1,3 +1,4 @@ +CONFIG_BUILD_OUTPUT_HEX=y CONFIG_BUILD_OUTPUT_UF2=y CONFIG_CLOCK_CONTROL=y CONFIG_CONSOLE=y diff --git a/boards/raspberrypi/rpi_pico2/support/openocd.cfg b/boards/raspberrypi/rpi_pico2/support/openocd.cfg new file mode 100644 index 000000000000000..82666bb53314ce7 --- /dev/null +++ b/boards/raspberrypi/rpi_pico2/support/openocd.cfg @@ -0,0 +1,11 @@ +# Copyright (c) 2024 TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +# Checking and set 'adapter speed'. +# Set the adaptor speed, if unset, and given as an argument. +proc set_adapter_speed_if_not_set { speed } { + puts "checking adapter speed..." + if { [catch {adapter speed} ret] } { + adapter speed $speed + } +}