itm: rework itm commands before 'init'

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
This commit is contained in:
Antonio Borneo 2020-11-13 19:41:41 +01:00
parent faaa42283f
commit f9509c92db
3 changed files with 11 additions and 6 deletions

View 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[] = {

View 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;

View 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. */