Skip to content

Commit 393238e

Browse files
committed
target/espressif: fix upstream review comments
1 parent cc534a6 commit 393238e

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

doc/openocd.texi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11138,8 +11138,8 @@ Data will be stored to specified destination.
1113811138
@item @code{trace_size} - maximum trace data size.
1113911139
Tracing will be stopped automatically when that amount is reached.
1114011140
Use "-1" to disable the limitation.
11141-
@item @code{stop_tmo} - Data receiption timeout in ms.
11142-
Tracing will be stopped automatically when no data is received withn that period.
11141+
@item @code{stop_tmo} - Data reception timeout in ms.
11142+
Tracing will be stopped automatically when no data is received within that period.
1114311143
@item @code{wait4halt} - if non-zero then wait for target to be halted before tracing start.
1114411144
@item @code{skip_size} - amount of tracing data to be skipped before writing it to destination.
1114511145
@end itemize
@@ -11154,7 +11154,7 @@ Requests ongoing tracing status.
1115411154
@end deffn
1115511155

1115611156
@deffn {Command} {esp apptrace} (dump file://<outfile>)
11157-
Dumps tracing data from target buffer. It can be usefull to dump the latest data
11157+
Dumps tracing data from target buffer. It can be useful to dump the latest data
1115811158
buffered on target for post-mortem analysis. For example when target starts tracing automatically
1115911159
w/o OpenOCD command and keeps only the latest data window which fit into the buffer.
1116011160
@uref{https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/app_trace.html#application-level-tracing-library, application level tracing}.

src/target/espressif/esp32_apptrace.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ int esp32_apptrace_dest_init(struct esp32_apptrace_dest dest[], const char *dest
318318
return i;
319319
}
320320

321-
int esp32_apptrace_dest_cleanup(struct esp32_apptrace_dest dest[], int max_dests)
321+
int esp32_apptrace_dest_cleanup(struct esp32_apptrace_dest dest[], unsigned int max_dests)
322322
{
323-
for (int i = 0; i < max_dests; i++) {
323+
for (unsigned int i = 0; i < max_dests; i++) {
324324
if (dest[i].clean && dest[i].priv) {
325325
int res = dest[i].clean(dest[i].priv);
326326
dest[i].priv = NULL;
@@ -511,7 +511,9 @@ int esp32_apptrace_cmd_ctx_init(struct target *target, struct esp32_apptrace_cmd
511511

512512
cmd_ctx->running = 1;
513513
if (cmd_ctx->mode != ESP_APPTRACE_CMD_MODE_SYNC) {
514-
int res = target_register_timer_callback(esp32_apptrace_data_processor, 0, TARGET_TIMER_TYPE_PERIODIC,
514+
int res = target_register_timer_callback(esp32_apptrace_data_processor,
515+
0,
516+
TARGET_TIMER_TYPE_PERIODIC,
515517
cmd_ctx);
516518
if (res != ERROR_OK) {
517519
LOG_ERROR("Failed to start trace data timer callback (%d)!", res);
@@ -621,12 +623,11 @@ static int esp32_apptrace_cmd_init(struct target *target,
621623
cmd_ctx->stop_tmo = -1.0; /* infinite */
622624
cmd_data->max_len = UINT32_MAX;
623625
cmd_data->poll_period = 0 /*ms*/;
624-
if (argc > 1) {
626+
if (argc > 1)
625627
/* parse remaining args */
626628
esp32_apptrace_cmd_args_parse(cmd_ctx, cmd_data, &argv[1], argc - 1);
627-
}
628-
LOG_USER(
629-
"App trace params: from %d cores, size %" PRId32 " bytes, stop_tmo %g s, poll period %" PRId32
629+
630+
LOG_USER("App trace params: from %d cores, size %" PRId32 " bytes, stop_tmo %g s, poll period %" PRId32
630631
" ms, wait_rst %d, skip %" PRId32 " bytes", cmd_ctx->cores_num,
631632
cmd_data->max_len,
632633
cmd_ctx->stop_tmo,
@@ -880,7 +881,7 @@ int esp_apptrace_usr_block_write(const struct esp32_apptrace_hw *hw, struct targ
880881
}
881882

882883
return hw->buffs_write(target,
883-
sizeof(buf_sz) / sizeof(buf_sz[0]),
884+
ARRAY_SIZE(buf_sz),
884885
buf_sz,
885886
bufs,
886887
block_id,
@@ -956,7 +957,7 @@ static int esp32_apptrace_process_data(struct esp32_apptrace_cmd_ctx *ctx,
956957
if (cmd_data->data_dest.log_progress)
957958
LOG_USER("%" PRId32 " ", ctx->tot_len);
958959
/* check for stop condition */
959-
if ((ctx->tot_len > cmd_data->skip_len) && (ctx->tot_len - cmd_data->skip_len >= cmd_data->max_len)) {
960+
if (ctx->tot_len > cmd_data->skip_len && (ctx->tot_len - cmd_data->skip_len >= cmd_data->max_len)) {
960961
ctx->running = 0;
961962
if (duration_measure(&ctx->read_time) != 0) {
962963
LOG_ERROR("Failed to stop trace read time measure!");
@@ -1102,7 +1103,7 @@ static int esp32_apptrace_poll(void *priv)
11021103
/* LOG_DEBUG("Block %d (%d bytes) on target (%s)!", target_state[0].block_id,
11031104
* target_state[0].data_len, target_name(ctx->cpus[0])); */
11041105
if (fired_target_num == UINT32_MAX) {
1105-
/* no data has been received, but block could be switched due to the data transfered
1106+
/* no data has been received, but block could be switched due to the data transferred
11061107
* from host to target */
11071108
if (ctx->cores_num > 1) {
11081109
uint32_t max_block_id = 0, min_block_id = ctx->hw->max_block_id;
@@ -1621,7 +1622,7 @@ int esp32_cmd_apptrace_generic(struct target *target, int mode, const char **arg
16211622
}
16221623
s_at_cmd_ctx.stop_tmo = 0.01; /* use small stop tmo */
16231624
s_at_cmd_ctx.process_data = esp32_apptrace_process_data;
1624-
/* check for exit signal and comand completion */
1625+
/* check for exit signal and command completion */
16251626
while (!openocd_is_shutdown_pending() && s_at_cmd_ctx.running) {
16261627
res = esp32_apptrace_poll(&s_at_cmd_ctx);
16271628
if (res != ERROR_OK) {

src/target/espressif/esp32_apptrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void esp32_apptrace_cmd_args_parse(struct esp32_apptrace_cmd_ctx *cmd_ctx,
114114
const char **argv,
115115
int argc);
116116
int esp32_apptrace_dest_init(struct esp32_apptrace_dest dest[], const char *dest_paths[], unsigned int max_dests);
117-
int esp32_apptrace_dest_cleanup(struct esp32_apptrace_dest dest[], int max_dests);
117+
int esp32_apptrace_dest_cleanup(struct esp32_apptrace_dest dest[], unsigned int max_dests);
118118
int esp_apptrace_usr_block_write(const struct esp32_apptrace_hw *hw, struct target *target,
119119
uint32_t block_id,
120120
const uint8_t *data,

src/target/espressif/esp32_sysview.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ int esp32_sysview_cmd_init(struct target *target,
8383
{
8484
int res;
8585
struct esp32_sysview_cmd_data *cmd_data;
86-
int core_num = cmd_ctx->cores_num;
8786

8887
if (argc < 1) {
8988
LOG_ERROR("Not enough args! Need trace data destination!");
@@ -94,6 +93,8 @@ int esp32_sysview_cmd_init(struct target *target,
9493
if (res)
9594
return res;
9695

96+
int core_num = cmd_ctx->cores_num;
97+
9798
if (!mcore_format && argc < core_num) {
9899
LOG_ERROR("Not enough args! Need %d trace data destinations!", core_num);
99100
res = ERROR_FAIL;

src/target/espressif/esp_xtensa_apptrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static int esp_xtensa_apptrace_data_reverse_read(struct xtensa *xtensa,
125125
if (res != ERROR_OK)
126126
return res;
127127
}
128-
for (unsigned int i = size / 4; i > 0; i--) {
128+
for (unsigned int i = size / 4; i != 0; i--) {
129129
res = xtensa_queue_dbg_reg_read(xtensa, XDMREG_TRAXDATA, &buffer[(i - 1) * 4]);
130130
if (res != ERROR_OK)
131131
return res;

0 commit comments

Comments
 (0)