This is an automated email from Gerrit.

Andreas Fritiofson ([email protected]) just uploaded a new patch set 
to Gerrit, which you can find at http://openocd.zylin.com/3146

-- gerrit

commit 1d3f3739c126ab2591371583a14c6a39c01dad71
Author: Andreas Fritiofson <[email protected]>
Date:   Sun Dec 6 01:21:41 2015 +0100

    cortex_m: Discover the AP to use, just like Cortex-A
    
    This required fixing the AP ID parsing in dap_find_ap() to
    match IHI0031C. The AXI type was added too.
    
    Change-Id: I44577a7848df37586e650dce0fb57ac26f5f858c
    Signed-off-by: Andreas Fritiofson <[email protected]>

diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index 53c0c4e..3a81784 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -825,9 +825,10 @@ int dap_find_ap(struct adiv5_dap *dap, enum ap_type 
type_to_find, uint8_t *ap_nu
                 * 31-28 : Revision
                 * 27-24 : JEDEC bank (0x4 for ARM)
                 * 23-17 : JEDEC code (0x3B for ARM)
-                * 16    : Mem-AP
-                * 15-8  : Reserved
-                *  7-0  : AP Identity (1=AHB-AP 2=APB-AP 0x10=JTAG-AP)
+                * 16-13 : Class (0b1000=Mem-AP)
+                * 12-8  : Reserved
+                *  7-4  : AP Variant (non-zero for JTAG-AP)
+                *  3-0  : AP Type (0=JTAG-AP 1=AHB-AP 2=APB-AP 4=AXI-AP)
                 */
 
                /* Reading register for a non-existant AP should not cause an 
error,
@@ -835,11 +836,12 @@ int dap_find_ap(struct adiv5_dap *dap, enum ap_type 
type_to_find, uint8_t *ap_nu
                 */
                if ((retval == ERROR_OK) &&                  /* Register read 
success */
                        ((id_val & 0x0FFF0000) == 0x04770000) && /* Jedec codes 
match */
-                       ((id_val & 0xFF) == type_to_find)) {     /* type 
matches*/
+                       ((id_val & 0xF) == type_to_find)) {      /* type 
matches*/
 
                        LOG_DEBUG("Found %s at AP index: %d (IDR=0x%08" PRIX32 
")",
                                                (type_to_find == 
AP_TYPE_AHB_AP)  ? "AHB-AP"  :
                                                (type_to_find == 
AP_TYPE_APB_AP)  ? "APB-AP"  :
+                                               (type_to_find == 
AP_TYPE_AXI_AP)  ? "AXI-AP"  :
                                                (type_to_find == 
AP_TYPE_JTAG_AP) ? "JTAG-AP" : "Unknown",
                                                ap, id_val);
 
@@ -851,6 +853,7 @@ int dap_find_ap(struct adiv5_dap *dap, enum ap_type 
type_to_find, uint8_t *ap_nu
        LOG_DEBUG("No %s found",
                                (type_to_find == AP_TYPE_AHB_AP)  ? "AHB-AP"  :
                                (type_to_find == AP_TYPE_APB_AP)  ? "APB-AP"  :
+                               (type_to_find == AP_TYPE_AXI_AP)  ? "AXI-AP"  :
                                (type_to_find == AP_TYPE_JTAG_AP) ? "JTAG-AP" : 
"Unknown");
        return ERROR_FAIL;
 }
diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h
index 32b7239..85b6224 100644
--- a/src/target/arm_adi_v5.h
+++ b/src/target/arm_adi_v5.h
@@ -279,9 +279,10 @@ struct dap_ops {
  * Access Port types
  */
 enum ap_type {
-       AP_TYPE_AHB_AP  = 0x01,  /* AHB Memory-AP */
-       AP_TYPE_APB_AP  = 0x02,  /* APB Memory-AP */
-       AP_TYPE_JTAG_AP = 0x10   /* JTAG-AP - JTAG master for controlling other 
JTAG devices */
+       AP_TYPE_JTAG_AP = 0x0,  /* JTAG-AP - JTAG master for controlling other 
JTAG devices */
+       AP_TYPE_AHB_AP  = 0x1,  /* AHB Memory-AP */
+       AP_TYPE_APB_AP  = 0x2,  /* APB Memory-AP */
+       AP_TYPE_AXI_AP  = 0x4,  /* AXI Memory-AP */
 };
 
 /**
diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c
index ec5caa2..7a7194a 100644
--- a/src/target/cortex_m.c
+++ b/src/target/cortex_m.c
@@ -1903,6 +1903,13 @@ int cortex_m_examine(struct target *target)
        struct adiv5_dap *swjdp = cortex_m->armv7m.arm.dap;
        struct armv7m_common *armv7m = target_to_armv7m(target);
 
+       /* Search for the MEM-AP */
+       retval = dap_find_ap(swjdp, AP_TYPE_AHB_AP, &armv7m->debug_ap);
+       if (retval != ERROR_OK) {
+               LOG_ERROR("Could not find MEM-AP to control the core");
+               return retval;
+       }
+
        /* Leave (only) generic DAP stuff for debugport_init(); */
        swjdp->ap[armv7m->debug_ap].memaccess_tck = 8;
 

-- 

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to