Skip to content

Commit 5436d1f

Browse files
committed
fix(esp_system): force enable uart0 sclk in esp_restart
1 parent 01e990e commit 5436d1f

File tree

6 files changed

+30
-0
lines changed

6 files changed

+30
-0
lines changed

components/esp_system/port/soc/esp32c5/system_internal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "soc/rtc_periph.h"
2323
#include "soc/uart_reg.h"
2424
#include "hal/wdt_hal.h"
25+
#include "hal/uart_ll.h"
2526
#if SOC_MODEM_CLOCK_SUPPORTED
2627
#include "hal/modem_syscon_ll.h"
2728
#include "hal/modem_lpcon_ll.h"
@@ -82,6 +83,10 @@ void esp_system_reset_modules_on_exit(void)
8283
CLEAR_PERI_REG_MASK(PCR_RSA_CONF_REG, PCR_RSA_RST_EN);
8384
SET_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
8485
CLEAR_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
86+
87+
// UART's sclk is controlled in the PCR register and does not reset with the UART module. The ROM missed enabling
88+
// it when initializing the ROM UART. If it is not turned on, it will trigger LP_WDT in the ROM.
89+
uart_ll_sclk_enable(&UART0);
8590
}
8691

8792
/* "inner" restart function for after RTOS, interrupts & anything else on this

components/esp_system/port/soc/esp32c6/system_internal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "esp_private/rtc_clk.h"
2121
#include "soc/rtc_periph.h"
2222
#include "soc/uart_reg.h"
23+
#include "hal/uart_ll.h"
2324
#include "hal/wdt_hal.h"
2425
#include "hal/modem_syscon_ll.h"
2526
#include "hal/modem_lpcon_ll.h"
@@ -75,6 +76,10 @@ void esp_system_reset_modules_on_exit(void)
7576
CLEAR_PERI_REG_MASK(PCR_HMAC_CONF_REG, PCR_HMAC_RST_EN);
7677
CLEAR_PERI_REG_MASK(PCR_RSA_CONF_REG, PCR_RSA_RST_EN);
7778
CLEAR_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
79+
80+
// UART's sclk is controlled in the PCR register and does not reset with the UART module. The ROM missed enabling
81+
// it when initializing the ROM UART. If it is not turned on, it will trigger LP_WDT in the ROM.
82+
uart_ll_sclk_enable(&UART0);
7883
}
7984

8085
/* "inner" restart function for after RTOS, interrupts & anything else on this

components/esp_system/port/soc/esp32c61/system_internal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "esp_private/rtc_clk.h"
2121
#include "soc/rtc_periph.h"
2222
#include "soc/uart_reg.h"
23+
#include "hal/uart_ll.h"
2324
#include "hal/wdt_hal.h"
2425
#include "esp_private/cache_err_int.h"
2526

@@ -82,6 +83,10 @@ void esp_system_reset_modules_on_exit(void)
8283
CLEAR_PERI_REG_MASK(PCR_RSA_CONF_REG, PCR_RSA_RST_EN);
8384
SET_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
8485
CLEAR_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
86+
87+
// UART's sclk is controlled in the PCR register and does not reset with the UART module. The ROM missed enabling
88+
// it when initializing the ROM UART. If it is not turned on, it will trigger LP_WDT in the ROM.
89+
uart_ll_sclk_enable(&UART0);
8590
}
8691

8792
/* "inner" restart function for after RTOS, interrupts & anything else on this

components/esp_system/port/soc/esp32h2/system_internal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "soc/uart_reg.h"
2424
#include "hal/wdt_hal.h"
2525
#include "hal/spimem_flash_ll.h"
26+
#include "hal/uart_ll.h"
2627
#include "esp_private/cache_err_int.h"
2728
#include "esp_private/mspi_timing_tuning.h"
2829

@@ -73,6 +74,10 @@ void esp_system_reset_modules_on_exit(void)
7374
CLEAR_PERI_REG_MASK(PCR_HMAC_CONF_REG, PCR_HMAC_RST_EN);
7475
CLEAR_PERI_REG_MASK(PCR_RSA_CONF_REG, PCR_RSA_RST_EN);
7576
CLEAR_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
77+
78+
// UART's sclk is controlled in the PCR register and does not reset with the UART module. The ROM missed enabling
79+
// it when initializing the ROM UART. If it is not turned on, it will trigger LP_WDT in the ROM.
80+
uart_ll_sclk_enable(&UART0);
7681
}
7782

7883
/* "inner" restart function for after RTOS, interrupts & anything else on this

components/esp_system/port/soc/esp32h21/system_internal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "esp_private/rtc_clk.h"
2121
#include "soc/rtc_periph.h"
2222
#include "soc/uart_reg.h"
23+
#include "hal/uart_ll.h"
2324
#include "hal/wdt_hal.h"
2425
#include "hal/spimem_flash_ll.h"
2526
#include "esp_private/cache_err_int.h"
@@ -77,6 +78,10 @@ void esp_system_reset_modules_on_exit(void)
7778
CLEAR_PERI_REG_MASK(PCR_RSA_CONF_REG, PCR_RSA_RST_EN);
7879
SET_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
7980
CLEAR_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
81+
82+
// UART's sclk is controlled in the PCR register and does not reset with the UART module. The ROM missed enabling
83+
// it when initializing the ROM UART. If it is not turned on, it will trigger LP_WDT in the ROM.
84+
uart_ll_sclk_enable(&UART0);
8085
}
8186

8287
/* "inner" restart function for after RTOS, interrupts & anything else on this

components/esp_system/port/soc/esp32h4/system_internal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "soc/rtc_periph.h"
2222
#include "soc/uart_reg.h"
2323
#include "hal/wdt_hal.h"
24+
#include "hal/uart_ll.h"
2425

2526
#include "esp32h4/rom/cache.h"
2627
// TODO: IDF-11911 need refactor
@@ -70,6 +71,10 @@ void esp_system_reset_modules_on_exit(void)
7071
CLEAR_PERI_REG_MASK(PCR_HMAC_CONF_REG, PCR_HMAC_RST_EN);
7172
SET_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
7273
CLEAR_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
74+
75+
// UART's sclk is controlled in the PCR register and does not reset with the UART module. The ROM missed enabling
76+
// it when initializing the ROM UART. If it is not turned on, it will trigger LP_WDT in the ROM.
77+
uart_ll_sclk_enable(&UART0);
7378
}
7479

7580
/* "inner" restart function for after RTOS, interrupts & anything else on this

0 commit comments

Comments
 (0)