Skip to content

Commit f8db83e

Browse files
committed
target/esp_riscv: halt other cores before running bp/wp set commands
1 parent c333c45 commit f8db83e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/target/espressif/esp_riscv.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,26 @@ int esp_riscv_semihosting(struct target *target)
346346
struct esp_riscv_common *esp_riscv = target_to_esp_riscv(target);
347347
struct semihosting *semihosting = target->semihosting;
348348

349+
/*
350+
If a bp/wp set request comes from Core1, the other cores may continue running.
351+
We need to ensure that all harts are in a halted state.
352+
*/
353+
if (target->smp && (semihosting->op == ESP_SEMIHOSTING_SYS_BREAKPOINT_SET ||
354+
semihosting->op == ESP_SEMIHOSTING_SYS_WATCHPOINT_SET)) {
355+
struct target_list *head;
356+
foreach_smp_target(head, target->smp_targets) {
357+
struct target *curr = head->target;
358+
if (curr->state != TARGET_HALTED) {
359+
LOG_TARGET_DEBUG(curr, "Target must be in halted state. Try to halt it");
360+
res = riscv_halt(curr);
361+
if (res != ERROR_OK)
362+
return res;
363+
/* Here all halts are in the halted state. Resume-all will be handled in riscv_semihosting() return */
364+
break;
365+
}
366+
}
367+
}
368+
349369
switch (semihosting->op) {
350370
case ESP_SEMIHOSTING_SYS_APPTRACE_INIT:
351371
res = esp_riscv_apptrace_info_init(target, semihosting->param, NULL);
@@ -374,7 +394,7 @@ int esp_riscv_semihosting(struct target *target)
374394
return ERROR_FAIL;
375395
}
376396
int set = semihosting_get_field(target,
377-
ESP_RISCV_SET_WATCHPOINT_ARG_SET,
397+
ESP_RISCV_SET_BREAKPOINT_ARG_SET,
378398
fields);
379399
if (set) {
380400
if (esp_riscv->target_bp_addr[id]) {

0 commit comments

Comments
 (0)