From 7d533b31e0efd9a963f18c5fb5ee7d1338a3e4e3 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Fri, 6 Sep 2024 11:36:31 +0100 Subject: [PATCH] rp2350: Handle the RISC-V cores properly --- src/target/rp2350.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/target/rp2350.c b/src/target/rp2350.c index 1fac3c4e586..063b3856ee0 100644 --- a/src/target/rp2350.c +++ b/src/target/rp2350.c @@ -36,6 +36,8 @@ #include "target.h" #include "target_internal.h" #include "cortexm.h" +#include "cortex_internal.h" +#include "riscv_debug.h" #include "spi.h" #include "sfdp.h" @@ -121,7 +123,8 @@ #define RP2350_QMI_DIRECT_TX_OUTPUT_ENABLE (1U << 19U) #define RP2350_QMI_DIRECT_TX_NOPUSH_RX (1U << 20U) -#define ID_RP2350 0x0040U +#define ID_RP2350_ARM 0x0040U +#define ID_RP2350_RISCV 0x0004U static bool rp2350_attach(target_s *target); static bool rp2350_flash_prepare(target_s *target); @@ -155,7 +158,7 @@ static void rp2350_add_flash(target_s *const target) bool rp2350_probe(target_s *const target) { /* Check that the target has the right part number */ - if (target->part_id != ID_RP2350) + if (target->part_id != ID_RP2350_ARM && target->part_id != ID_RP2350_RISCV) return false; /* Check the boot ROM magic for a more positive identification of the part */ @@ -177,8 +180,15 @@ bool rp2350_probe(target_s *const target) static bool rp2350_attach(target_s *const target) { /* Complete the attach to the core first */ - if (!cortexm_attach(target)) - return false; + if (target->priv_free == cortex_priv_free) { + if (!cortexm_attach(target)) + return false; +#ifdef ENABLE_RISCV + } else { + if (!riscv_attach(target)) + return false; +#endif + } /* Then figure out the memory map */ target_mem_map_free(target);