esp32: don’t reset APP CPU if it was already reset by OpenOCD
When ‘reset halt’ command is executed, OpenOCD will take the APP CPU out of reset and enable the clock. At this point, user can set a breakpoint on code which will run on APP CPU. Previously, app startup code would do another reset of APP CPU, thereby removing any breakpoints which may have been set. This change makes APP CPU reset conditional on DPORT_APPCPU_CLKGATE_EN bit, which is 0 by default but is set to 1 by OpenOCD after reset.
This commit is contained in:
parent
e7db29b2a8
commit
f327a9b1cf
1 changed files with 10 additions and 5 deletions
|
@ -142,11 +142,16 @@ void IRAM_ATTR call_start_cpu0()
|
||||||
Cache_Flush(1);
|
Cache_Flush(1);
|
||||||
Cache_Read_Enable(1);
|
Cache_Read_Enable(1);
|
||||||
esp_cpu_unstall(1);
|
esp_cpu_unstall(1);
|
||||||
//Enable clock gating and reset the app cpu.
|
// Enable clock and reset APP CPU. Note that OpenOCD may have already
|
||||||
DPORT_SET_PERI_REG_MASK(DPORT_APPCPU_CTRL_B_REG, DPORT_APPCPU_CLKGATE_EN);
|
// enabled clock and taken APP CPU out of reset. In this case don't reset
|
||||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_APPCPU_CTRL_C_REG, DPORT_APPCPU_RUNSTALL);
|
// APP CPU again, as that will clear the breakpoints which may have already
|
||||||
DPORT_SET_PERI_REG_MASK(DPORT_APPCPU_CTRL_A_REG, DPORT_APPCPU_RESETTING);
|
// been set.
|
||||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_APPCPU_CTRL_A_REG, DPORT_APPCPU_RESETTING);
|
if (!DPORT_GET_PERI_REG_MASK(DPORT_APPCPU_CTRL_B_REG, DPORT_APPCPU_CLKGATE_EN)) {
|
||||||
|
DPORT_SET_PERI_REG_MASK(DPORT_APPCPU_CTRL_B_REG, DPORT_APPCPU_CLKGATE_EN);
|
||||||
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_APPCPU_CTRL_C_REG, DPORT_APPCPU_RUNSTALL);
|
||||||
|
DPORT_SET_PERI_REG_MASK(DPORT_APPCPU_CTRL_A_REG, DPORT_APPCPU_RESETTING);
|
||||||
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_APPCPU_CTRL_A_REG, DPORT_APPCPU_RESETTING);
|
||||||
|
}
|
||||||
ets_set_appcpu_boot_addr((uint32_t)call_start_cpu1);
|
ets_set_appcpu_boot_addr((uint32_t)call_start_cpu1);
|
||||||
|
|
||||||
while (!app_cpu_started) {
|
while (!app_cpu_started) {
|
||||||
|
|
Loading…
Reference in a new issue