itm: rework itm commands before 'init' 29/6029/3
authorAntonio Borneo <borneo.antonio@gmail.com>
Fri, 13 Nov 2020 18:41:41 +0000 (19:41 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Wed, 10 Mar 2021 21:33:09 +0000 (21:33 +0000)
If the command 'itm port[s]' is issued before 'init', the ITM can
not be programmed because OpenOCD cannot access the target yet.
The configuration is recorded and applied after target examine.
The current test to trigger the ITM delayed-programming is based
on the TPIU configuration. This is allowed because the only use of
ITM it so send data through TPIU.
In case of system TPIU, not belonging anymore to the target, there
is no more association between target ITM and system TPIU.

Add a flag to record the pending ITM configuration requested
before 'init' and test the flag to trigger the delayed-programming
of the ITM.

Change-Id: I101eb97a116d7925cd2ff068f3e8813fc008b08e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6029
Tested-by: jenkins
src/target/armv7m_trace.c
src/target/armv7m_trace.h
src/target/cortex_m.c

index adfef2e9baa0bec15fbe6954701297f776d4b4b8..02f3f10610583659d9aa5c1aef502c50dbe6e84f 100644 (file)
@@ -408,8 +408,9 @@ COMMAND_HANDLER(handle_itm_port_command)
 
        if (CMD_CTX->mode == COMMAND_EXEC)
                return armv7m_trace_itm_config(target);
-       else
-               return ERROR_OK;
+
+       armv7m->trace_config.itm_deferred_config = true;
+       return ERROR_OK;
 }
 
 COMMAND_HANDLER(handle_itm_ports_command)
@@ -427,8 +428,9 @@ COMMAND_HANDLER(handle_itm_ports_command)
 
        if (CMD_CTX->mode == COMMAND_EXEC)
                return armv7m_trace_itm_config(target);
-       else
-               return ERROR_OK;
+
+       armv7m->trace_config.itm_deferred_config = true;
+       return ERROR_OK;
 }
 
 static const struct command_registration tpiu_command_handlers[] = {
index cdf79e74cb344694445f7a3e9770411b390c6009..61142b1e3a63f93c28a061a6414f810641f40192 100644 (file)
@@ -78,6 +78,8 @@ struct armv7m_trace_config {
        bool itm_async_timestamps;
        /** Enable synchronisation packet transmission (for sync port only) */
        bool itm_synchro_packets;
+       /** Config ITM after target examine */
+       bool itm_deferred_config;
 
        /** Current frequency of TRACECLKIN (usually matches HCLK) */
        unsigned int traceclkin_freq;
index ce2c426cee5bbdff91321b2af11500fd2922eee8..4580c10ff48f0d3ce56240e72ea5f70b4ef47769 100644 (file)
@@ -2082,10 +2082,11 @@ int cortex_m_examine(struct target *target)
                if (retval != ERROR_OK)
                        return retval;
 
-               if (armv7m->trace_config.config_type != TRACE_CONFIG_TYPE_DISABLED) {
+               if (armv7m->trace_config.config_type != TRACE_CONFIG_TYPE_DISABLED)
                        armv7m_trace_tpiu_config(target);
+
+               if (armv7m->trace_config.itm_deferred_config)
                        armv7m_trace_itm_config(target);
-               }
 
                /* NOTE: FPB and DWT are both optional. */
 

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)