target/espressif: add application tracing functionality over JTAG
[openocd.git] / src / target / espressif / esp32_apptrace.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4 * ESP32 application trace module *
5 * Copyright (C) 2017-2019 Espressif Systems Ltd. *
6 ***************************************************************************/
7
8 #ifndef OPENOCD_TARGET_ESP32_APPTRACE_H
9 #define OPENOCD_TARGET_ESP32_APPTRACE_H
10
11 #include <helper/command.h>
12 #include <helper/time_support.h>
13 #include <target/target.h>
14
15 #define ESP32_APPTRACE_MAX_CORES_NUM 2
16
17 struct esp32_apptrace_hw {
18 uint32_t max_block_id;
19 uint32_t (*max_block_size_get)(struct target *target);
20 int (*status_reg_read)(struct target *target, uint32_t *stat);
21 int (*ctrl_reg_write)(struct target *target,
22 uint32_t block_id,
23 uint32_t len,
24 bool conn,
25 bool data);
26 int (*ctrl_reg_read)(struct target *target,
27 uint32_t *block_id,
28 uint32_t *len,
29 bool *conn);
30 int (*data_len_read)(struct target *target,
31 uint32_t *block_id,
32 uint32_t *len);
33 int (*data_read)(struct target *target,
34 uint32_t size,
35 uint8_t *buffer,
36 uint32_t block_id,
37 bool ack);
38 uint32_t (*usr_block_max_size_get)(struct target *target);
39 int (*buffs_write)(struct target *target,
40 uint32_t bufs_num,
41 uint32_t buf_sz[],
42 const uint8_t *bufs[],
43 uint32_t block_id,
44 bool ack,
45 bool data);
46 int (*leave_trace_crit_section_start)(struct target *target);
47 int (*leave_trace_crit_section_stop)(struct target *target);
48 };
49
50 struct esp_apptrace_host2target_hdr {
51 uint16_t block_sz;
52 };
53
54 struct esp32_apptrace_dest {
55 void *priv;
56 int (*write)(void *priv, uint8_t *data, int size);
57 int (*clean)(void *priv);
58 bool log_progress;
59 };
60
61 struct esp32_apptrace_format {
62 uint32_t hdr_sz;
63 int (*core_id_get)(struct target *target, uint8_t *hdr_buf);
64 uint32_t (*usr_block_len_get)(struct target *target, uint8_t *hdr_buf, uint32_t *wr_len);
65 };
66
67 struct esp32_apptrace_cmd_stats {
68 uint32_t incompl_blocks;
69 uint32_t lost_bytes;
70 float min_blk_read_time;
71 float max_blk_read_time;
72 float min_blk_proc_time;
73 float max_blk_proc_time;
74 };
75
76 struct esp32_apptrace_cmd_ctx {
77 volatile int running;
78 int mode;
79 /* TODO: use subtargets from target arch info */
80 struct target *cpus[ESP32_APPTRACE_MAX_CORES_NUM];
81 /* TODO: use cores num from target */
82 unsigned int cores_num;
83 const struct esp32_apptrace_hw *hw;
84 enum target_state target_state;
85 uint32_t last_blk_id;
86 struct list_head free_trace_blocks;
87 struct list_head ready_trace_blocks;
88 uint32_t max_trace_block_sz;
89 struct esp32_apptrace_format trace_format;
90 int (*process_data)(struct esp32_apptrace_cmd_ctx *ctx, unsigned int core_id, uint8_t *data, uint32_t data_len);
91 void (*auto_clean)(struct esp32_apptrace_cmd_ctx *ctx);
92 uint32_t tot_len;
93 uint32_t raw_tot_len;
94 float stop_tmo;
95 struct esp32_apptrace_cmd_stats stats;
96 struct duration read_time;
97 struct duration idle_time;
98 void *cmd_priv;
99 struct target *target;
100 struct command_invocation *cmd;
101 };
102
103 struct esp32_apptrace_cmd_data {
104 struct esp32_apptrace_dest data_dest;
105 uint32_t poll_period;
106 uint32_t max_len;
107 uint32_t skip_len;
108 bool wait4halt;
109 };
110
111 int esp32_apptrace_cmd_ctx_init(struct esp32_apptrace_cmd_ctx *cmd_ctx, struct command_invocation *cmd, int mode);
112 int esp32_apptrace_cmd_ctx_cleanup(struct esp32_apptrace_cmd_ctx *cmd_ctx);
113 void esp32_apptrace_cmd_args_parse(struct esp32_apptrace_cmd_ctx *cmd_ctx,
114 struct esp32_apptrace_cmd_data *cmd_data,
115 const char **argv,
116 int argc);
117 int esp32_apptrace_dest_init(struct esp32_apptrace_dest dest[], const char *dest_paths[], unsigned int max_dests);
118 int esp32_apptrace_dest_cleanup(struct esp32_apptrace_dest dest[], unsigned int max_dests);
119 int esp_apptrace_usr_block_write(const struct esp32_apptrace_hw *hw, struct target *target,
120 uint32_t block_id,
121 const uint8_t *data,
122 uint32_t size);
123
124 extern const struct command_registration esp32_apptrace_command_handlers[];
125
126 #endif /* OPENOCD_TARGET_ESP32_APPTRACE_H */

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)