Skip to content

Commit 89141b5

Browse files
committed
feat(esp8266): Panic uses hardware restart instead of software restart
1 parent a46b819 commit 89141b5

File tree

1 file changed

+23
-5
lines changed
  • components/freertos/port/esp8266

1 file changed

+23
-5
lines changed

components/freertos/port/esp8266/panic.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,35 @@ static void panic_frame(panic_frame_t *frame)
125125
#endif /* ESP_PANIC_PRINT */
126126

127127
#ifdef ESP_PANIC_REBOOT
128+
static void hardware_restart(void)
129+
{
130+
CLEAR_WDT_REG_MASK(WDT_CTL_ADDRESS, BIT0);
131+
WDT_REG_WRITE(WDT_OP_ADDRESS, 1);
132+
WDT_REG_WRITE(WDT_OP_ND_ADDRESS, 1);
133+
SET_PERI_REG_BITS(PERIPHS_WDT_BASEADDR + WDT_CTL_ADDRESS,
134+
WDT_CTL_RSTLEN_MASK,
135+
7 << WDT_CTL_RSTLEN_LSB,
136+
0);
137+
SET_PERI_REG_BITS(PERIPHS_WDT_BASEADDR + WDT_CTL_ADDRESS,
138+
WDT_CTL_RSPMOD_MASK,
139+
0 << WDT_CTL_RSPMOD_LSB,
140+
0);
141+
SET_PERI_REG_BITS(PERIPHS_WDT_BASEADDR + WDT_CTL_ADDRESS,
142+
WDT_CTL_EN_MASK,
143+
1 << WDT_CTL_EN_LSB,
144+
0);
145+
}
146+
128147
static void esp_panic_reset(void)
129148
{
130149
uart_tx_wait_idle(0);
131-
uart_tx_wait_idle(1);
132-
133-
rom_i2c_writeReg(0x67, 4, 1, 0x08);
134-
rom_i2c_writeReg(0x67, 4, 2, 0x81);
150+
uart_tx_wait_idle(1);
135151

136152
esp_reset_reason_set_hint(ESP_RST_PANIC);
137153

138-
rom_software_reboot();
154+
hardware_restart();
155+
156+
while (1);
139157
}
140158
#endif
141159

0 commit comments

Comments
 (0)