diff --git a/components/esp_hw_support/sleep_system_peripheral.c b/components/esp_hw_support/sleep_system_peripheral.c index 81d6569e414..0a76f5550a2 100644 --- a/components/esp_hw_support/sleep_system_peripheral.c +++ b/components/esp_hw_support/sleep_system_peripheral.c @@ -172,6 +172,7 @@ ESP_SYSTEM_INIT_FN(sleep_sys_periph_startup_init, SECONDARY, BIT(0), 107) { sleep_retention_module_init_param_t init_param = { .cbs = { .create = { .handle = sleep_sys_periph_retention_init, .arg = NULL } }, + .attribute = SLEEP_RETENTION_MODULE_ATTR_ATTACH, .depends.bitmap[SLEEP_RETENTION_MODULE_CLOCK_SYSTEM >> 5] = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM % 32) }; esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_SYS_PERIPH, &init_param); @@ -180,6 +181,12 @@ ESP_SYSTEM_INIT_FN(sleep_sys_periph_startup_init, SECONDARY, BIT(0), 107) if (err != ESP_OK) { ESP_LOGW(TAG, "failed to allocate sleep retention linked list for system peripherals retention"); } + if (err == ESP_OK) { + err = sleep_retention_module_attach(SLEEP_RETENTION_MODULE_SYS_PERIPH); + if (err != ESP_OK) { + ESP_LOGW(TAG, "failed to attach sleep retention linked list for system peripherals retention"); + } + } } return ESP_OK; } diff --git a/components/esp_system/int_wdt.c b/components/esp_system/int_wdt.c index 6c460cd1fec..7a1dca6439e 100644 --- a/components/esp_system/int_wdt.c +++ b/components/esp_system/int_wdt.c @@ -73,6 +73,7 @@ static esp_err_t esp_int_wdt_retention_enable(uint32_t group_id) { sleep_retention_module_init_param_t init_param = { .cbs = { .create = { .handle = sleep_int_wdt_retention_init, .arg = &group_id } }, + .attribute = SLEEP_RETENTION_MODULE_ATTR_ATTACH, .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_SYSTEM) }; esp_err_t err = sleep_retention_module_init((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT, &init_param); @@ -80,6 +81,11 @@ static esp_err_t esp_int_wdt_retention_enable(uint32_t group_id) err = sleep_retention_module_allocate((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT); if (err != ESP_OK) { ESP_LOGW(TAG, "Failed to allocate sleep retention linked list for interrupt watchdog timer retention"); + } else { + err = sleep_retention_module_attach((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Failed to attach sleep retention linked list for interrupt watchdog timer retention"); + } } } return err; diff --git a/components/esp_system/task_wdt/task_wdt_impl_timergroup.c b/components/esp_system/task_wdt/task_wdt_impl_timergroup.c index dba9c705d10..26b6beb636d 100644 --- a/components/esp_system/task_wdt/task_wdt_impl_timergroup.c +++ b/components/esp_system/task_wdt/task_wdt_impl_timergroup.c @@ -71,6 +71,7 @@ static esp_err_t esp_task_wdt_retention_enable(uint32_t group_id) { sleep_retention_module_init_param_t init_param = { .cbs = { .create = { .handle = sleep_task_wdt_retention_init, .arg = &group_id } }, + .attribute = SLEEP_RETENTION_MODULE_ATTR_ATTACH, .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_SYSTEM) }; esp_err_t err = sleep_retention_module_init((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT, &init_param); @@ -78,6 +79,11 @@ static esp_err_t esp_task_wdt_retention_enable(uint32_t group_id) err = sleep_retention_module_allocate((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT); if (err != ESP_OK) { ESP_LOGW(TAG, "Failed to allocate sleep retention linked list for task watchdog timer retention"); + } else { + err = sleep_retention_module_attach((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Failed to attach sleep retention linked list for task watchdog timer retention"); + } } } return err; @@ -85,9 +91,12 @@ static esp_err_t esp_task_wdt_retention_enable(uint32_t group_id) static esp_err_t esp_task_wdt_retention_disable(uint32_t group_id) { - esp_err_t err = sleep_retention_module_free((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT); + esp_err_t err = sleep_retention_module_detach((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT); if (err == ESP_OK) { - err = sleep_retention_module_deinit((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT); + err = sleep_retention_module_free((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT); + if (err == ESP_OK) { + err = sleep_retention_module_deinit((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT); + } } return err; }