From e94242c156a89405dc7a6118d80386c8e4b0bee7 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Mon, 2 Dec 2024 22:13:39 +0100 Subject: [PATCH] nrf51: Rename MDM to CTRL-AP MDM is a NXP-specific term, Nordic calls it a CTRL-AP. --- src/target/adiv5.c | 2 +- src/target/nrf51.c | 40 +++++++++++++++++++-------------------- src/target/target_probe.c | 2 +- src/target/target_probe.h | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/target/adiv5.c b/src/target/adiv5.c index 91d7b6520dc..8712e2beeb2 100644 --- a/src/target/adiv5.c +++ b/src/target/adiv5.c @@ -513,7 +513,7 @@ void adiv5_dp_init(adiv5_debug_port_s *const dp) } kinetis_mdm_probe(ap); - nrf51_mdm_probe(ap); + nrf51_ctrl_ap_probe(ap); nrf54l_ctrl_ap_probe(ap); efm32_aap_probe(ap); lpc55_dmap_probe(ap); diff --git a/src/target/nrf51.c b/src/target/nrf51.c index a60975c9291..ecf448f35e5 100644 --- a/src/target/nrf51.c +++ b/src/target/nrf51.c @@ -400,20 +400,20 @@ static bool nrf51_cmd_read(target_s *t, int argc, const char **argv) return nrf51_cmd_read_help(t, 0, NULL); } -#define NRF52_MDM_IDR 0x02880000U +#define NRF52_CTRL_AP_IDR 0x02880000U -static bool nrf51_mdm_mass_erase(target_s *t, platform_timeout_s *print_progess); +static bool nrf51_ctrl_ap_mass_erase(target_s *t, platform_timeout_s *print_progess); -#define MDM_POWER_EN ADIV5_DP_REG(0x01U) -#define MDM_SELECT_AP ADIV5_DP_REG(0x02U) -#define MDM_STATUS ADIV5_AP_REG(0x08U) -#define MDM_CONTROL ADIV5_AP_REG(0x04U) -#define MDM_PROT_EN ADIV5_AP_REG(0x0cU) +#define CTRL_AP_POWER_EN ADIV5_DP_REG(0x01U) +#define CTRL_AP_SELECT_AP ADIV5_DP_REG(0x02U) +#define CTRL_AP_STATUS ADIV5_AP_REG(0x08U) +#define CTRL_AP_CONTROL ADIV5_AP_REG(0x04U) +#define CTRL_AP_PROT_EN ADIV5_AP_REG(0x0cU) -bool nrf51_mdm_probe(adiv5_access_port_s *ap) +bool nrf51_ctrl_ap_probe(adiv5_access_port_s *ap) { switch (ap->idr) { - case NRF52_MDM_IDR: + case NRF52_CTRL_AP_IDR: break; default: return false; @@ -424,13 +424,13 @@ bool nrf51_mdm_probe(adiv5_access_port_s *ap) return false; t->enter_flash_mode = target_enter_flash_mode_stub; - t->mass_erase = nrf51_mdm_mass_erase; + t->mass_erase = nrf51_ctrl_ap_mass_erase; adiv5_ap_ref(ap); t->priv = ap; t->priv_free = (void *)adiv5_ap_unref; - uint32_t status = adiv5_ap_read(ap, MDM_PROT_EN); - status = adiv5_ap_read(ap, MDM_PROT_EN); + uint32_t status = adiv5_ap_read(ap, CTRL_AP_PROT_EN); + status = adiv5_ap_read(ap, CTRL_AP_PROT_EN); if (status) t->driver = "Nordic nRF52 Access Port"; else @@ -440,24 +440,24 @@ bool nrf51_mdm_probe(adiv5_access_port_s *ap) return true; } -static bool nrf51_mdm_mass_erase(target_s *const t, platform_timeout_s *const print_progess) +static bool nrf51_ctrl_ap_mass_erase(target_s *const t, platform_timeout_s *const print_progess) { adiv5_access_port_s *const ap = t->priv; - uint32_t status = adiv5_ap_read(ap, MDM_STATUS); - adiv5_dp_write(ap->dp, MDM_POWER_EN, 0x50000000U); - adiv5_dp_write(ap->dp, MDM_SELECT_AP, 0x01000000U); - adiv5_ap_write(ap, MDM_CONTROL, 0x00000001U); + uint32_t status = adiv5_ap_read(ap, CTRL_AP_STATUS); + adiv5_dp_write(ap->dp, CTRL_AP_POWER_EN, 0x50000000U); + adiv5_dp_write(ap->dp, CTRL_AP_SELECT_AP, 0x01000000U); + adiv5_ap_write(ap, CTRL_AP_CONTROL, 0x00000001U); // Read until 0, probably should have a timeout here... do { - status = adiv5_ap_read(ap, MDM_STATUS); + status = adiv5_ap_read(ap, CTRL_AP_STATUS); target_print_progress(print_progess); } while (status); // The second read will provide true prot status - status = adiv5_ap_read(ap, MDM_PROT_EN); - status = adiv5_ap_read(ap, MDM_PROT_EN); + status = adiv5_ap_read(ap, CTRL_AP_PROT_EN); + status = adiv5_ap_read(ap, CTRL_AP_PROT_EN); // Should we return the prot status here? return true; diff --git a/src/target/target_probe.c b/src/target/target_probe.c index d4a6a4cacd5..2fee2a324e1 100644 --- a/src/target/target_probe.c +++ b/src/target/target_probe.c @@ -97,7 +97,7 @@ TARGET_PROBE_WEAK_NOP(riscv64_probe) CORTEXM_PROBE_WEAK_NOP(efm32_aap_probe) CORTEXM_PROBE_WEAK_NOP(kinetis_mdm_probe) CORTEXM_PROBE_WEAK_NOP(lpc55_dmap_probe) -CORTEXM_PROBE_WEAK_NOP(nrf51_mdm_probe) +CORTEXM_PROBE_WEAK_NOP(nrf51_ctrl_ap_probe) CORTEXM_PROBE_WEAK_NOP(nrf54l_ctrl_ap_probe) CORTEXM_PROBE_WEAK_NOP(rp2040_rescue_probe) diff --git a/src/target/target_probe.h b/src/target/target_probe.h index 842211a16ba..a68693dea8c 100644 --- a/src/target/target_probe.h +++ b/src/target/target_probe.h @@ -48,7 +48,7 @@ bool riscv64_probe(target_s *target); bool efm32_aap_probe(adiv5_access_port_s *ap); bool kinetis_mdm_probe(adiv5_access_port_s *ap); bool lpc55_dmap_probe(adiv5_access_port_s *ap); -bool nrf51_mdm_probe(adiv5_access_port_s *ap); +bool nrf51_ctrl_ap_probe(adiv5_access_port_s *ap); bool nrf54l_ctrl_ap_probe(adiv5_access_port_s *ap); bool rp2040_rescue_probe(adiv5_access_port_s *ap);