]> git.sur5r.net Git - openocd/blobdiff - src/target/cortex_a.c
arm_adi_v5: Split ahbap_debugport_init
[openocd] / src / target / cortex_a.c
index f95985a746c8d0f51e14dd9df967d39fa5c3b920..0923f880c0c1eccff9bee989eaddd4a9857dc15c 100644 (file)
@@ -2910,6 +2910,12 @@ static int cortex_a_examine_first(struct target *target)
        int retval = ERROR_OK;
        uint32_t didr, ctypr, ttypr, cpuid, dbg_osreg;
 
+       retval = dap_dp_init(swjdp);
+       if (retval != ERROR_OK) {
+               LOG_ERROR("Could not initialize the debug port");
+               return retval;
+       }
+
        /* Search for the APB-AB - it is needed for access to debug registers */
        retval = dap_find_ap(swjdp, AP_TYPE_APB_AP, &armv7a->debug_ap);
        if (retval != ERROR_OK) {
@@ -2917,24 +2923,28 @@ static int cortex_a_examine_first(struct target *target)
                return retval;
        }
 
-       /* We do one extra read to ensure DAP is configured,
-        * we call ahbap_debugport_init(swjdp) instead
-        */
-       retval = ahbap_debugport_init(armv7a->debug_ap);
-       if (retval != ERROR_OK)
+       retval = mem_ap_init(armv7a->debug_ap);
+       if (retval != ERROR_OK) {
+               LOG_ERROR("Could not initialize the APB-AP");
                return retval;
+       }
 
-       /* Search for the AHB-AB */
+       /* Search for the AHB-AB.
+        * REVISIT: We should search for AXI-AP as well and make sure the AP's MEMTYPE says it
+        * can access system memory. */
+       armv7a->memory_ap_available = false;
        retval = dap_find_ap(swjdp, AP_TYPE_AHB_AP, &armv7a->memory_ap);
-       if (retval != ERROR_OK) {
+       if (retval == ERROR_OK) {
+               retval = mem_ap_init(armv7a->memory_ap);
+               if (retval == ERROR_OK)
+                       armv7a->memory_ap_available = true;
+               else
+                       LOG_WARNING("Could not initialize AHB-AP for memory access - using APB-AP");
+       } else {
                /* AHB-AP not found - use APB-AP */
                LOG_DEBUG("Could not find AHB-AP - using APB-AP for memory access");
-               armv7a->memory_ap_available = false;
-       } else {
-               armv7a->memory_ap_available = true;
        }
 
-
        if (!target->dbgbase_set) {
                uint32_t dbgbase;
                /* Get ROM Table base */