arm_debug: Support multiple APs per DAP and remove DAP from armv7* structs
[openocd.git] / src / target / cortex_m.c
index b821bde8538406ca2a7198ae11f9c99c9ffd714f..f8a513265c93d3c147493fea09c0668e6d2ca103 100644 (file)
@@ -1903,6 +1903,9 @@ int cortex_m_examine(struct target *target)
        struct adiv5_dap *swjdp = cortex_m->armv7m.arm.dap;
        struct armv7m_common *armv7m = target_to_armv7m(target);
 
+       /* Leave (only) generic DAP stuff for debugport_init(); */
+       swjdp->ap[armv7m->debug_ap].memaccess_tck = 8;
+
        /* stlink shares the examine handler but does not support
         * all its calls */
        if (!armv7m->stlink) {
@@ -1957,7 +1960,7 @@ int cortex_m_examine(struct target *target)
 
                if (i == 4 || i == 3) {
                        /* Cortex-M3/M4 has 4096 bytes autoincrement range */
-                       armv7m->dap.tar_autoincr_block = (1 << 12);
+                       swjdp->ap[armv7m->debug_ap].tar_autoincr_block = (1 << 12);
                }
 
                /* Configure trace modules */
@@ -2106,24 +2109,26 @@ static int cortex_m_init_arch_info(struct target *target,
 
        armv7m_init_arch_info(target, armv7m);
 
-       /* prepare JTAG information for the new target */
-       cortex_m->jtag_info.tap = tap;
-       cortex_m->jtag_info.scann_size = 4;
+       /*  tap has no dap initialized */
+       if (!tap->dap) {
+               tap->dap = dap_init();
+
+               /* prepare JTAG information for the new target */
+               cortex_m->jtag_info.tap = tap;
+               cortex_m->jtag_info.scann_size = 4;
+
+               /* Leave (only) generic DAP stuff for debugport_init() */
+               tap->dap->jtag_info = &cortex_m->jtag_info;
+       }
 
        /* default reset mode is to use srst if fitted
         * if not it will use CORTEX_M3_RESET_VECTRESET */
        cortex_m->soft_reset_config = CORTEX_M_RESET_VECTRESET;
 
-       armv7m->arm.dap = &armv7m->dap;
+       armv7m->arm.dap = tap->dap;
 
        /* Leave (only) generic DAP stuff for debugport_init(); */
-       armv7m->dap.jtag_info = &cortex_m->jtag_info;
-       armv7m->dap.memaccess_tck = 8;
-
-       /* Cortex-M3/M4 has 4096 bytes autoincrement range
-        * but set a safe default to 1024 to support Cortex-M0
-        * this will be changed in cortex_m3_examine if a M3/M4 is detected */
-       armv7m->dap.tar_autoincr_block = (1 << 10);
+       tap->dap->ap[dap_ap_get_select(tap->dap)].memaccess_tck = 8;
 
        /* register arch-specific functions */
        armv7m->examine_debug_reason = cortex_m_examine_debug_reason;

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)