Skip to content

Commit 1fa27cb

Browse files
committed
Merge branch 'feature/esp32c5mp_light_sleep_support_stage_2' into 'master'
feat(esp_hw_support): esp32c5mp sleep support (system part) Closes IDF-8643, PM-195, PM-169, IDF-8641, IDF-8640, IDF-8639, IDF-8638, CV-259, IDF-10308, IDF-10317, IDF-10310, PM-202, IDF-10918, PM-207, PM-208, PM-210, and PM-214 See merge request espressif/esp-idf!31645
2 parents 2526ebd + 4393343 commit 1fa27cb

File tree

128 files changed

+2032
-814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+2032
-814
lines changed

components/app_update/test_apps/.build-test-rules.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
components/app_update/test_apps:
44
disable:
5-
- if: IDF_TARGET in ["esp32c5", "esp32c61"]
5+
- if: IDF_TARGET in ["esp32c61"]
66
temporary: true
7-
reason: target esp32c5 is not supported yet # TODO: [ESP32C5] IDF-8640, IDF-10317, [ESP32C61] IDF-9245
7+
reason: target esp32c61 is not supported yet # TODO: [ESP32C61] IDF-9245
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
2-
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
1+
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
2+
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |

components/app_update/test_apps/pytest_app_update_ut.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def run_multiple_stages(dut: Dut, test_case_num: int, stages: int) -> None:
1919

2020

2121
@pytest.mark.supported_targets
22-
@pytest.mark.temp_skip_ci(targets=['esp32c5'], reason='C5 has not supported deep sleep') # TODO: [ESP32C5] IDF-8640, IDF-10317
2322
@pytest.mark.generic
2423
def test_app_update(dut: Dut) -> None:
2524
dut.run_all_single_board_cases(timeout=90)

components/bootloader_support/src/esp32c5/bootloader_soc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ void bootloader_ana_super_wdt_reset_config(bool enable)
1919
//Not supported but common bootloader calls the function. Do nothing
2020
void bootloader_ana_clock_glitch_reset_config(bool enable)
2121
{
22-
// TODO: [ESP32C5] IDF-8667
22+
// TODO: [ESP32C5] IDF-8667, PM-207
2323
(void)enable;
2424
}

components/bt/controller/esp32c5/bt.c

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@
3939
#include "esp_pm.h"
4040
#include "esp_phy_init.h"
4141
#include "esp_private/periph_ctrl.h"
42-
#include "bt_osi_mem.h"
43-
44-
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
42+
#include "soc/retention_periph_defs.h"
4543
#include "esp_private/sleep_retention.h"
46-
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG
44+
#include "soc/regdma.h"
45+
#include "bt_osi_mem.h"
4746

4847
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
4948
#include "esp_private/sleep_modem.h"
@@ -52,9 +51,6 @@
5251
#include "freertos/FreeRTOS.h"
5352
#include "freertos/task.h"
5453

55-
#include "esp_private/periph_ctrl.h"
56-
#include "esp_sleep.h"
57-
5854
#include "hal/efuse_hal.h"
5955
#include "soc/rtc.h"
6056
/* Macro definition
@@ -377,25 +373,53 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
377373
}
378374

379375
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
376+
// TODO: IDF-10765
377+
// static esp_err_t sleep_modem_ble_mac_retention_init(void *arg)
378+
// {
379+
// uint8_t size;
380+
// int extra = *(int *)arg;
381+
// const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra);
382+
// esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BLE_MAC);
383+
// if (err == ESP_OK) {
384+
// ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Modem BLE MAC retention initialization");
385+
// }
386+
// return err;
387+
// return ESP_OK;
388+
// }
389+
380390
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
381391
{
382-
uint8_t size;
383-
const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra);
384-
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BLE_MAC);
385-
if (err == ESP_OK) {
386-
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Modem BLE MAC retention initialization");
387-
}
388-
return err;
392+
// TODO: IDF-10765
393+
// int retention_args = extra;
394+
// sleep_retention_module_init_param_t init_param = {
395+
// .cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
396+
// .depends = BIT(SLEEP_RETENTION_MODULE_BT_BB)
397+
// };
398+
// esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
399+
// if (err == ESP_OK) {
400+
// err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_BLE_MAC);
401+
// }
402+
// return err;
403+
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "This func temporary not supported for current target!");
404+
return ESP_OK;
389405
}
390406

391407
static void sleep_modem_ble_mac_modem_state_deinit(void)
392408
{
393-
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_BLE_MAC);
409+
// TODO: IDF-10765
410+
// esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_BLE_MAC);
411+
// if (err == ESP_OK) {
412+
// err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_BLE_MAC);
413+
// assert(err == ESP_OK);
414+
// }
415+
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "This func temporary not supported for current target!");
394416
}
395417

396418
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
397419
{
398-
esp_ble_set_wakeup_overhead(overhead);
420+
// TODO: IDF-10765
421+
// esp_ble_set_wakeup_overhead(overhead);
422+
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "This func temporary not supported for current target!");
399423
}
400424
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
401425

components/esp_adc/adc_oneshot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ esp_err_t adc_oneshot_new_unit(const adc_oneshot_unit_init_cfg_t *init_config, a
126126
if (init_config->ulp_mode == ADC_ULP_MODE_DISABLE) {
127127
sar_periph_ctrl_adc_oneshot_power_acquire();
128128
} else {
129-
#if !CONFIG_IDF_TARGET_ESP32C5// # TODO: IDF-8638, IDF-8640
129+
#if SOC_LIGHT_SLEEP_SUPPORTED || SOC_DEEP_SLEEP_SUPPORTED
130130
esp_sleep_enable_adc_tsens_monitor(true);
131131
#endif
132132
}
@@ -229,7 +229,7 @@ esp_err_t adc_oneshot_del_unit(adc_oneshot_unit_handle_t handle)
229229
if (ulp_mode == ADC_ULP_MODE_DISABLE) {
230230
sar_periph_ctrl_adc_oneshot_power_release();
231231
} else {
232-
#if !CONFIG_IDF_TARGET_ESP32C5// # TODO: IDF-8638, IDF-8640
232+
#if SOC_LIGHT_SLEEP_SUPPORTED || SOC_DEEP_SLEEP_SUPPORTED
233233
esp_sleep_enable_adc_tsens_monitor(false);
234234
#endif
235235
}

components/esp_driver_gpio/src/gpio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ esp_err_t gpio_sleep_pupd_config_unapply(gpio_num_t gpio_num)
975975
}
976976
#endif // CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL
977977

978-
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
978+
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED
979979
esp_err_t gpio_deep_sleep_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type)
980980
{
981981
if (!GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num)) {
@@ -1015,7 +1015,7 @@ esp_err_t gpio_deep_sleep_wakeup_disable(gpio_num_t gpio_num)
10151015
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
10161016
return ESP_OK;
10171017
}
1018-
#endif // SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
1018+
#endif // SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED
10191019

10201020
esp_err_t gpio_dump_io_configuration(FILE *out_stream, uint64_t io_bit_mask)
10211021
{

components/esp_driver_rmt/test_apps/rmt/main/test_rmt_sleep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "test_util_rmt_encoders.h"
2121
#include "test_board.h"
2222

23+
#if SOC_RMT_SUPPORT_SLEEP_RETENTION // TODO: IDF-10917
2324
typedef struct {
2425
TaskHandle_t task_to_notify;
2526
size_t received_symbol_num;
@@ -146,7 +147,6 @@ static void test_rmt_tx_rx_sleep_retention(bool back_up_before_sleep)
146147
TEST_CASE("rmt tx+rx after light sleep", "[rmt]")
147148
{
148149
test_rmt_tx_rx_sleep_retention(false);
149-
#if SOC_RMT_SUPPORT_SLEEP_RETENTION
150150
test_rmt_tx_rx_sleep_retention(true);
151-
#endif
152151
}
152+
#endif

components/esp_driver_uart/test_apps/uart/main/test_uart_auto_lightsleep.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
#define MIN_FREQ 8
3434
#elif CONFIG_XTAL_FREQ_26
3535
#define MIN_FREQ 13
36+
#elif CONFIG_XTAL_FREQ_AUTO
37+
#if CONFIG_IDF_TARGET_ESP32C5
38+
/* The ESP32C5 uses Autodetect to obtain the XTAL_FREQ, and its CONFIG_XTAL_FREQ is set to 0.
39+
* Its MIN_FREQ is set to 12M because it primarily uses a 48M xtal */
40+
#define MIN_FREQ 12
41+
#endif
3642
#endif
3743

3844
TEST_CASE("uart tx won't be blocked by auto light sleep", "[uart]")

components/esp_hw_support/CMakeLists.txt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ if(NOT BOOTLOADER_BUILD)
5353
if(CONFIG_SOC_PAU_SUPPORTED)
5454
list(APPEND srcs "sleep_retention.c"
5555
"sleep_system_peripheral.c"
56-
"sleep_clock.c"
57-
"port/${target}/clock_retention_init.c"
5856
)
5957
endif()
6058

@@ -143,15 +141,6 @@ if(NOT BOOTLOADER_BUILD)
143141
list(APPEND srcs "esp_clock_output.c")
144142
endif()
145143

146-
if(CONFIG_IDF_TARGET_ESP32C5)
147-
list(REMOVE_ITEM srcs
148-
"sleep_modes.c" # TODO: [ESP32C5] IDF-8638
149-
"sleep_modem.c" # TODO: [ESP32C5] IDF-8638
150-
"sleep_wake_stub.c" # TODO: [ESP32C5] IDF-8638
151-
"sleep_gpio.c" # TODO: [ESP32C5] IDF-8638
152-
)
153-
endif()
154-
155144
if(CONFIG_IDF_TARGET_ESP32C61) # TODO: [ESP32C61] IDF-9245, IDF-9247, IDF-9248
156145
list(REMOVE_ITEM srcs
157146
"sleep_cpu.c"
@@ -184,6 +173,10 @@ if(CONFIG_COMPILER_STATIC_ANALYZER AND CMAKE_C_COMPILER_ID STREQUAL "GNU") # TOD
184173
target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-analyzer")
185174
endif()
186175

176+
if(CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND OR CONFIG_PM_SLP_DISABLE_GPIO)
177+
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_sleep_gpio_include")
178+
endif()
179+
187180
if(NOT BOOTLOADER_BUILD)
188181
if(CONFIG_SPIRAM)
189182
idf_component_optional_requires(PRIVATE esp_psram)

0 commit comments

Comments
 (0)