From 5e8624dae33fb2a08d80eda30311c7bdca36a45c Mon Sep 17 00:00:00 2001 From: Peter Lawrence <12226419+majbthrd@users.noreply.github.com> Date: Sat, 6 Feb 2021 19:30:11 -0600 Subject: [PATCH] two variants; debugger now runs on Core1 --- DAP_config.h | 22 +++---- README.md | 11 +++- pico-debug.hzp | 33 ++++++----- picodebug_MemoryMap.xml | 2 +- picodebug_Startup.s | 20 ++++--- picodebug_sram_placement.xml | 15 +++++ ...acement.xml => picodebug_xip_placement.xml | 13 +++-- spawn.c | 58 +++++++++++++++++++ usb_descriptors.c | 2 +- 9 files changed, 132 insertions(+), 44 deletions(-) create mode 100644 picodebug_sram_placement.xml rename picodebug_placement.xml => picodebug_xip_placement.xml (69%) create mode 100644 spawn.c diff --git a/DAP_config.h b/DAP_config.h index f04b40b..0f07ea8 100644 --- a/DAP_config.h +++ b/DAP_config.h @@ -225,7 +225,7 @@ __STATIC_INLINE void PORT_SWD_SETUP (void) { /* enable the peripheral and enable local control of core1's SWD interface */ resets_hw->reset &= ~RESETS_RESET_SYSCFG_BITS; - syscfg_hw->dbgforce = SYSCFG_DBGFORCE_PROC1_ATTACH_BITS; + syscfg_hw->dbgforce = SYSCFG_DBGFORCE_PROC0_ATTACH_BITS; #if 1 /* this #if block is a temporary measure to perform target selection even if the host IDE doesn't know how */ @@ -238,12 +238,12 @@ __STATIC_INLINE void PORT_SWD_SETUP (void) { SWJ_Sequence(8*sizeof(sequence_alert), sequence_alert); /* it is possible to do this with SWJ_Sequence on the rp2040 since data input and output are distinct */ - static const uint8_t write_targetsel[] = { 0x99, 0xff, 0x24, 0x05, 0x20, 0x22, 0x00, }; + static const uint8_t write_targetsel[] = { 0x99, 0xff, 0x24, 0x05, 0x20, 0x00, 0x00, }; SWJ_Sequence(8*sizeof(write_targetsel), write_targetsel); #endif /* set to default high level */ - syscfg_hw->dbgforce |= SYSCFG_DBGFORCE_PROC1_SWCLK_BITS | SYSCFG_DBGFORCE_PROC1_SWDI_BITS; + syscfg_hw->dbgforce |= SYSCFG_DBGFORCE_PROC0_SWCLK_BITS | SYSCFG_DBGFORCE_PROC0_SWDI_BITS; } /** Disable JTAG/SWD I/O Pins. @@ -268,14 +268,14 @@ __STATIC_FORCEINLINE uint32_t PIN_SWCLK_TCK_IN (void) { Set the SWCLK/TCK DAP hardware I/O pin to high level. */ __STATIC_FORCEINLINE void PIN_SWCLK_TCK_SET (void) { - syscfg_hw->dbgforce |= SYSCFG_DBGFORCE_PROC1_SWCLK_BITS; + syscfg_hw->dbgforce |= SYSCFG_DBGFORCE_PROC0_SWCLK_BITS; } /** SWCLK/TCK I/O pin: Set Output to Low. Set the SWCLK/TCK DAP hardware I/O pin to low level. */ __STATIC_FORCEINLINE void PIN_SWCLK_TCK_CLR (void) { - syscfg_hw->dbgforce &= ~SYSCFG_DBGFORCE_PROC1_SWCLK_BITS; + syscfg_hw->dbgforce &= ~SYSCFG_DBGFORCE_PROC0_SWCLK_BITS; } @@ -294,21 +294,21 @@ __STATIC_FORCEINLINE uint32_t PIN_SWDIO_TMS_IN (void) { Set the SWDIO/TMS DAP hardware I/O pin to high level. */ __STATIC_FORCEINLINE void PIN_SWDIO_TMS_SET (void) { - syscfg_hw->dbgforce |= SYSCFG_DBGFORCE_PROC1_SWDI_BITS; + syscfg_hw->dbgforce |= SYSCFG_DBGFORCE_PROC0_SWDI_BITS; } /** SWDIO/TMS I/O pin: Set Output to Low. Set the SWDIO/TMS DAP hardware I/O pin to low level. */ __STATIC_FORCEINLINE void PIN_SWDIO_TMS_CLR (void) { - syscfg_hw->dbgforce &= ~SYSCFG_DBGFORCE_PROC1_SWDI_BITS; + syscfg_hw->dbgforce &= ~SYSCFG_DBGFORCE_PROC0_SWDI_BITS; } /** SWDIO I/O pin: Get Input (used in SWD mode only). \return Current status of the SWDIO DAP hardware I/O pin. */ __STATIC_FORCEINLINE uint32_t PIN_SWDIO_IN (void) { - return (syscfg_hw->dbgforce & SYSCFG_DBGFORCE_PROC1_SWDO_BITS) ? 1U : 0U; + return (syscfg_hw->dbgforce & SYSCFG_DBGFORCE_PROC0_SWDO_BITS) ? 1U : 0U; } /** SWDIO I/O pin: Set Output (used in SWD mode only). @@ -316,9 +316,9 @@ __STATIC_FORCEINLINE uint32_t PIN_SWDIO_IN (void) { */ __STATIC_FORCEINLINE void PIN_SWDIO_OUT (uint32_t bit) { if (bit & 1) - syscfg_hw->dbgforce |= SYSCFG_DBGFORCE_PROC1_SWDI_BITS; + syscfg_hw->dbgforce |= SYSCFG_DBGFORCE_PROC0_SWDI_BITS; else - syscfg_hw->dbgforce &= ~SYSCFG_DBGFORCE_PROC1_SWDI_BITS; + syscfg_hw->dbgforce &= ~SYSCFG_DBGFORCE_PROC0_SWDI_BITS; } /** SWDIO I/O pin: Switch to Output mode (used in SWD mode only). @@ -334,7 +334,7 @@ Configure the SWDIO DAP hardware I/O pin to input mode. This function is called prior \ref PIN_SWDIO_IN function calls. */ __STATIC_FORCEINLINE void PIN_SWDIO_OUT_DISABLE (void) { - syscfg_hw->dbgforce |= SYSCFG_DBGFORCE_PROC1_SWDI_BITS; + syscfg_hw->dbgforce |= SYSCFG_DBGFORCE_PROC0_SWDI_BITS; } diff --git a/README.md b/README.md index d2ee0e0..289b3ce 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,18 @@ pico-debug runs on one core in a RP2040 and provides a USB CMSIS-DAP interface t Boot the RP2040 with the BOOTSEL button pressed, copy over pico-debug.uf2, and it immediately reboots as a CMSIS-DAP adapter. pico-debug loads as a RAM only .uf2 image, meaning that it is never written to flash and doesn't replace existing user code. -*All* 264kBytes of SRAM on the RP2040 is available for running user code; pico-debug shoehorns itself entirely into the 16kBytes of XIP_SRAM (aka flash cache). +To cater to different user situations, there are two versions of pico-debug: **MAXRAM** and **GIMMECACHE** -If viewing this on github, a pre-built binary is available for download on the right under "Releases". +With **pico-debug-maxram**, *all* 264kBytes of SRAM on the RP2040 is available for running user code; pico-debug shoehorns itself entirely into the 16kBytes of XIP_SRAM (aka flash cache). + +With **pico-debug-gimmecache**, 248kBytes (94% of total) of SRAM is available for running user code; pico-debug gives plenty of elbow room by occupying only 6% near the very top of SRAM, and unlike MAXRAM, leaves the flash cache operational. + +If viewing this on github, pre-built binaries are available for download on the right under "Releases". ## Caveats whilst using pico-debug -- the flash cache cannot be used by the user code, as pico-debug is using this memory +- MAXRAM only: the flash cache cannot be used by the user code, as pico-debug is using this memory +- GIMMECACHE only: SRAM 0x2003C000 to 0x2003FFFF must not be used by user code - user code cannot reconfigure the PLL and clocks, as the USB peripheral needs this - the USB peripheral is used to provide the debugger, so the user code cannot use it as well diff --git a/pico-debug.hzp b/pico-debug.hzp index 950ef4c..7a4428e 100644 --- a/pico-debug.hzp +++ b/pico-debug.hzp @@ -3,18 +3,20 @@ + gcc_entry_point="boot_entry" + package_dependencies="CMSIS;Cortex_M_Generic" /> + @@ -44,9 +46,7 @@ - - -