Skip to content

Commit b562afa

Browse files
fix(panic_handler): Updated panic handler to use RTC WDT
This commit updates the following: - Updates the panic handler to use only the RTC WDT to reset the system. - Refactors some of the panic handler code. - Updates Bluetooth files where in they now feed the WDTs instead of reconfiguring them. - Removes some unnecessary configuration of WDTs from various files. - Added a unit test to verify that the system does not lock up when the panic handler is stuck. - Updates the memprot unit tests to work with the refactored panic handler. Closes #15166 Closes #15018 Closes #10110
1 parent b5aef58 commit b562afa

File tree

20 files changed

+574
-159
lines changed

20 files changed

+574
-159
lines changed

components/bt/controller/esp32c2/bt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ extern int ble_controller_init(esp_bt_controller_config_t *cfg);
130130
extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
131131
extern int ble_log_deinit_async(void);
132132
extern void ble_log_async_output_dump_all(bool output);
133-
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
133+
extern void esp_panic_handler_feed_wdts(void);
134134
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
135135
extern int ble_controller_deinit(void);
136136
extern int ble_controller_enable(uint8_t mode);
@@ -391,7 +391,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
391391

392392
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
393393
portENTER_CRITICAL_SAFE(&spinlock);
394-
esp_panic_handler_reconfigure_wdts(5000);
394+
esp_panic_handler_feed_wdts();
395395
ble_log_async_output_dump_all(true);
396396
stop_write = true;
397397
esp_bt_ontroller_log_deinit();
@@ -449,7 +449,7 @@ void esp_ble_controller_log_dump_all(bool output)
449449
} else {
450450
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
451451
portENTER_CRITICAL_SAFE(&spinlock);
452-
esp_panic_handler_reconfigure_wdts(5000);
452+
esp_panic_handler_feed_wdts();
453453
BT_ASSERT_PRINT("\r\n[DUMP_START:");
454454
ble_log_async_output_dump_all(output);
455455
BT_ASSERT_PRINT(":DUMP_END]\r\n");

components/bt/controller/esp32c5/bt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bo
116116
extern int r_ble_log_deinit_async(void);
117117
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
118118
extern void r_ble_log_async_output_dump_all(bool output);
119-
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
119+
extern void esp_panic_handler_feed_wdts(void);
120120
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
121121
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
122122
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
@@ -376,13 +376,13 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
376376

377377
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
378378
portENTER_CRITICAL_SAFE(&spinlock);
379-
esp_panic_handler_reconfigure_wdts(5000);
379+
esp_panic_handler_feed_wdts();
380380
r_ble_log_async_output_dump_all(true);
381381
esp_bt_ontroller_log_deinit();
382382
stop_write = true;
383383

384384
buffer = (const uint8_t *)mapped_ptr;
385-
esp_panic_handler_reconfigure_wdts(5000);
385+
esp_panic_handler_feed_wdts();
386386
if (is_filled) {
387387
read_index = next_erase_index;
388388
} else {
@@ -394,7 +394,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
394394
while (read_index != write_index) {
395395
esp_rom_printf("%02x ", buffer[read_index]);
396396
if (print_len > max_print_len) {
397-
esp_panic_handler_reconfigure_wdts(5000);
397+
esp_panic_handler_feed_wdts();
398398
print_len = 0;
399399
}
400400

@@ -1380,7 +1380,7 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, b
13801380
} else {
13811381
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
13821382
portENTER_CRITICAL_SAFE(&spinlock);
1383-
esp_panic_handler_reconfigure_wdts(1000);
1383+
esp_panic_handler_feed_wdts();
13841384
for (int i = 0; i < len; i++) {
13851385
esp_rom_printf("%02x ", addr[i]);
13861386
}
@@ -1401,7 +1401,7 @@ void esp_ble_controller_log_dump_all(bool output)
14011401
} else {
14021402
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
14031403
portENTER_CRITICAL_SAFE(&spinlock);
1404-
esp_panic_handler_reconfigure_wdts(5000);
1404+
esp_panic_handler_feed_wdts();
14051405
BT_ASSERT_PRINT("\r\n[DUMP_START:");
14061406
r_ble_log_async_output_dump_all(output);
14071407
BT_ASSERT_PRINT(":DUMP_END]\r\n");

components/bt/controller/esp32c6/bt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bo
119119
extern int r_ble_log_deinit_async(void);
120120
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
121121
extern void r_ble_log_async_output_dump_all(bool output);
122-
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
122+
extern void esp_panic_handler_feed_wdts(void);
123123
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
124124
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
125125
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
@@ -379,13 +379,13 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
379379

380380
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
381381
portENTER_CRITICAL_SAFE(&spinlock);
382-
esp_panic_handler_reconfigure_wdts(5000);
382+
esp_panic_handler_feed_wdts();
383383
r_ble_log_async_output_dump_all(true);
384384
esp_bt_ontroller_log_deinit();
385385
stop_write = true;
386386

387387
buffer = (const uint8_t *)mapped_ptr;
388-
esp_panic_handler_reconfigure_wdts(5000);
388+
esp_panic_handler_feed_wdts();
389389
if (is_filled) {
390390
read_index = next_erase_index;
391391
} else {
@@ -397,7 +397,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
397397
while (read_index != write_index) {
398398
esp_rom_printf("%02x ", buffer[read_index]);
399399
if (print_len > max_print_len) {
400-
esp_panic_handler_reconfigure_wdts(5000);
400+
esp_panic_handler_feed_wdts();
401401
print_len = 0;
402402
}
403403

@@ -1401,7 +1401,7 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, b
14011401
} else {
14021402
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
14031403
portENTER_CRITICAL_SAFE(&spinlock);
1404-
esp_panic_handler_reconfigure_wdts(1000);
1404+
esp_panic_handler_feed_wdts();
14051405
for (int i = 0; i < len; i++) {
14061406
esp_rom_printf("%02x ", addr[i]);
14071407
}
@@ -1422,7 +1422,7 @@ void esp_ble_controller_log_dump_all(bool output)
14221422
} else {
14231423
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
14241424
portENTER_CRITICAL_SAFE(&spinlock);
1425-
esp_panic_handler_reconfigure_wdts(5000);
1425+
esp_panic_handler_feed_wdts();
14261426
BT_ASSERT_PRINT("\r\n[DUMP_START:");
14271427
r_ble_log_async_output_dump_all(output);
14281428
BT_ASSERT_PRINT(":DUMP_END]\r\n");

components/bt/controller/esp32h2/bt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bo
114114
extern int r_ble_log_deinit_async(void);
115115
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
116116
extern void r_ble_log_async_output_dump_all(bool output);
117-
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
117+
extern void esp_panic_handler_feed_wdts(void);
118118
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
119119
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
120120
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
@@ -377,13 +377,13 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
377377

378378
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
379379
portENTER_CRITICAL_SAFE(&spinlock);
380-
esp_panic_handler_reconfigure_wdts(5000);
380+
esp_panic_handler_feed_wdts();
381381
r_ble_log_async_output_dump_all(true);
382382
esp_bt_ontroller_log_deinit();
383383
stop_write = true;
384384

385385
buffer = (const uint8_t *)mapped_ptr;
386-
esp_panic_handler_reconfigure_wdts(5000);
386+
esp_panic_handler_feed_wdts();
387387
if (is_filled) {
388388
read_index = next_erase_index;
389389
} else {
@@ -395,7 +395,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
395395
while (read_index != write_index) {
396396
esp_rom_printf("%02x ", buffer[read_index]);
397397
if (print_len > max_print_len) {
398-
esp_panic_handler_reconfigure_wdts(5000);
398+
esp_panic_handler_feed_wdts();
399399
print_len = 0;
400400
}
401401

@@ -1375,7 +1375,7 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, b
13751375
} else {
13761376
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
13771377
portENTER_CRITICAL_SAFE(&spinlock);
1378-
esp_panic_handler_reconfigure_wdts(1000);
1378+
esp_panic_handler_feed_wdts();
13791379
for (int i = 0; i < len; i++) {
13801380
esp_rom_printf("%02x ", addr[i]);
13811381
}
@@ -1395,7 +1395,7 @@ void esp_ble_controller_log_dump_all(bool output)
13951395
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
13961396

13971397
portENTER_CRITICAL_SAFE(&spinlock);
1398-
esp_panic_handler_reconfigure_wdts(5000);
1398+
esp_panic_handler_feed_wdts();
13991399
BT_ASSERT_PRINT("\r\n[DUMP_START:");
14001400
r_ble_log_async_output_dump_all(output);
14011401
BT_ASSERT_PRINT(":DUMP_END]\r\n");

0 commit comments

Comments
 (0)