Skip to content

Commit a28f717

Browse files
committed
esp/apptrace: Select HW interface basng on target GDB arch API
1 parent ed17035 commit a28f717

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/target/esp32_apptrace.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,21 @@ int esp32_apptrace_cmd_ctx_init(struct target *target,
555555
* TODO: remove that dependency */
556556
assert(cmd_ctx->cores_num <= ESP32_APPTRACE_MAX_CORES_NUM && "Too many cores number!");
557557

558-
/* TODO: find better way to detect chip arch */
559-
if (strncmp(target_type_name(target), "esp32c3", 7) == 0) {
560-
cmd_ctx->hw = target_to_esp_riscv(target)->apptrace.hw;
561-
cmd_ctx->algo_hw = target_to_esp_riscv(target)->algo_hw;
558+
const char *arch = target_get_gdb_arch(target);
559+
if (arch != NULL) {
560+
if (strncmp(arch, "riscv", 5) == 0) {
561+
cmd_ctx->hw = target_to_esp_riscv(target)->apptrace.hw;
562+
cmd_ctx->algo_hw = target_to_esp_riscv(target)->algo_hw;
563+
} else if (strncmp(arch, "xtensa", 6) == 0) {
564+
cmd_ctx->hw = target_to_esp_xtensa(target)->apptrace.hw;
565+
cmd_ctx->algo_hw = target_to_esp_xtensa(target)->algo_hw;
566+
} else {
567+
LOG_ERROR("Unsupported target arch '%s'!", arch);
568+
return ERROR_FAIL;
569+
}
562570
} else {
563-
cmd_ctx->hw = target_to_esp_xtensa(target)->apptrace.hw;
564-
cmd_ctx->algo_hw = target_to_esp_xtensa(target)->algo_hw;
571+
LOG_ERROR("Unsupported target arch '%s'!", arch);
572+
return ERROR_FAIL;
565573
}
566574

567575
cmd_ctx->max_trace_block_sz = cmd_ctx->hw->max_block_size_get(cmd_ctx->cpus[0]);

0 commit comments

Comments
 (0)