X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Ftarget%2Faarch64.c;h=8e90e6400711fb4689087353d221cc7c2b654a4c;hp=8592daa167c74cdc31778c97dc034ad151731246;hb=c6fe10de75763623dfdaaf2fe3fff7e78a4ca146;hpb=2278878a05d8dfbbed3e59f0cfbeeb598af3129c diff --git a/src/target/aarch64.c b/src/target/aarch64.c index 8592daa167..8e90e64007 100644 --- a/src/target/aarch64.c +++ b/src/target/aarch64.c @@ -2546,23 +2546,20 @@ static int aarch64_examine_first(struct target *target) if (!pc) return ERROR_FAIL; - if (armv8->debug_ap) { - dap_put_ap(armv8->debug_ap); - armv8->debug_ap = NULL; - } - - if (pc->adiv5_config.ap_num == DP_APSEL_INVALID) { - /* Search for the APB-AB */ - retval = dap_find_get_ap(swjdp, AP_TYPE_APB_AP, &armv8->debug_ap); - if (retval != ERROR_OK) { - LOG_ERROR("Could not find APB-AP for debug access"); - return retval; - } - } else { - armv8->debug_ap = dap_get_ap(swjdp, pc->adiv5_config.ap_num); - if (!armv8->debug_ap) { - LOG_ERROR("Cannot get AP"); - return ERROR_FAIL; + if (!armv8->debug_ap) { + if (pc->adiv5_config.ap_num == DP_APSEL_INVALID) { + /* Search for the APB-AB */ + retval = dap_find_get_ap(swjdp, AP_TYPE_APB_AP, &armv8->debug_ap); + if (retval != ERROR_OK) { + LOG_ERROR("Could not find APB-AP for debug access"); + return retval; + } + } else { + armv8->debug_ap = dap_get_ap(swjdp, pc->adiv5_config.ap_num); + if (!armv8->debug_ap) { + LOG_ERROR("Cannot get AP"); + return ERROR_FAIL; + } } }