risc-v/esp32c3: Fix reset triggering crash nested when crash

This commit is contained in:
Dong Heng 2021-08-30 15:37:32 +08:00 committed by Gustavo Henrique Nihei
parent 5a41572fd0
commit 92eedd93a7
4 changed files with 51 additions and 8 deletions

View File

@ -113,6 +113,25 @@ int esp32c3_unregister_shutdown_handler(shutdown_handler_t handler)
return -EINVAL;
}
/****************************************************************************
* Name: up_shutdown_handler
*
* Description:
* Process all registered shutdown callback functions.
*
****************************************************************************/
void up_shutdown_handler(void)
{
for (int i = SHUTDOWN_HANDLERS_NO - 1; i >= 0; i--)
{
if (shutdown_handlers[i])
{
shutdown_handlers[i]();
}
}
}
/****************************************************************************
* Name: up_systemreset
*
@ -123,14 +142,6 @@ int esp32c3_unregister_shutdown_handler(shutdown_handler_t handler)
void up_systemreset(void)
{
for (int i = SHUTDOWN_HANDLERS_NO - 1; i >= 0; i--)
{
if (shutdown_handlers[i])
{
shutdown_handlers[i]();
}
}
putreg32(RTC_CNTL_SW_SYS_RST, RTC_CNTL_OPTIONS0_REG);
/* Wait for the reset */

View File

@ -86,6 +86,16 @@ int esp32c3_register_shutdown_handler(shutdown_handler_t handler);
int esp32c3_unregister_shutdown_handler(shutdown_handler_t handler);
/****************************************************************************
* Name: up_shutdown_handler
*
* Description:
* Process all registered shutdown callback functions.
*
****************************************************************************/
void up_shutdown_handler(void);
#ifdef __cplusplus
}
#endif

View File

@ -7192,6 +7192,8 @@ int esp32c3_wifi_bt_coexist_init(void)
void esp_wifi_stop_callback(void)
{
wlinfo("Trying to stop Wi-Fi...");
int ret = esp_wifi_stop();
if (ret)
{

View File

@ -24,6 +24,9 @@
#include <nuttx/config.h>
#include <stdlib.h>
#include <debug.h>
#include <assert.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -55,6 +58,23 @@
int board_reset(int status)
{
#ifdef CONFIG_BOARD_ASSERT_RESET_VALUE
syslog(LOG_INFO, "reboot status=%d\n", status);
switch (status)
{
case EXIT_SUCCESS:
up_shutdown_handler();
break;
case CONFIG_BOARD_ASSERT_RESET_VALUE:
break;
default:
break;
}
#else
up_shutdown_handler();
#endif
up_systemreset();
return 0;