Compare commits
11 Commits
debugprobe
...
P33M-patch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc69bb8927 | ||
|
|
c70815a297 | ||
|
|
f601757084 | ||
|
|
1abda4c329 | ||
|
|
83e28db1d3 | ||
|
|
3d58384754 | ||
|
|
818ed79f4b | ||
|
|
53875ec320 | ||
|
|
9226fac61a | ||
|
|
06c7792560 | ||
|
|
1752f2a61b |
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
include(pico_sdk_import.cmake)
|
||||
|
||||
set(FREERTOS_KERNEL_PATH ${CMAKE_CURRENT_LIST_DIR}/freertos)
|
||||
set(FREERTOS_KERNEL_PATH "${CMAKE_CURRENT_LIST_DIR}/freertos")
|
||||
include(FreeRTOS_Kernel_import.cmake)
|
||||
|
||||
project(debugprobe)
|
||||
@@ -40,8 +40,8 @@ target_include_directories(debugprobe PRIVATE
|
||||
|
||||
target_compile_options(debugprobe PRIVATE -Wall)
|
||||
|
||||
pico_generate_pio_header(debugprobe ${CMAKE_CURRENT_LIST_DIR}/src/probe.pio)
|
||||
pico_generate_pio_header(debugprobe ${CMAKE_CURRENT_LIST_DIR}/src/probe_oen.pio)
|
||||
pico_generate_pio_header(debugprobe "${CMAKE_CURRENT_LIST_DIR}/src/probe.pio")
|
||||
pico_generate_pio_header(debugprobe "${CMAKE_CURRENT_LIST_DIR}/src/probe_oen.pio")
|
||||
|
||||
target_include_directories(debugprobe PRIVATE src)
|
||||
|
||||
@@ -51,12 +51,20 @@ target_compile_definitions (debugprobe PRIVATE
|
||||
|
||||
option (DEBUG_ON_PICO "Compile firmware for the Pico instead of Debug Probe" OFF)
|
||||
if (DEBUG_ON_PICO)
|
||||
target_compile_definitions (debugprobe PRIVATE
|
||||
target_compile_definitions (debugprobe PRIVATE
|
||||
DEBUG_ON_PICO=1
|
||||
)
|
||||
set_target_properties(debugprobe PROPERTIES
|
||||
OUTPUT_NAME "debugprobe_on_pico"
|
||||
)
|
||||
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 ()
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# respectively.
|
||||
|
||||
if (DEFINED ENV{FREERTOS_KERNEL_PATH} AND (NOT FREERTOS_KERNEL_PATH))
|
||||
set(FREERTOS_KERNEL_PATH $ENV{FREERTOS_KERNEL_PATH})
|
||||
set(FREERTOS_KERNEL_PATH "$ENV{FREERTOS_KERNEL_PATH}")
|
||||
message("Using FREERTOS_KERNEL_PATH from environment ('${FREERTOS_KERNEL_PATH}')")
|
||||
endif ()
|
||||
|
||||
@@ -34,18 +34,18 @@ foreach(SEARCH_PASS RANGE 0 1)
|
||||
|
||||
if (NOT FREERTOS_KERNEL_PATH)
|
||||
# check if we are inside the FreeRTOS kernel tree (i.e. this file has been included directly)
|
||||
get_filename_component(_ACTUAL_PATH ${CMAKE_CURRENT_LIST_DIR} REALPATH)
|
||||
get_filename_component(_POSSIBLE_PATH ${CMAKE_CURRENT_LIST_DIR}/${FREERTOS_KERNEL_RP2040_BACK_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH} REALPATH)
|
||||
get_filename_component(_ACTUAL_PATH "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
|
||||
get_filename_component(_POSSIBLE_PATH "${CMAKE_CURRENT_LIST_DIR}/${FREERTOS_KERNEL_RP2040_BACK_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}" REALPATH)
|
||||
if (_ACTUAL_PATH STREQUAL _POSSIBLE_PATH)
|
||||
get_filename_component(FREERTOS_KERNEL_PATH ${CMAKE_CURRENT_LIST_DIR}/${FREERTOS_KERNEL_RP2040_BACK_PATH} REALPATH)
|
||||
get_filename_component(FREERTOS_KERNEL_PATH "${CMAKE_CURRENT_LIST_DIR}/${FREERTOS_KERNEL_RP2040_BACK_PATH}" REALPATH)
|
||||
endif()
|
||||
if (_ACTUAL_PATH STREQUAL _POSSIBLE_PATH)
|
||||
get_filename_component(FREERTOS_KERNEL_PATH ${CMAKE_CURRENT_LIST_DIR}/${FREERTOS_KERNEL_RP2040_BACK_PATH} REALPATH)
|
||||
message("Setting FREERTOS_KERNEL_PATH to ${FREERTOS_KERNEL_PATH} based on location of FreeRTOS-Kernel-import.cmake")
|
||||
get_filename_component(FREERTOS_KERNEL_PATH "${CMAKE_CURRENT_LIST_DIR}/${FREERTOS_KERNEL_RP2040_BACK_PATH}" REALPATH)
|
||||
message("Setting FREERTOS_KERNEL_PATH to '${FREERTOS_KERNEL_PATH}' based on location of FreeRTOS-Kernel-import.cmake")
|
||||
break()
|
||||
elseif (PICO_SDK_PATH AND EXISTS "${PICO_SDK_PATH}/../FreeRTOS-Kernel")
|
||||
set(FREERTOS_KERNEL_PATH ${PICO_SDK_PATH}/../FreeRTOS-Kernel)
|
||||
message("Defaulting FREERTOS_KERNEL_PATH as sibling of PICO_SDK_PATH: ${FREERTOS_KERNEL_PATH}")
|
||||
set(FREERTOS_KERNEL_PATH "${PICO_SDK_PATH}/../FreeRTOS-Kernel")
|
||||
message("Defaulting FREERTOS_KERNEL_PATH as sibling of PICO_SDK_PATH: '${FREERTOS_KERNEL_PATH}'")
|
||||
break()
|
||||
endif()
|
||||
endif ()
|
||||
@@ -53,10 +53,10 @@ foreach(SEARCH_PASS RANGE 0 1)
|
||||
if (NOT FREERTOS_KERNEL_PATH)
|
||||
foreach(POSSIBLE_SUFFIX Source FreeRTOS-Kernel FreeRTOS/Source)
|
||||
# check if FreeRTOS-Kernel exists under directory that included us
|
||||
set(SEARCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
get_filename_component(_POSSIBLE_PATH ${SEARCH_ROOT}/${POSSIBLE_SUFFIX} REALPATH)
|
||||
if (EXISTS ${_POSSIBLE_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}/CMakeLists.txt)
|
||||
get_filename_component(FREERTOS_KERNEL_PATH ${_POSSIBLE_PATH} REALPATH)
|
||||
set(SEARCH_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
get_filename_component(_POSSIBLE_PATH "${SEARCH_ROOT}/${POSSIBLE_SUFFIX}" REALPATH)
|
||||
if (EXISTS "${_POSSIBLE_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}/CMakeLists.txt")
|
||||
get_filename_component(FREERTOS_KERNEL_PATH "${_POSSIBLE_PATH}" REALPATH)
|
||||
message("Setting FREERTOS_KERNEL_PATH to '${FREERTOS_KERNEL_PATH}' found relative to enclosing project")
|
||||
break()
|
||||
endif()
|
||||
@@ -81,12 +81,12 @@ endif()
|
||||
set(FREERTOS_KERNEL_PATH "${FREERTOS_KERNEL_PATH}" CACHE PATH "Path to the FreeRTOS Kernel")
|
||||
|
||||
get_filename_component(FREERTOS_KERNEL_PATH "${FREERTOS_KERNEL_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
|
||||
if (NOT EXISTS ${FREERTOS_KERNEL_PATH})
|
||||
if (NOT EXISTS "${FREERTOS_KERNEL_PATH}")
|
||||
message(FATAL_ERROR "Directory '${FREERTOS_KERNEL_PATH}' not found")
|
||||
endif()
|
||||
if (NOT EXISTS ${FREERTOS_KERNEL_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}/CMakeLists.txt)
|
||||
message(FATAL_ERROR "Directory '${FREERTOS_KERNEL_PATH}' does not contain a '${PICO_PLATFORM}' port here: ${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}")
|
||||
if (NOT EXISTS "${FREERTOS_KERNEL_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}/CMakeLists.txt")
|
||||
message(FATAL_ERROR "Directory '${FREERTOS_KERNEL_PATH}' does not contain a '${PICO_PLATFORM}' port here: '${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}'")
|
||||
endif()
|
||||
set(FREERTOS_KERNEL_PATH ${FREERTOS_KERNEL_PATH} CACHE PATH "Path to the FreeRTOS_KERNEL" FORCE)
|
||||
set(FREERTOS_KERNEL_PATH "${FREERTOS_KERNEL_PATH}" CACHE PATH "Path to the FreeRTOS_KERNEL" FORCE)
|
||||
|
||||
add_subdirectory(${FREERTOS_KERNEL_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH} FREERTOS_KERNEL)
|
||||
add_subdirectory("${FREERTOS_KERNEL_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}" FREERTOS_KERNEL)
|
||||
|
||||
@@ -9,7 +9,7 @@ Firmware source for the Raspberry Pi Debug Probe SWD/UART accessory. Can also be
|
||||
|
||||
# Documentation
|
||||
|
||||
Debug Probe documentation can be found in the [Pico Getting Started Guide](https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf). See "Appendix A: Using the Debug Probe".
|
||||
Debug Probe documentation can be found at the [Raspberry Pi Microcontroller Documentation portal](https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html#about-the-debug-probe).
|
||||
|
||||
# Hacking
|
||||
|
||||
@@ -22,7 +22,7 @@ cd debugprobe
|
||||
```
|
||||
Initialize and update the submodules:
|
||||
```
|
||||
git submodule update --init
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
Then create and switch to the build directory:
|
||||
```
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# It should be include()ed prior to project()
|
||||
|
||||
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
|
||||
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
|
||||
set(PICO_SDK_PATH "$ENV{PICO_SDK_PATH}")
|
||||
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
|
||||
endif ()
|
||||
|
||||
@@ -15,7 +15,7 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT))
|
||||
endif ()
|
||||
|
||||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH))
|
||||
set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH})
|
||||
set(PICO_SDK_FETCH_FROM_GIT_PATH "$ENV{PICO_SDK_FETCH_FROM_GIT_PATH}")
|
||||
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
|
||||
endif ()
|
||||
|
||||
@@ -26,7 +26,7 @@ set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPAT
|
||||
if (NOT PICO_SDK_PATH)
|
||||
if (PICO_SDK_FETCH_FROM_GIT)
|
||||
include(FetchContent)
|
||||
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
|
||||
set(FETCHCONTENT_BASE_DIR_SAVE "${FETCHCONTENT_BASE_DIR}")
|
||||
if (PICO_SDK_FETCH_FROM_GIT_PATH)
|
||||
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
||||
endif ()
|
||||
@@ -49,9 +49,9 @@ if (NOT PICO_SDK_PATH)
|
||||
if (NOT pico_sdk)
|
||||
message("Downloading Raspberry Pi Pico SDK")
|
||||
FetchContent_Populate(pico_sdk)
|
||||
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
|
||||
set(PICO_SDK_PATH "${pico_sdk_SOURCE_DIR}")
|
||||
endif ()
|
||||
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
|
||||
set(FETCHCONTENT_BASE_DIR "${FETCHCONTENT_BASE_DIR_SAVE}")
|
||||
else ()
|
||||
message(FATAL_ERROR
|
||||
"SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
|
||||
@@ -60,15 +60,15 @@ if (NOT PICO_SDK_PATH)
|
||||
endif ()
|
||||
|
||||
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
|
||||
if (NOT EXISTS ${PICO_SDK_PATH})
|
||||
if (NOT EXISTS "${PICO_SDK_PATH}")
|
||||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
|
||||
endif ()
|
||||
|
||||
set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
|
||||
if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
|
||||
set(PICO_SDK_INIT_CMAKE_FILE "${PICO_SDK_PATH}/pico_sdk_init.cmake")
|
||||
if (NOT EXISTS "${PICO_SDK_INIT_CMAKE_FILE}")
|
||||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
|
||||
endif ()
|
||||
|
||||
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
|
||||
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
|
||||
|
||||
include(${PICO_SDK_INIT_CMAKE_FILE})
|
||||
include("${PICO_SDK_INIT_CMAKE_FILE}")
|
||||
|
||||
28
src/main.c
28
src/main.c
@@ -60,6 +60,8 @@ static uint8_t RxDataBuffer[CFG_TUD_HID_EP_BUFSIZE];
|
||||
|
||||
TaskHandle_t dap_taskhandle, tud_taskhandle, mon_taskhandle;
|
||||
|
||||
static int was_configured;
|
||||
|
||||
void dev_mon(void *ptr)
|
||||
{
|
||||
uint32_t sof[3];
|
||||
@@ -224,17 +226,21 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
|
||||
void tud_suspend_cb(bool remote_wakeup_en)
|
||||
{
|
||||
probe_info("Suspended\n");
|
||||
/* Join DAP and UART threads? Or just suspend them, for transparency */
|
||||
vTaskSuspend(uart_taskhandle);
|
||||
vTaskSuspend(dap_taskhandle);
|
||||
/* Were we actually configured? If not, threads don't exist */
|
||||
if (was_configured) {
|
||||
vTaskSuspend(uart_taskhandle);
|
||||
vTaskSuspend(dap_taskhandle);
|
||||
}
|
||||
/* slow down clk_sys for power saving ? */
|
||||
}
|
||||
|
||||
void tud_resume_cb(void)
|
||||
{
|
||||
probe_info("Resumed\n");
|
||||
vTaskResume(uart_taskhandle);
|
||||
vTaskResume(dap_taskhandle);
|
||||
if (was_configured) {
|
||||
vTaskResume(uart_taskhandle);
|
||||
vTaskResume(dap_taskhandle);
|
||||
}
|
||||
}
|
||||
|
||||
void tud_unmount_cb(void)
|
||||
@@ -244,15 +250,19 @@ void tud_unmount_cb(void)
|
||||
vTaskSuspend(dap_taskhandle);
|
||||
vTaskDelete(uart_taskhandle);
|
||||
vTaskDelete(dap_taskhandle);
|
||||
was_configured = 0;
|
||||
}
|
||||
|
||||
void tud_mount_cb(void)
|
||||
{
|
||||
probe_info("Connected, Configured\n");
|
||||
/* UART needs to preempt USB as if we don't, characters get lost */
|
||||
xTaskCreate(cdc_thread, "UART", configMINIMAL_STACK_SIZE, NULL, UART_TASK_PRIO, &uart_taskhandle);
|
||||
/* Lowest priority thread is debug - need to shuffle buffers before we can toggle swd... */
|
||||
xTaskCreate(dap_thread, "DAP", configMINIMAL_STACK_SIZE, NULL, DAP_TASK_PRIO, &dap_taskhandle);
|
||||
if (!was_configured) {
|
||||
/* UART needs to preempt USB as if we don't, characters get lost */
|
||||
xTaskCreate(cdc_thread, "UART", configMINIMAL_STACK_SIZE, NULL, UART_TASK_PRIO, &uart_taskhandle);
|
||||
/* Lowest priority thread is debug - need to shuffle buffers before we can toggle swd... */
|
||||
xTaskCreate(dap_thread, "DAP", configMINIMAL_STACK_SIZE, NULL, DAP_TASK_PRIO, &dap_taskhandle);
|
||||
was_configured = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void vApplicationTickHook (void)
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
* is issued. At high datarates this leads to huge variation in instantaneous
|
||||
* throughput on USB, so a large runway is needed.
|
||||
*/
|
||||
#define CFG_TUD_CDC_RX_BUFSIZE 128
|
||||
#define CFG_TUD_CDC_RX_BUFSIZE 64
|
||||
#define CFG_TUD_CDC_TX_BUFSIZE 4096
|
||||
|
||||
#define CFG_TUD_VENDOR_RX_BUFSIZE 8192
|
||||
|
||||
@@ -48,7 +48,7 @@ tusb_desc_device_t const desc_device =
|
||||
|
||||
.idVendor = 0x2E8A, // Pi
|
||||
.idProduct = 0x000c, // CMSIS-DAP Debug Probe
|
||||
.bcdDevice = 0x0210, // Version 02.10
|
||||
.bcdDevice = 0x0222, // Version 02.22
|
||||
.iManufacturer = 0x01,
|
||||
.iProduct = 0x02,
|
||||
.iSerialNumber = 0x03,
|
||||
@@ -244,4 +244,4 @@ TU_VERIFY_STATIC(sizeof(desc_ms_os_20) == MS_OS_20_DESC_LEN, "Incorrect size");
|
||||
uint8_t const * tud_descriptor_bos_cb(void)
|
||||
{
|
||||
return desc_bos;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user