target/aarch64: Use apnum setting 31/5831/4
authorKevin Yang <kangyang@google.com>
Thu, 3 Sep 2020 03:15:31 +0000 (20:15 -0700)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 11 Oct 2020 14:53:43 +0000 (15:53 +0100)
Change aarch64 to use ap-num setting if provided. Fall back to original
behavior of using first AP when ap-num is invalid.

Change-Id: I0d3624f75c86ba5fd5a322ac60856dbbb6e71eaf
Signed-off-by: Kevin Yang <kangyang@google.com>
Reviewed-on: http://openocd.zylin.com/5831
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/target/aarch64.c

index dee16d116130c90997fe88bcc8bcdfde15ec229b..8d23bcabc631ac43cdc02957414c3d8dfe6e19d3 100644 (file)
@@ -2248,7 +2248,7 @@ static int aarch64_examine_first(struct target *target)
        struct aarch64_common *aarch64 = target_to_aarch64(target);
        struct armv8_common *armv8 = &aarch64->armv8_common;
        struct adiv5_dap *swjdp = armv8->arm.dap;
-       struct aarch64_private_config *pc;
+       struct aarch64_private_config *pc = target->private_config;
        int i;
        int retval = ERROR_OK;
        uint64_t debug, ttypr;
@@ -2256,11 +2256,18 @@ static int aarch64_examine_first(struct target *target)
        uint32_t tmp0, tmp1, tmp2, tmp3;
        debug = ttypr = cpuid = 0;
 
-       /* Search for the APB-AB - it is needed for access to debug registers */
-       retval = dap_find_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;
+       if (pc == NULL)
+               return ERROR_FAIL;
+
+       if (pc->adiv5_config.ap_num == DP_APSEL_INVALID) {
+               /* Search for the APB-AB */
+               retval = dap_find_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_ap(swjdp, pc->adiv5_config.ap_num);
        }
 
        retval = mem_ap_init(armv8->debug_ap);
@@ -2335,10 +2342,6 @@ static int aarch64_examine_first(struct target *target)
        LOG_DEBUG("ttypr = 0x%08" PRIx64, ttypr);
        LOG_DEBUG("debug = 0x%08" PRIx64, debug);
 
-       if (target->private_config == NULL)
-               return ERROR_FAIL;
-
-       pc = (struct aarch64_private_config *)target->private_config;
        if (pc->cti == NULL)
                return ERROR_FAIL;
 
@@ -2491,6 +2494,7 @@ static int aarch64_jim_configure(struct target *target, Jim_GetOptInfo *goi)
        pc = (struct aarch64_private_config *)target->private_config;
        if (pc == NULL) {
                        pc = calloc(1, sizeof(struct aarch64_private_config));
+                       pc->adiv5_config.ap_num = DP_APSEL_INVALID;
                        target->private_config = pc;
        }
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)