]> git.gag.com Git - fw/openocd/commitdiff
armv7m_trace: stop getting traces from adapter at exit
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 14 Dec 2020 16:08:06 +0000 (17:08 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 26 Dec 2020 15:47:44 +0000 (15:47 +0000)
If OpenOCD is reading trace data from the target, at exit it
should stop the adapter to gather data, but should left the target
still producing them.

Add a helper in armv7m_trace to disable the adapter's trace and
call it during OpenOCD teardown.

This also provides a workaround for an issue in the firmware of
ST-Link V3 till version V3J7. If the SWD connection is closed when
trace is active, at following connection the trace does not work
anymore.

Change-Id: I47ccab61405384938555096c5aca789eaa090d27
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5978
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
Tested-by: jenkins
src/target/armv7m_trace.c
src/target/armv7m_trace.h
src/target/cortex_m.c

index 916d1a1647866d8d8ad4f938966e32dffb725cb3..10f14221d43b927cb9652efea1d4199ac1587730 100644 (file)
@@ -234,6 +234,21 @@ static int trace_connection_closed(struct connection *connection)
        return ERROR_OK;
 }
 
+extern struct command_context *global_cmd_ctx;
+
+int armv7m_trace_tpiu_exit(struct target *target)
+{
+       struct armv7m_common *armv7m = target_to_armv7m(target);
+
+       if (global_cmd_ctx->mode == COMMAND_CONFIG ||
+               armv7m->trace_config.config_type == TRACE_CONFIG_TYPE_DISABLED)
+               return ERROR_OK;
+
+       close_trace_channel(armv7m);
+       armv7m->trace_config.config_type = TRACE_CONFIG_TYPE_DISABLED;
+       return armv7m_trace_tpiu_config(target);
+}
+
 COMMAND_HANDLER(handle_tpiu_config_command)
 {
        struct target *target = get_current_target(CMD_CTX);
index 076f9d5829d119b4a2fddfe9c5cada03a7524008..cdf79e74cb344694445f7a3e9770411b390c6009 100644 (file)
@@ -95,6 +95,10 @@ extern const struct command_registration armv7m_trace_command_handlers[];
  * Configure hardware accordingly to the current TPIU target settings
  */
 int armv7m_trace_tpiu_config(struct target *target);
+/**
+ * Disable TPIU data gathering at exit
+ */
+int armv7m_trace_tpiu_exit(struct target *target);
 /**
  * Configure hardware accordingly to the current ITM target settings
  */
index 316089c3513a1359c1e2d8a45452968960b60a96..ac308b43ba6e1815ddb533ac996c3e361dc4efd5 100644 (file)
@@ -1648,6 +1648,8 @@ void cortex_m_deinit_target(struct target *target)
 {
        struct cortex_m_common *cortex_m = target_to_cm(target);
 
+       armv7m_trace_tpiu_exit(target);
+
        free(cortex_m->fp_comparator_list);
 
        cortex_m_dwt_free(target);