From eb494103d43ddaf432b261078112db26f4c97255 Mon Sep 17 00:00:00 2001 From: Roger Wolff Date: Thu, 22 Jun 2023 14:50:25 +0200 Subject: [PATCH] buildsystem improvements to make it easier to build for debugprobe. (#87) Merge documentation pull request from @rewolff --- CMakeLists.txt | 11 +++++++++++ README.md | 31 +++++++++++++++++++++++++++++++ include/board_debugprobe_config.h | 2 +- src/picoprobe_config.h | 5 ++++- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4b8a67..c7df996 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,17 @@ target_compile_definitions (picoprobe PRIVATE PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1 ) +option (DEBUGPROBE "compile for the debugprobe" OFF) +if (DEBUGPROBE) + target_compile_definitions (picoprobe PRIVATE + DEBUGPROBE=1 + ) + set_target_properties(picoprobe PROPERTIES + OUTPUT_NAME "debugprobe" + ) +endif () + + target_link_libraries(picoprobe PRIVATE pico_multicore pico_stdlib diff --git a/README.md b/README.md index c938a95..b315456 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,37 @@ Picoprobe allows a Pico / RP2040 to be used as USB -> SWD and UART bridge. This # Documentation Picoprobe documentation can be found in the [Pico Getting Started Guide](https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf). See "Appendix A: Using Picoprobe". +# Hacking + +For the purpose of making changes or studying of the code, you may want to compile the code yourself. + +To compile this project just initialize the submodules and update them: +``` + git submodule init + git submodule update +``` +then create and switch to the build directory: +``` + mkdir build + cd build +``` +then run cmake and build the code: +``` + cmake .. + make +``` +Done! You should now have a picoprobe.uf2 that you can upload to your pico in the normal way. + +If you want to create the version that runs on the raspberry pi debugprobe, then you need to invoke cmake in the sequence above with the DEBUGPROBE=ON option: +``` +cmake -DDEBUGPROBE=ON .. +``` + +This will build with the configuration for the debugprobe and call the output program "debugprobe.uf2" as opposed to "picoprobe.uf2" for the vanilla version. + +Note that if you first ran through the whole sequence to compile for the pico, then you don't need to start back at the top. You can just go back to the cmake step and start from there. + + # TODO - TinyUSB's vendor interface is FIFO-based and not packet-based. Using raw tx/rx callbacks is preferable as this stops DAP command batches from being concatenated, which confused openOCD. - Instead of polling, move the DAP thread to an asynchronously started/stopped one-shot operation to reduce CPU wakeups diff --git a/include/board_debugprobe_config.h b/include/board_debugprobe_config.h index e5e9157..32b744c 100644 --- a/include/board_debugprobe_config.h +++ b/include/board_debugprobe_config.h @@ -52,4 +52,4 @@ #define PROBE_PRODUCT_STRING "Debug Probe (CMSIS-DAP)" -#endif \ No newline at end of file +#endif diff --git a/src/picoprobe_config.h b/src/picoprobe_config.h index 68b791c..dd5d7b3 100644 --- a/src/picoprobe_config.h +++ b/src/picoprobe_config.h @@ -47,8 +47,11 @@ // TODO tie this up with PICO_BOARD defines in the main SDK +#ifndef DEBUGPROBE #include "board_pico_config.h" -//#include "board_debugprobe_config.h" +#else +#include "board_debugprobe_config.h" +#endif //#include "board_example_config.h"