Merge branch 'feature/panic_using_hardware_restart_instead_of_software_v3.3' into 'release/v3.3'

feat(esp8266): Panic uses hardware restart instead of software restart (backport v3.3)

See merge request sdk/ESP8266_RTOS_SDK!1403
This commit is contained in:
Dong Heng
2020-05-19 17:43:22 +08:00

View File

@ -125,17 +125,35 @@ static void panic_frame(panic_frame_t *frame)
#endif /* ESP_PANIC_PRINT */
#ifdef ESP_PANIC_REBOOT
static void hardware_restart(void)
{
CLEAR_WDT_REG_MASK(WDT_CTL_ADDRESS, BIT0);
WDT_REG_WRITE(WDT_OP_ADDRESS, 1);
WDT_REG_WRITE(WDT_OP_ND_ADDRESS, 1);
SET_PERI_REG_BITS(PERIPHS_WDT_BASEADDR + WDT_CTL_ADDRESS,
WDT_CTL_RSTLEN_MASK,
7 << WDT_CTL_RSTLEN_LSB,
0);
SET_PERI_REG_BITS(PERIPHS_WDT_BASEADDR + WDT_CTL_ADDRESS,
WDT_CTL_RSPMOD_MASK,
0 << WDT_CTL_RSPMOD_LSB,
0);
SET_PERI_REG_BITS(PERIPHS_WDT_BASEADDR + WDT_CTL_ADDRESS,
WDT_CTL_EN_MASK,
1 << WDT_CTL_EN_LSB,
0);
}
static void esp_panic_reset(void)
{
uart_tx_wait_idle(0);
uart_tx_wait_idle(1);
rom_i2c_writeReg(0x67, 4, 1, 0x08);
rom_i2c_writeReg(0x67, 4, 2, 0x81);
uart_tx_wait_idle(1);
esp_reset_reason_set_hint(ESP_RST_PANIC);
rom_software_reboot();
hardware_restart();
while (1);
}
#endif