Merge branch 'feature/twdt_prints_backtrace' into 'master'
Add Task Watchdog backtrace printing Closes IDF-1072 See merge request espressif/esp-idf!8136
This commit is contained in:
commit
d013105256
4 changed files with 42 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "esp_intr_alloc.h"
|
#include "esp_intr_alloc.h"
|
||||||
|
#include "esp_debug_helpers.h"
|
||||||
|
|
||||||
#include "esp32/rom/ets_sys.h"
|
#include "esp32/rom/ets_sys.h"
|
||||||
#include "esp32/rom/uart.h"
|
#include "esp32/rom/uart.h"
|
||||||
|
@ -34,6 +35,7 @@
|
||||||
|
|
||||||
#define REASON_YIELD BIT(0)
|
#define REASON_YIELD BIT(0)
|
||||||
#define REASON_FREQ_SWITCH BIT(1)
|
#define REASON_FREQ_SWITCH BIT(1)
|
||||||
|
#define REASON_PRINT_BACKTRACE BIT(2)
|
||||||
|
|
||||||
static portMUX_TYPE reason_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
static portMUX_TYPE reason_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||||
static volatile uint32_t reason[ portNUM_PROCESSORS ];
|
static volatile uint32_t reason[ portNUM_PROCESSORS ];
|
||||||
|
@ -74,6 +76,9 @@ static void IRAM_ATTR esp_crosscore_isr(void *arg) {
|
||||||
* to allow DFS features without the extra latency of the ISR hook.
|
* to allow DFS features without the extra latency of the ISR hook.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
if (my_reason_val & REASON_PRINT_BACKTRACE) {
|
||||||
|
esp_backtrace_print(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialize the crosscore interrupt on this core. Call this once
|
//Initialize the crosscore interrupt on this core. Call this once
|
||||||
|
@ -115,3 +120,7 @@ void IRAM_ATTR esp_crosscore_int_send_freq_switch(int core_id)
|
||||||
esp_crosscore_int_send(core_id, REASON_FREQ_SWITCH);
|
esp_crosscore_int_send(core_id, REASON_FREQ_SWITCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_crosscore_int_send_print_backtrace(int core_id)
|
||||||
|
{
|
||||||
|
esp_crosscore_int_send(core_id, REASON_PRINT_BACKTRACE);
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "esp_intr_alloc.h"
|
#include "esp_intr_alloc.h"
|
||||||
|
#include "esp_debug_helpers.h"
|
||||||
|
|
||||||
#include "esp32s2/rom/ets_sys.h"
|
#include "esp32s2/rom/ets_sys.h"
|
||||||
#include "esp32s2/rom/uart.h"
|
#include "esp32s2/rom/uart.h"
|
||||||
|
@ -35,6 +36,7 @@
|
||||||
|
|
||||||
#define REASON_YIELD BIT(0)
|
#define REASON_YIELD BIT(0)
|
||||||
#define REASON_FREQ_SWITCH BIT(1)
|
#define REASON_FREQ_SWITCH BIT(1)
|
||||||
|
#define REASON_PRINT_BACKTRACE BIT(2)
|
||||||
|
|
||||||
static portMUX_TYPE reason_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
static portMUX_TYPE reason_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||||
static volatile uint32_t reason;
|
static volatile uint32_t reason;
|
||||||
|
@ -71,6 +73,9 @@ static void IRAM_ATTR esp_crosscore_isr(void *arg) {
|
||||||
* to allow DFS features without the extra latency of the ISR hook.
|
* to allow DFS features without the extra latency of the ISR hook.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
if (my_reason_val & REASON_PRINT_BACKTRACE) {
|
||||||
|
esp_backtrace_print(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialize the crosscore interrupt on this core.
|
//Initialize the crosscore interrupt on this core.
|
||||||
|
@ -101,3 +106,7 @@ void IRAM_ATTR esp_crosscore_int_send_freq_switch(int core_id)
|
||||||
esp_crosscore_int_send(core_id, REASON_FREQ_SWITCH);
|
esp_crosscore_int_send(core_id, REASON_FREQ_SWITCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_crosscore_int_send_print_backtrace(int core_id)
|
||||||
|
{
|
||||||
|
esp_crosscore_int_send(core_id, REASON_PRINT_BACKTRACE);
|
||||||
|
}
|
|
@ -51,4 +51,14 @@ void esp_crosscore_int_send_yield(int core_id);
|
||||||
*/
|
*/
|
||||||
void esp_crosscore_int_send_freq_switch(int core_id);
|
void esp_crosscore_int_send_freq_switch(int core_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an interrupt to a CPU indicating it should print its current backtrace
|
||||||
|
*
|
||||||
|
* This is use internally by the Task Watchdog to dump the backtrace of the
|
||||||
|
* opposite core and should not be called from application code.
|
||||||
|
*
|
||||||
|
* @param core_id Core that should print its backtrace
|
||||||
|
*/
|
||||||
|
void esp_crosscore_int_send_print_backtrace(int core_id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "esp_intr_alloc.h"
|
#include "esp_intr_alloc.h"
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
|
#include "esp_debug_helpers.h"
|
||||||
#include "esp_freertos_hooks.h"
|
#include "esp_freertos_hooks.h"
|
||||||
#include "soc/timer_periph.h"
|
#include "soc/timer_periph.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
@ -33,6 +34,7 @@
|
||||||
#include "driver/periph_ctrl.h"
|
#include "driver/periph_ctrl.h"
|
||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
#include "esp_private/system_internal.h"
|
#include "esp_private/system_internal.h"
|
||||||
|
#include "esp_private/crosscore_int.h"
|
||||||
#include "hal/timer_types.h"
|
#include "hal/timer_types.h"
|
||||||
#include "hal/wdt_hal.h"
|
#include "hal/wdt_hal.h"
|
||||||
|
|
||||||
|
@ -172,11 +174,22 @@ static void task_wdt_isr(void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_task_wdt_isr_user_handler();
|
esp_task_wdt_isr_user_handler();
|
||||||
|
|
||||||
if (twdt_config->panic){ //Trigger Panic if configured to do so
|
if (twdt_config->panic){ //Trigger Panic if configured to do so
|
||||||
ESP_EARLY_LOGE(TAG, "Aborting.");
|
ESP_EARLY_LOGE(TAG, "Aborting.");
|
||||||
portEXIT_CRITICAL_ISR(&twdt_spinlock);
|
portEXIT_CRITICAL_ISR(&twdt_spinlock);
|
||||||
esp_reset_reason_set_hint(ESP_RST_TASK_WDT);
|
esp_reset_reason_set_hint(ESP_RST_TASK_WDT);
|
||||||
abort();
|
abort();
|
||||||
|
} else {
|
||||||
|
int current_core = xPortGetCoreID();
|
||||||
|
//Print backtrace of current core
|
||||||
|
ESP_EARLY_LOGE(TAG, "Print CPU %d (current core) backtrace", current_core);
|
||||||
|
esp_backtrace_print(100);
|
||||||
|
#if !CONFIG_FREERTOS_UNICORE
|
||||||
|
//Print backtrace of other core
|
||||||
|
ESP_EARLY_LOGE(TAG, "Print CPU %d backtrace", !current_core);
|
||||||
|
esp_crosscore_int_send_print_backtrace(!current_core);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
portEXIT_CRITICAL_ISR(&twdt_spinlock);
|
portEXIT_CRITICAL_ISR(&twdt_spinlock);
|
||||||
|
|
Loading…
Reference in a new issue