This is an automated email from Gerrit. Eric Katzfey ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/3711
-- gerrit commit 4210861ae3302f3810bd5b5c7db6474025765a20 Author: Eric Katzfey <[email protected]> Date: Fri Aug 19 10:05:14 2016 -0700 target: Added the ability to configure the AP number Specify the AP number for the target as a parameter in 'target create'. The AP number is stored in the target structure and can be used by any target. This makes it available to both Cortex-M and Cortex-A targets. Change-Id: Ie1f1e79e0619d59f04a4d8f5c8f2ce4001a3effa Signed-off-by: Eric Katzfey <[email protected]> diff --git a/doc/openocd.texi b/doc/openocd.texi index 8146654..4031c10 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -4223,6 +4223,9 @@ The value should normally correspond to a static mapping for the @option{FreeRTOS}|@option{linux}|@option{ChibiOS}|@option{embKernel}|@option{mqx} @xref{gdbrtossupport,,RTOS Support}. +@item @code{-ap-num} @var{num} -- choose the AP to use for this target. This works for both +cortex_m and cortex_a. + @end itemize @end deffn diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c index d1590f6..a1b8806 100644 --- a/src/target/cortex_a.c +++ b/src/target/cortex_a.c @@ -2963,11 +2963,17 @@ static int cortex_a_examine_first(struct target *target) return retval; } - /* Search for the APB-AP - it is needed for access to debug registers */ - retval = dap_find_ap(swjdp, AP_TYPE_APB_AP, &armv7a->debug_ap); - if (retval != ERROR_OK) { - LOG_ERROR("Could not find APB-AP for debug access"); - return retval; + /* Search for the APB-AP if location wasn't configured. + * It is needed for access to debug registers */ + if (target->ap_num == -1) { + retval = dap_find_ap(swjdp, AP_TYPE_APB_AP, &armv7a->debug_ap); + if (retval != ERROR_OK) { + LOG_ERROR("Could not find APB-AP for debug access"); + return retval; + } + } else { + armv7a->debug_ap = &swjdp->ap[target->ap_num]; + LOG_DEBUG("Configured Cortex-A APB-AP at AP index: %d", target->ap_num); } retval = mem_ap_init(armv7a->debug_ap); diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index a6a9309..c1cf6a6 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -1898,11 +1898,20 @@ int cortex_m_examine(struct target *target) return retval; } - /* 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; + /* Search for the MEM-AP if location wasn't configured */ + if (target->ap_num == -1) { + 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; + } else { + target->ap_num = armv7m->debug_ap->ap_num; + } + } else { + armv7m->debug_ap = &swjdp->ap[target->ap_num]; + LOG_DEBUG("Configured Cortex-M AHB-AP at AP index: %d", target->ap_num); } /* Leave (only) generic DAP stuff for debugport_init(); */ diff --git a/src/target/target.c b/src/target/target.c index 56d9eee..bbc302d 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -4323,6 +4323,7 @@ enum target_cfg_param { TCFG_CHAIN_POSITION, TCFG_DBGBASE, TCFG_RTOS, + TCFG_AP_NUM, }; static Jim_Nvp nvp_config_opts[] = { @@ -4337,6 +4338,7 @@ static Jim_Nvp nvp_config_opts[] = { { .name = "-chain-position", .value = TCFG_CHAIN_POSITION }, { .name = "-dbgbase", .value = TCFG_DBGBASE }, { .name = "-rtos", .value = TCFG_RTOS }, + { .name = "-ap-num", .value = TCFG_AP_NUM }, { .name = NULL, .value = -1 } }; @@ -4611,6 +4613,20 @@ no_params: } /* loop for more */ break; + case TCFG_AP_NUM: + /* Configure AP number so that it doesn't have to be detected */ + if (goi->isconfigure) { + e = Jim_GetOpt_Wide(goi, &w); + if (e != JIM_OK) + return e; + target->ap_num = (int)w; + } else { + if (goi->argc != 0) + goto no_params; + } + Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, target->ap_num)); + /* loop for more */ + break; } } /* while (goi->argc) */ @@ -5340,6 +5356,8 @@ static int target_create(Jim_GetOptInfo *goi) target->rtos = NULL; target->rtos_auto_detect = false; + target->ap_num = -1; + /* Do the rest as "configure" options */ goi->isconfigure = 1; e = target_configure(goi, target); diff --git a/src/target/target.h b/src/target/target.h index 0cee117..5d61334 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -186,6 +186,7 @@ struct target { * and must be detected when symbols are offered */ struct backoff_timer backoff; int smp; /* add some target attributes for smp support */ + int ap_num; /* Which AP in a DAP */ struct target_list *head; /* the gdb service is there in case of smp, we have only one gdb server * for all smp target -- ------------------------------------------------------------------------------ _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
