Skip to content

Commit

Permalink
esp32: Tries to select non-stalled CPU for any debug reason
Browse files Browse the repository at this point in the history
  • Loading branch information
gerekon committed Jul 2, 2019
1 parent 805964f commit 93468be
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/target/esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1851,12 +1851,6 @@ static int xtensa_poll(struct target *target)
esp32->active_cpu = k-1;
}
}
// Handle special case when halt is send to the stalled active core.
// We need to switch focus to another core in order to be able to run algorithms.
if (target->debug_reason == DBG_REASON_DBGRQ && (dsr[esp32->active_cpu] & OCDDSR_RUNSTALLSAMPLE)) {
LOG_DEBUG("Received debug request on stalled active core %d. Switch active core.", (int)esp32->active_cpu);
esp32->active_cpu = esp32->active_cpu == ESP32_PRO_CPU_ID ? ESP32_APP_CPU_ID : ESP32_PRO_CPU_ID;
}
for (size_t k = esp32->configured_cores_num; k > 0; k--) {
if (halt_cause[k-1] & DEBUGCAUSE_IC)
{
Expand All @@ -1879,6 +1873,16 @@ static int xtensa_poll(struct target *target)
esp32->active_cpu = k-1;
}
}
// Handle special case when halt is send to the stalled active core.
// We need to switch focus to another core in order to be able to run algorithms.
if (dsr[esp32->active_cpu] & OCDDSR_RUNSTALLSAMPLE) {
LOG_WARNING("Received debug request on stalled active core %d.", (int)esp32->active_cpu);
int other_core = esp32->active_cpu == ESP32_PRO_CPU_ID ? ESP32_APP_CPU_ID : ESP32_PRO_CPU_ID;
if ((dsr[other_core] & OCDDSR_RUNSTALLSAMPLE) == 0) {
LOG_DEBUG("Switch active core to %d.", other_core);
esp32->active_cpu = other_core;
}
}
if (esp32->configured_cores_num > 1) {
LOG_INFO("Target halted. PRO_CPU: PC=0x%08X %s APP_CPU: PC=0x%08X %s",
esp108_reg_get(&esp32->core_caches[0]->reg_list[XT_REG_IDX_PC]),
Expand Down

0 comments on commit 93468be

Please sign in to comment.