From 2b6eda4b7163ffd8bda48dd18b473eb66700b6a9 Mon Sep 17 00:00:00 2001 From: Carl Hamilton Date: Fri, 15 May 2026 14:43:30 -0700 Subject: [PATCH 1/5] Flesh out board configuration include guards Added "_CONFIG" to the include guards for the board configuration headers. This will help avoid collisions and confusion with other, similarly named headers. --- include/board_debug_probe_config.h | 4 ++-- include/board_example_config.h | 4 ++-- include/board_pico_config.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/board_debug_probe_config.h b/include/board_debug_probe_config.h index 3e7fc353c..244b500fb 100644 --- a/include/board_debug_probe_config.h +++ b/include/board_debug_probe_config.h @@ -23,8 +23,8 @@ * */ -#ifndef BOARD_DEBUG_PROBE_H_ -#define BOARD_DEBUG_PROBE_H_ +#ifndef BOARD_DEBUG_PROBE_CONFIG_H_ +#define BOARD_DEBUG_PROBE_CONFIG_H_ #define PROBE_IO_SWDI #define PROBE_CDC_UART diff --git a/include/board_example_config.h b/include/board_example_config.h index 0e0f13130..2c731d8b1 100644 --- a/include/board_example_config.h +++ b/include/board_example_config.h @@ -23,8 +23,8 @@ * */ -#ifndef BOARD_EXAMPLE_H_ -#define BOARD_EXAMPLE_H_ +#ifndef BOARD_EXAMPLE_CONFIG_H_ +#define BOARD_EXAMPLE_CONFIG_H_ #error "Example board configuration requested - specify PICO_BOARD and re-run CMake." /* Select one of these. */ diff --git a/include/board_pico_config.h b/include/board_pico_config.h index dd22f0a74..f732fb707 100644 --- a/include/board_pico_config.h +++ b/include/board_pico_config.h @@ -23,8 +23,8 @@ * */ -#ifndef BOARD_PICO_H_ -#define BOARD_PICO_H_ +#ifndef BOARD_PICO_CONFIG_H_ +#define BOARD_PICO_CONFIG_H_ #define PROBE_IO_RAW #define PROBE_CDC_UART From 201c28d7fb2d2c3ede492e2a78ff9e273a6d74dc Mon Sep 17 00:00:00 2001 From: Carl Hamilton Date: Fri, 15 May 2026 16:07:18 -0700 Subject: [PATCH 2/5] Move board configuration logic to dedicated header The small amount of logic to select and configure the target board has moved to a new, dedicated header: board_config.h. This will allow future changes to board selection and configuration to be more easily isolated and prevent probe_config.h from being polluted by board-related shenanigans. --- include/board_config.h | 38 ++++++++++++++++++++++++++++++++++++++ src/probe_config.h | 9 +-------- 2 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 include/board_config.h diff --git a/include/board_config.h b/include/board_config.h new file mode 100644 index 000000000..825552146 --- /dev/null +++ b/include/board_config.h @@ -0,0 +1,38 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#ifndef BOARD_CONFIG_H_ +#define BOARD_CONFIG_H_ + +// TODO tie this up with PICO_BOARD defines in the main SDK + +#ifdef DEBUG_ON_PICO +#include "board_pico_config.h" +#else +#include "board_debug_probe_config.h" +#endif +//#include "board_example_config.h" + +#endif diff --git a/src/probe_config.h b/src/probe_config.h index 5c5e14909..ff12f0413 100644 --- a/src/probe_config.h +++ b/src/probe_config.h @@ -63,14 +63,7 @@ do { \ #define probe_dump(format,...) ((void)0) #endif -// TODO tie this up with PICO_BOARD defines in the main SDK - -#ifdef DEBUG_ON_PICO -#include "board_pico_config.h" -#else -#include "board_debug_probe_config.h" -#endif -//#include "board_example_config.h" +#include "board_config.h" // Add the configuration to binary information void bi_decl_config(); From 07e2eaa2f8be0c0c720e22dbca298507a094b9d0 Mon Sep 17 00:00:00 2001 From: Carl Hamilton Date: Fri, 15 May 2026 16:52:06 -0700 Subject: [PATCH 3/5] Use the Pico SDK's board configuration framework This simplifies building the Debug Probe firmware for any board supported by the Pico SDK's board idenfication and configuration framework. If no PICO_BOARD value is provided on the cmake command line, firmware will be built for the `debug_probe` board defined in the SDK. --- CMakeLists.txt | 22 ++++++---------------- README.md | 6 +++--- include/board_config.h | 11 ++++++----- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92ea05a53..744a5d5e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.12) +# build for the Raspberry Pi Debug Probe by default +set(PICO_BOARD debug_probe CACHE STRING "Board type") + set(CMAKE_BUILD_TYPE RelWithDebInfo) include(pico_sdk_import.cmake) @@ -65,25 +68,12 @@ target_compile_definitions (debugprobe PRIVATE PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1 ) -option (DEBUG_ON_PICO "Compile firmware for the Pico instead of Debug Probe" OFF) -if (DEBUG_ON_PICO) - target_compile_definitions (debugprobe PRIVATE - DEBUG_ON_PICO=1 +if (NOT PICO_BOARD STREQUAL "debug_probe") + set_target_properties(debugprobe PROPERTIES + OUTPUT_NAME "debugprobe_on_${PICO_BOARD}" ) - if (PICO_BOARD STREQUAL "pico") - set_target_properties(debugprobe PROPERTIES - OUTPUT_NAME "debugprobe_on_pico" - ) - elseif (PICO_BOARD STREQUAL "pico2") - set_target_properties(debugprobe PROPERTIES - OUTPUT_NAME "debugprobe_on_pico2" - ) - else () - message(SEND_ERROR "Unsupported board ${PICO_BOARD}") - endif () endif () - target_link_libraries(debugprobe PRIVATE pico_multicore pico_stdlib diff --git a/README.md b/README.md index 7f3add41d..89526ba61 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,9 @@ Done! You should now have a `debugprobe.uf2` that you can upload to your Debug P ## Building for the Pico 1 -If you want to create the version that runs on the Pico, then you need to invoke `cmake` in the sequence above with the `DEBUG_ON_PICO=ON` option: +If you want to create the version that runs on the Pico, then you need to invoke `cmake` in the sequence above with the `-DPICO_BOARD=pico` option: ``` -cmake -DDEBUG_ON_PICO=ON .. +cmake -DPICO_BOARD=pico .. ``` This will build with the configuration for the Pico and call the output program `debugprobe_on_pico.uf2`, as opposed to `debugprobe.uf2` for the accessory hardware. @@ -61,7 +61,7 @@ git submodule sync git submodule update --init --recursive mkdir build-pico2 cd build-pico2 -cmake -DDEBUG_ON_PICO=1 -DPICO_BOARD=pico2 ../ +cmake -DPICO_BOARD=pico2 ../ ``` This will build with the configuration for the Pico 2 and call the output program `debugprobe_on_pico2.uf2`. diff --git a/include/board_config.h b/include/board_config.h index 825552146..d34e854ea 100644 --- a/include/board_config.h +++ b/include/board_config.h @@ -26,13 +26,14 @@ #ifndef BOARD_CONFIG_H_ #define BOARD_CONFIG_H_ -// TODO tie this up with PICO_BOARD defines in the main SDK - -#ifdef DEBUG_ON_PICO +#include "pico/stdlib.h" +#if defined(RASPBERRYPI_DEBUG_PROBE) +#include "board_debug_probe_config.h" +#elif defined(RASPBERRYPI_PICO) || defined(RASPBERRYPI_PICO2) #include "board_pico_config.h" #else -#include "board_debug_probe_config.h" -#endif +#error Unsupported board //#include "board_example_config.h" +#endif #endif From 0f4d59ce9262dd064c5aa3a1e8d5ed33184e9df9 Mon Sep 17 00:00:00 2001 From: Carl Hamilton Date: Wed, 1 Jul 2026 15:38:49 -0700 Subject: [PATCH 4/5] Use LED definitions from debug probe board config. --- include/board_debug_probe_config.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/board_debug_probe_config.h b/include/board_debug_probe_config.h index 244b500fb..180f3da29 100644 --- a/include/board_debug_probe_config.h +++ b/include/board_debug_probe_config.h @@ -44,11 +44,11 @@ #define PROBE_UART_INTERFACE uart1 #define PROBE_UART_BAUDRATE 115200 -#define PROBE_USB_CONNECTED_LED 2 -#define PROBE_DAP_CONNECTED_LED 15 -#define PROBE_DAP_RUNNING_LED 16 -#define PROBE_UART_RX_LED 7 -#define PROBE_UART_TX_LED 8 +#define PROBE_USB_CONNECTED_LED DEBUG_PROBE_USB_CONNECTED_LED_PIN +#define PROBE_DAP_CONNECTED_LED DEBUG_PROBE_DAP_CONNECTED_LED_PIN +#define PROBE_DAP_RUNNING_LED DEBUG_PROBE_DAP_RUNNING_LED_PIN +#define PROBE_UART_RX_LED DEBUG_PROBE_UART_RX_LED_PIN +#define PROBE_UART_TX_LED DEBUG_PROBE_UART_TX_LED_PIN #define PROBE_PRODUCT_STRING "Debug Probe (CMSIS-DAP)" From b509da3cc2db8b4839ee151cb95592a41ef9d334 Mon Sep 17 00:00:00 2001 From: Carl Hamilton Date: Thu, 10 Sep 2026 17:40:02 -0700 Subject: [PATCH 5/5] Require Pico SDK version 2.3.0 or greater. Building for the Debug Probe now requires the debug_probe board definition from the Pico SDK, which was introduced in SDK version 2.3.0. Unfortunately, performing this version test requires some gyrations in pico_sdk_import.cmake to test the SDK's version before including the standard SDK init file. Changing pico_sdk_import.cmake is generally discouraged, but I couldn't find a better way to produce a helpful error when building against an outdated SDK. --- CMakeLists.txt | 4 ---- pico_sdk_import.cmake | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 744a5d5e1..b36d2e79f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,6 @@ project(debugprobe) pico_sdk_init() -if (${PICO_SDK_VERSION_MAJOR} LESS 2) - message(SEND_ERROR "Version 2 of the Pico SDK is required to compile this project. Please update your installation at ${PICO_SDK_PATH}") -endif () - add_executable(debugprobe src/probe_config.c src/main.c diff --git a/pico_sdk_import.cmake b/pico_sdk_import.cmake index d4773f8fe..e89be1e5c 100644 --- a/pico_sdk_import.cmake +++ b/pico_sdk_import.cmake @@ -71,4 +71,18 @@ endif () set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) +# We need to include the Pico SDK version file and test the SDK's +# version *before* including the standard SDK init file. If the SDK is +# old and PICO_BOARD is set to "debug_probe" (the default), including +# the standard init file fails because it can't find a board definition +# for "debug_probe" (which doesn't exist prior to SDK version 2.3.0). +if (NOT EXISTS ${PICO_SDK_PATH}/pico_sdk_version.cmake) + message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not contain a Raspberry Pi Pico SDK version file") +endif () + +include(${PICO_SDK_PATH}/pico_sdk_version.cmake) +if (${PICO_SDK_VERSION_STRING} VERSION_LESS "2.3.0") + message(FATAL_ERROR "Version 2.3.0 of the Pico SDK is required to compile this project. Please update your installation at ${PICO_SDK_PATH}") +endif () + include(${PICO_SDK_INIT_CMAKE_FILE})