Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Panic] add user configurable reboot delay in seconds (IDFGH-8506) #9962

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions components/esp_system/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ menu "ESP System Settings"
Invoke gdbstub on the serial port, allowing for gdb to attach to it and to do a debug on runtime.
endchoice

config ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS
int "Panic reboot delay (Seconds)"
default 0
depends on ESP_SYSTEM_PANIC_PRINT_REBOOT || ESP_SYSTEM_PANIC_SILENT_REBOOT
help
After the panic handler executes, you can specify a number of seconds to
wait before the device reboots.

config ESP_SYSTEM_SINGLE_CORE_MODE
bool
default n
Expand Down
21 changes: 21 additions & 0 deletions components/esp_system/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,27 @@ void esp_panic_handler(panic_info_t *info)
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
#if CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT

#if CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS

disable_all_wdts();

panic_print_str("Waiting to reboot...\r\n");

for(int i = 0; i < CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS; i++) {

// Display a progress countdown.
// Only print every 5th second so users terminal is still "calm".
if (i % 5 == 0) {
panic_print_dec(CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS - i);
panic_print_str(" seconds...\r\n");
}

esp_rom_delay_us(1000000);
}

esp_panic_handler_reconfigure_wdts();
#endif /* CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS */

if (esp_reset_reason_get_hint() == ESP_RST_UNKNOWN) {
switch (info->exception) {
case PANIC_EXCEPTION_IWDT:
Expand Down