Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -11,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
Expand Down Expand Up @@ -65,25 +64,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
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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`.

Expand Down
39 changes: 39 additions & 0 deletions include/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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_

#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
#error Unsupported board
//#include "board_example_config.h"
#endif

#endif
14 changes: 7 additions & 7 deletions include/board_debug_probe_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)"

Expand Down
4 changes: 2 additions & 2 deletions include/board_example_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
4 changes: 2 additions & 2 deletions include/board_pico_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions pico_sdk_import.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
9 changes: 1 addition & 8 deletions src/probe_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down