Merge branch 'feature/s31_lp_uart_ulp' into 'master'

feat(ulp): add lp uart support for ULP on S31

Closes IDF-14634 and IDF-15567

See merge request espressif/esp-idf!48055
This commit is contained in:
Marius Vikhammer
2026-05-06 15:43:12 +08:00
14 changed files with 38 additions and 10 deletions
+6 -1
View File
@@ -3,7 +3,12 @@ idf_build_get_property(target IDF_TARGET)
set(srcs)
set(public_include "include")
if(CONFIG_SOC_UART_SUPPORTED)
list(APPEND srcs "src/uart.c" "src/uart_wakeup.c")
list(APPEND srcs "src/uart.c")
if(CONFIG_SOC_DEEP_SLEEP_SUPPORTED OR CONFIG_SOC_LIGHT_SLEEP_SUPPORTED)
list(APPEND srcs "src/uart_wakeup.c")
endif()
if(CONFIG_SOC_UHCI_SUPPORTED)
list(APPEND srcs "src/uhci.c")
endif()
@@ -175,6 +175,10 @@ config SOC_RTC_TIMER_SUPPORTED
bool
default y
config SOC_ULP_LP_UART_SUPPORTED
bool
default y
config SOC_LP_GPIO_MATRIX_SUPPORTED
bool
default y
@@ -79,7 +79,7 @@
#define SOC_PAU_SUPPORTED 1
#define SOC_PMU_SUPPORTED 1
#define SOC_RTC_TIMER_SUPPORTED 1
// #define SOC_ULP_LP_UART_SUPPORTED 1 // TODO: [ESP32S31] IDF-14634
#define SOC_ULP_LP_UART_SUPPORTED 1
#define SOC_LP_GPIO_MATRIX_SUPPORTED 1
#define SOC_LP_PERIPHERALS_SUPPORTED 1
#define SOC_LP_I2C_SUPPORTED 1
@@ -31,6 +31,11 @@ extern "C" {
#define LP_UART_DEFAULT_RX_GPIO_NUM GPIO_NUM_4
#define LP_UART_DEFAULT_RTS_GPIO_NUM GPIO_NUM_2
#define LP_UART_DEFAULT_CTS_GPIO_NUM GPIO_NUM_3
#elif CONFIG_IDF_TARGET_ESP32S31
#define LP_UART_DEFAULT_TX_GPIO_NUM GPIO_NUM_6
#define LP_UART_DEFAULT_RX_GPIO_NUM GPIO_NUM_7
#define LP_UART_DEFAULT_RTS_GPIO_NUM GPIO_NUM_4
#define LP_UART_DEFAULT_CTS_GPIO_NUM GPIO_NUM_5
#else
#error "LP IO Mux pins undefined for LP UART"
#endif /* CONFIG_IDF_TARGET_ESP32P4 */
@@ -13,6 +13,7 @@
extern "C" {
#endif
#if SOC_DEEP_SLEEP_SUPPORTED
/**
* @brief Initialize and configure the LP UART wakeup mode.
*
@@ -28,6 +29,7 @@ extern "C" {
* @return esp_err_t ESP_OK when successful
*/
esp_err_t lp_core_uart_wakeup_setup(const uart_wakeup_cfg_t *cfg);
#endif /* SOC_DEEP_SLEEP_SUPPORTED */
/**
* @brief Clear LP UART rx tx buffer.
@@ -5,16 +5,19 @@
*/
#include "ulp_lp_core_lp_uart_shared.h"
#include "hal/uart_hal.h"
#include "soc/soc_caps.h"
/* LP UART HAL Context */
static uart_hal_context_t hal = {
.dev = (uart_dev_t *)UART_LL_GET_HW(LP_UART_NUM_0),
};
#if SOC_DEEP_SLEEP_SUPPORTED
esp_err_t lp_core_uart_wakeup_setup(const uart_wakeup_cfg_t *cfg)
{
return uart_wakeup_setup(LP_UART_NUM_0, cfg);
}
#endif /* SOC_DEEP_SLEEP_SUPPORTED */
void lp_core_uart_clear_buf(void)
{
@@ -6,7 +6,9 @@ endif()
if(CONFIG_SOC_ULP_LP_UART_SUPPORTED)
list(APPEND app_sources "test_lp_core_uart.c")
list(APPEND app_sources "test_lp_core_uart_wakeup.c")
if(CONFIG_SOC_DEEP_SLEEP_SUPPORTED)
list(APPEND app_sources "test_lp_core_uart_wakeup.c")
endif()
endif()
if(CONFIG_SOC_LP_SPI_SUPPORTED)
@@ -43,7 +45,9 @@ endif()
if(CONFIG_SOC_ULP_LP_UART_SUPPORTED)
set(lp_core_sources_uart "lp_core/test_main_uart.c")
set(lp_core_sources_uart_wakeup "lp_core/test_main_uart_wakeup.c")
if(CONFIG_SOC_DEEP_SLEEP_SUPPORTED)
set(lp_core_sources_uart_wakeup "lp_core/test_main_uart_wakeup.c")
endif()
endif()
if(CONFIG_SOC_LP_SPI_SUPPORTED)
@@ -89,7 +93,9 @@ endif()
if(CONFIG_SOC_ULP_LP_UART_SUPPORTED)
ulp_embed_binary(lp_core_test_app_uart "${lp_core_sources_uart}" "${lp_core_exp_dep_srcs}")
ulp_embed_binary(lp_core_test_app_uart_wakeup "${lp_core_sources_uart_wakeup}" "${lp_core_exp_dep_srcs}")
if(CONFIG_SOC_DEEP_SLEEP_SUPPORTED)
ulp_embed_binary(lp_core_test_app_uart_wakeup "${lp_core_sources_uart_wakeup}" "${lp_core_exp_dep_srcs}")
endif()
endif()
if(CONFIG_SOC_LP_SPI_SUPPORTED)
@@ -79,6 +79,7 @@ def test_lp_core_multi_device(case_tester: CaseTester) -> None:
indirect=True,
)
@idf_parametrize('target', soc_filtered_targets('SOC_ULP_LP_UART_SUPPORTED == 1'), indirect=['target'])
@pytest.mark.temp_skip_ci(targets=['esp32s31'], reason='TODO IDF-15572 Enable ULP multi device tests for ESP32-S31')
def test_lp_uart_multi_device(case_tester: CaseTester) -> None:
uart_cases = [case for case in case_tester.test_menu if 'uart' in case.groups and 'wakeup' not in case.groups]
for case in uart_cases:
@@ -17,9 +17,6 @@ def test_lp_core_hp_uart_print(dut: Dut) -> None:
@pytest.mark.generic
@pytest.mark.temp_skip_ci(
targets=['esp32s31'], reason='TODO IDF-15567 investigate esp32s31.default.test_lp_core_panic failure'
)
@idf_parametrize('target', soc_filtered_targets('SOC_LP_CORE_SUPPORTED == 1'), indirect=['target'])
def test_lp_core_panic(dut: Dut) -> None:
dut.expect_exact('Press ENTER to see the list of tests')