Select one of the symbols to view example projects that use it.
 
Outline
#include <stdlib.h>
#include <string.h>
#include "esp_macros.h"
#include "esp_err.h"
#include "esp_attr.h"
#include "esp_compiler.h"
#include "esp_private/system_internal.h"
#include "esp_private/usb_console.h"
#include "esp_cpu.h"
#include "soc/rtc.h"
#include "hal/timer_hal.h"
#include "hal/wdt_types.h"
#include "hal/wdt_hal.h"
#include "hal/mwdt_ll.h"
#include "esp_private/esp_int_wdt.h"
#include "esp_private/panic_internal.h"
#include "port/panic_funcs.h"
#include "esp_rom_sys.h"
#include "sdkconfig.h"
#define WITH_ELF_SHA256
#include "esp_app_desc.h"
#include "esp_core_dump.h"
#include "esp_app_trace.h"
#include "SEGGER_RTT.h"
#define APPTRACE_ONPANIC_HOST_FLUSH_TMO
#define APPTRACE_ONPANIC_HOST_FLUSH_TMO
#include "hal/uart_hal.h"
#include "esp_gdbstub.h"
#include "hal/usb_serial_jtag_ll.h"
#include "xtensa/semihosting.h"
#include "riscv/semihosting.h"
#define ESP_SEMIHOSTING_SYS_PANIC_REASON
#define MWDT_DEFAULT_TICKS_PER_US
g_panic_abort
g_panic_abort_details
rtc_wdt_ctx
s_panic_uart
panic_print_char_uart(const char)
#define USBSERIAL_TIMEOUT_MAX_US
panic_print_char(const char)
panic_print_str(const char *)
panic_print_hex(int)
panic_print_dec(int)
esp_panic_handler_reconfigure_wdts(uint32_t)
disable_all_wdts()
print_abort_details(const void *)
esp_panic_handler(panic_info_t *)
panic_abort(const char *)
esp_reset_reason_set_hint(esp_reset_reason_t)
esp_reset_reason_get_hint()
Files
ESP-IDF
components
app_trace
app_update
bootloader_support
bt
cmock
console
cxx
driver
efuse
esp_adc
esp_app_format
esp_bootloader_format
esp_coex
esp_common
esp_driver_ana_cmpr
esp_driver_cam
esp_driver_dac
esp_driver_gpio
esp_driver_gptimer
esp_driver_i2c
esp_driver_i2s
esp_driver_jpeg
esp_driver_ledc
esp_driver_mcpwm
esp_driver_parlio
esp_driver_pcnt
esp_driver_rmt
esp_driver_sdio
esp_driver_sdm
esp_driver_sdmmc
esp_driver_sdspi
esp_driver_spi
esp_driver_tsens
esp_driver_uart
esp_driver_usb_serial_jtag
esp_eth
esp_event
esp_gdbstub
esp_hid
esp_http_client
esp_http_server
esp_https_ota
esp_https_server
esp_hw_support
esp_lcd
esp_local_ctrl
esp_mm
esp_netif
esp_partition
esp_phy
esp_pm
esp_psram
esp_ringbuf
esp_rom
esp_security
esp_system
include
port
task_wdt
esp_timer
esp_vfs_console
esp_wifi
esp-tls
espcoredump
hal
heap
http_parser
ieee802154
log
mqtt
newlib
nvs_flash
nvs_sec_provider
openthread
perfmon
protobuf-c
protocomm
pthread
rt
sdmmc
soc
spi_flash
spiffs
tcp_transport
ulp
unity
vfs
wear_levelling
wifi_provisioning
wpa_supplicant
xtensa
examples
lwIP
FreeRTOS
cJSON
mbedTLS
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/esp_system/panic.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #include <stdlib.h> #include <string.h> #include "esp_macros.h" #include "esp_err.h" #include "esp_attr.h" #include "esp_compiler.h" #include "esp_private/system_internal.h" #include "esp_private/usb_console.h" #include "esp_cpu.h" #include "soc/rtc.h" #include "hal/timer_hal.h" #include "hal/wdt_types.h" #include "hal/wdt_hal.h" #include "hal/mwdt_ll.h" #include "esp_private/esp_int_wdt.h" #include "esp_private/panic_internal.h" #include "port/panic_funcs.h" #include "esp_rom_sys.h" #include "sdkconfig.h"19 includes #if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT #if __has_include("esp_app_desc.h") #define WITH_ELF_SHA256 #include "esp_app_desc.h"/* ... */ #endif/* ... */ #endif // CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT #if CONFIG_ESP_COREDUMP_ENABLE #include "esp_core_dump.h" #endif #if CONFIG_APPTRACE_ENABLE #include "esp_app_trace.h" #if CONFIG_APPTRACE_SV_ENABLE #include "SEGGER_RTT.h" #endif #if CONFIG_APPTRACE_ONPANIC_HOST_FLUSH_TMO == -1 #define APPTRACE_ONPANIC_HOST_FLUSH_TMO ESP_APPTRACE_TMO_INFINITE #else #define APPTRACE_ONPANIC_HOST_FLUSH_TMO (1000*CONFIG_APPTRACE_ONPANIC_HOST_FLUSH_TMO) #endif/* ... */ #endif // CONFIG_APPTRACE_ENABLE #if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT #include "hal/uart_hal.h" #endif #if CONFIG_ESP_SYSTEM_PANIC_GDBSTUB #include "esp_gdbstub.h" #endif #if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG #include "hal/usb_serial_jtag_ll.h" #endif #ifdef __XTENSA__ #include "xtensa/semihosting.h" #elif __riscv #include "riscv/semihosting.h" #endif #define ESP_SEMIHOSTING_SYS_PANIC_REASON 0x116 #define MWDT_DEFAULT_TICKS_PER_US 500 bool g_panic_abort = false; char *g_panic_abort_details = NULL; static wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT(); #if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT #if CONFIG_ESP_CONSOLE_UART static uart_hal_context_t s_panic_uart = { .dev = CONFIG_ESP_CONSOLE_UART_NUM == 0 ? &UART0 :&UART1 }; static void panic_print_char_uart(const char c) { uint32_t sz = 0; while (!uart_hal_get_txfifo_len(&s_panic_uart)); uart_hal_write_txfifo(&s_panic_uart, (uint8_t *) &c, 1, &sz); }{ ... } #endif/* ... */ // CONFIG_ESP_CONSOLE_UART #if CONFIG_ESP_CONSOLE_USB_CDC static void panic_print_char_usb_cdc(const char c) { esp_usb_console_write_buf(&c, 1); /* result ignored */ }{...} /* ... */#endif // CONFIG_ESP_CONSOLE_USB_CDC #if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG //Timeout; if there's no host listening, the txfifo won't ever //be writable after the first packet. #define USBSERIAL_TIMEOUT_MAX_US 50000 static int s_usbserial_timeout = 0; static void panic_print_char_usb_serial_jtag(const char c) { while (!usb_serial_jtag_ll_txfifo_writable() && s_usbserial_timeout < (USBSERIAL_TIMEOUT_MAX_US / 100)) { esp_rom_delay_us(100); s_usbserial_timeout++; }{...} if (usb_serial_jtag_ll_txfifo_writable()) { usb_serial_jtag_ll_write_txfifo((const uint8_t *)&c, 1); s_usbserial_timeout = 0; }{...} }{...} /* ... */#endif //CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG void panic_print_char(const char c) { #if CONFIG_ESP_CONSOLE_UART panic_print_char_uart(c); #endif #if CONFIG_ESP_CONSOLE_USB_CDC panic_print_char_usb_cdc(c); #endif #if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG panic_print_char_usb_serial_jtag(c); #endif }{ ... } void panic_print_str(const char *str) { for (int i = 0; str[i] != 0; i++) { panic_print_char(str[i]); }{...} }{ ... } void panic_print_hex(int h) { int x; int c; // Does not print '0x', only the digits (8 digits to print) for (x = 0; x < 8; x++) { c = (h >> 28) & 0xf; // extract the leftmost byte if (c < 10) { panic_print_char('0' + c); }{...} else { panic_print_char('a' + c - 10); }{...} h <<= 4; // move the 2nd leftmost byte to the left, to be extracted next }{...} }{ ... } void panic_print_dec(int d) { // can print at most 2 digits! int n1, n2; n1 = d % 10; // extract ones digit n2 = d / 10; // extract tens digit if (n2 == 0) { panic_print_char(' '); }{...} else { panic_print_char(n2 + '0'); }{...} panic_print_char(n1 + '0'); }{ ... } #endif/* ... */ // CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT /* If watchdogs are enabled, the panic handler runs the risk of getting aborted pre-emptively because an overzealous watchdog decides to reset it. On the other hand, if we disable all watchdogs, we run the risk of somehow halting in the panic handler and not resetting. That is why this routine kills all watchdogs except the timer group 0 watchdog, and it reconfigures that to reset the chip after one second. We have to do this before we do anything that might cause issues in the WDT interrupt handlers, for example stalling the other core on ESP32 may cause the ESP32_ECO3_CACHE_LOCK_FIX handler to get stuck. *//* ... */ void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms) { wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; #if SOC_TIMER_GROUPS >= 2 // IDF-3825 wdt_hal_context_t wdt1_context = {.inst = WDT_MWDT1, .mwdt_dev = &TIMERG1};/* ... */ #endif //Todo: Refactor to use Interrupt or Task Watchdog API, and a system level WDT context //Reconfigure TWDT (Timer Group 0) wdt_hal_init(&wdt0_context, WDT_MWDT0, MWDT_LL_DEFAULT_CLK_PRESCALER, false); //Prescaler: wdt counts in ticks of TG0_WDT_TICK_US wdt_hal_write_protect_disable(&wdt0_context); wdt_hal_config_stage(&wdt0_context, 0, timeout_ms * 1000 / MWDT_DEFAULT_TICKS_PER_US, WDT_STAGE_ACTION_RESET_SYSTEM); //1 second before reset wdt_hal_enable(&wdt0_context); wdt_hal_write_protect_enable(&wdt0_context); #if SOC_TIMER_GROUPS >= 2 //Disable IWDT (Timer Group 1) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context);/* ... */ #endif }{ ... } /* This disables all the watchdogs for when we call the gdbstub. *//* ... */ static inline void disable_all_wdts(void) { wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; #if SOC_TIMER_GROUPS >= 2 wdt_hal_context_t wdt1_context = {.inst = WDT_MWDT1, .mwdt_dev = &TIMERG1}; #endif //Todo: Refactor to use Interrupt or Task Watchdog API, and a system level WDT context //Task WDT is the Main Watchdog Timer of Timer Group 0 wdt_hal_write_protect_disable(&wdt0_context); wdt_hal_disable(&wdt0_context); wdt_hal_write_protect_enable(&wdt0_context); #if SOC_TIMER_GROUPS >= 2 //Interrupt WDT is the Main Watchdog Timer of Timer Group 1 wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context);/* ... */ #endif }{ ... } static void print_abort_details(const void *f) { panic_print_str(g_panic_abort_details); }{ ... } // Control arrives from chip-specific panic handler, environment prepared for // the 'main' logic of panic handling. This means that chip-specific stuff have // already been done, and panic_info_t has been filled. void esp_panic_handler(panic_info_t *info) { // The port-level panic handler has already called this, but call it again // to reset the TG0WDT period esp_panic_handler_reconfigure_wdts(1000); // If the exception was due to an abort, override some of the panic info if (g_panic_abort) { info->description = NULL; info->details = g_panic_abort_details ? print_abort_details : NULL; info->reason = NULL; info->exception = PANIC_EXCEPTION_ABORT; }{...} /* * For any supported chip, the panic handler prints the contents of panic_info_t in the following format: * * * Guru Meditation Error: Core <core> (<exception>). <description> * <details> * * <state> * * <elf_info> * * * ---------------------------------------------------------------------------------------- * core - core where exception was triggered * exception - what kind of exception occurred * description - a short description regarding the exception that occurred * details - more details about the exception * state - processor state like register contents, and backtrace * elf_info - details about the image currently running * * NULL fields in panic_info_t are not printed. * * *//* ... */ if (info->reason) { panic_print_str("Guru Meditation Error: Core "); panic_print_dec(info->core); panic_print_str(" panic'ed ("); panic_print_str(info->reason); panic_print_str("). "); }{...} if (info->description) { panic_print_str(info->description); }{...} panic_print_str("\r\n"); PANIC_INFO_DUMP(info, details); panic_print_str("\r\n"); // If on-chip-debugger is attached, and system is configured to be aware of this, // then only print up to details. Users should be able to probe for the other information // in debug mode. #if CONFIG_ESP_DEBUG_OCDAWARE if (esp_cpu_dbgr_is_attached()) { char *panic_reason_str = NULL; if (info->pseudo_excause) { panic_reason_str = (char *)info->reason; }{...} else if (g_panic_abort) { panic_reason_str = g_panic_abort_details; }{...} if (panic_reason_str) { /* OpenOCD will print the halt cause when target is stopped at the below breakpoint (info->addr) */ long args[] = {(long)panic_reason_str, strlen(panic_reason_str)}; semihosting_call_noerrno(ESP_SEMIHOSTING_SYS_PANIC_REASON, args); }{...} panic_print_str("Setting breakpoint at 0x"); panic_print_hex((uint32_t)info->addr); panic_print_str(" and returning...\r\n"); disable_all_wdts(); #if CONFIG_APPTRACE_ENABLE #if CONFIG_APPTRACE_SV_ENABLE SEGGER_RTT_ESP_FlushNoLock(CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH, APPTRACE_ONPANIC_HOST_FLUSH_TMO); #else esp_apptrace_flush_nolock(ESP_APPTRACE_DEST_TRAX, CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH, APPTRACE_ONPANIC_HOST_FLUSH_TMO);/* ... */ #endif/* ... */ #endif esp_cpu_set_breakpoint(0, info->addr); // use breakpoint 0 return; }{...} #endif/* ... */ //CONFIG_ESP_DEBUG_OCDAWARE // start panic WDT to restart system if we hang in this handler if (!wdt_hal_is_enabled(&rtc_wdt_ctx)) { wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); uint32_t stage_timeout_ticks = (uint32_t)(7000ULL * rtc_clk_slow_freq_get_hz() / 1000ULL); wdt_hal_write_protect_disable(&rtc_wdt_ctx); wdt_hal_config_stage(&rtc_wdt_ctx, WDT_STAGE0, stage_timeout_ticks, WDT_STAGE_ACTION_RESET_SYSTEM); // 64KB of core dump data (stacks of about 30 tasks) will produce ~85KB base64 data. // @ 115200 UART speed it will take more than 6 sec to print them out. wdt_hal_enable(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); }{...} esp_panic_handler_reconfigure_wdts(1000); // Restart WDT again PANIC_INFO_DUMP(info, state); panic_print_str("\r\n"); /* No matter if we come here from abort or an exception, this variable must be reset. * Else, any exception/error occurring during the current panic handler would considered * an abort. Do this after PANIC_INFO_DUMP(info, state) as it also checks this variable. * For example, if coredump triggers a stack overflow and this variable is not reset, * the second panic would be still be marked as the result of an abort, even the previous * message reason would be kept. *//* ... */ g_panic_abort = false; #ifdef WITH_ELF_SHA256 panic_print_str("\r\nELF file SHA256: "); panic_print_str(esp_app_get_elf_sha256_str()); panic_print_str("\r\n");/* ... */ #endif // WITH_ELF_SHA256 panic_print_str("\r\n"); #if CONFIG_APPTRACE_ENABLE disable_all_wdts(); #if CONFIG_APPTRACE_SV_ENABLE SEGGER_RTT_ESP_FlushNoLock(CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH, APPTRACE_ONPANIC_HOST_FLUSH_TMO); #else esp_apptrace_flush_nolock(ESP_APPTRACE_DEST_TRAX, CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH, APPTRACE_ONPANIC_HOST_FLUSH_TMO);/* ... */ #endif esp_panic_handler_reconfigure_wdts(1000); // restore WDT config/* ... */ #endif // CONFIG_APPTRACE_ENABLE #if CONFIG_ESP_COREDUMP_ENABLE static bool s_dumping_core; if (s_dumping_core) { panic_print_str("Re-entered core dump! Exception happened during core dump!\r\n"); }{...} else { disable_all_wdts(); s_dumping_core = true; esp_core_dump_write(info); s_dumping_core = false; esp_panic_handler_reconfigure_wdts(1000); }{...} #endif/* ... */ /* CONFIG_ESP_COREDUMP_ENABLE */ #if CONFIG_ESP_SYSTEM_PANIC_GDBSTUB disable_all_wdts(); wdt_hal_write_protect_disable(&rtc_wdt_ctx); wdt_hal_disable(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); panic_print_str("Entering gdb stub now.\r\n"); esp_gdbstub_panic_handler((void *)info->frame);/* ... */ #else #if CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS // start RTC WDT if it hasn't been started yet and set the timeout to more than the delay time wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); uint32_t stage_timeout_ticks = (uint32_t)(((CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS + 1) * 1000 * rtc_clk_slow_freq_get_hz()) / 1000ULL); wdt_hal_write_protect_disable(&rtc_wdt_ctx); wdt_hal_config_stage(&rtc_wdt_ctx, WDT_STAGE0, stage_timeout_ticks, WDT_STAGE_ACTION_RESET_SYSTEM); // 64KB of core dump data (stacks of about 30 tasks) will produce ~85KB base64 data. // @ 115200 UART speed it will take more than 6 sec to print them out. wdt_hal_enable(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); esp_panic_handler_reconfigure_wdts((CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS + 1) * 1000); panic_print_str("Rebooting in "); panic_print_dec(CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS); panic_print_str(" seconds...\r\n"); esp_rom_delay_us(CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS * 1000000); esp_panic_handler_reconfigure_wdts(1000);/* ... */ #endif /* CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS */ wdt_hal_write_protect_disable(&rtc_wdt_ctx); wdt_hal_disable(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); #if CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT if (esp_reset_reason_get_hint() == ESP_RST_UNKNOWN) { switch (info->exception) { case PANIC_EXCEPTION_IWDT: esp_reset_reason_set_hint(ESP_RST_INT_WDT); break;... case PANIC_EXCEPTION_TWDT: esp_reset_reason_set_hint(ESP_RST_TASK_WDT); break;... case PANIC_EXCEPTION_ABORT: case PANIC_EXCEPTION_FAULT: default: esp_reset_reason_set_hint(ESP_RST_PANIC); break; // do not touch the previously set reset reason hint... }{...} }{...} panic_print_str("Rebooting...\r\n"); panic_restart();/* ... */ #else /* CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT */ disable_all_wdts(); panic_print_str("CPU halted.\r\n"); esp_system_reset_modules_on_exit(); ESP_INFINITE_LOOP();/* ... */ #endif /* CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT *//* ... */ #endif /* CONFIG_ESP_SYSTEM_PANIC_GDBSTUB */ }{ ... } void IRAM_ATTR __attribute__((noreturn, no_sanitize_undefined)) panic_abort(const char *details) { g_panic_abort = true; g_panic_abort_details = (char *) details; #if CONFIG_APPTRACE_ENABLE #if CONFIG_APPTRACE_SV_ENABLE SEGGER_RTT_ESP_FlushNoLock(CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH, APPTRACE_ONPANIC_HOST_FLUSH_TMO); #else esp_apptrace_flush_nolock(ESP_APPTRACE_DEST_TRAX, CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH, APPTRACE_ONPANIC_HOST_FLUSH_TMO);/* ... */ #endif/* ... */ #endif #ifdef __XTENSA__ asm("ill"); // should be an invalid operation on xtensa targets #elif __riscv asm("unimp"); // should be an invalid operation on RISC-V targets #endif ESP_INFINITE_LOOP(); }{ ... } /* Weak versions of reset reason hint functions. * If these weren't provided, reset reason code would be linked into the app * even if the app never called esp_reset_reason(). *//* ... */ void IRAM_ATTR __attribute__((weak)) esp_reset_reason_set_hint(esp_reset_reason_t hint) { }{ ... } esp_reset_reason_t IRAM_ATTR __attribute__((weak)) esp_reset_reason_get_hint(void) { return ESP_RST_UNKNOWN; }{ ... }
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.