diff --git a/components/bootloader/Kconfig.projbuild b/components/bootloader/Kconfig.projbuild index 46244b88cf..96dd3f5b92 100644 --- a/components/bootloader/Kconfig.projbuild +++ b/components/bootloader/Kconfig.projbuild @@ -323,7 +323,7 @@ menu "Bootloader config" # options, allowing to turn on "allow insecure options" and have secure boot with # "skip validation when existing deep sleep". Keeping this to avoid a breaking change, # but - as noted in help - it invalidates the integrity of Secure Boot checks - depends on (SECURE_BOOT && SECURE_BOOT_INSECURE) || !SECURE_BOOT + depends on SOC_RTC_FAST_MEM_SUPPORTED && ((SECURE_BOOT && SECURE_BOOT_INSECURE) || !SECURE_BOOT) default n help This option disables the normal validation of an image coming out of @@ -379,6 +379,7 @@ menu "Bootloader config" config BOOTLOADER_RESERVE_RTC_SIZE hex + depends on SOC_RTC_FAST_MEM_SUPPORTED default 0x10 if BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP || BOOTLOADER_CUSTOM_RESERVE_RTC default 0 help @@ -390,6 +391,7 @@ menu "Bootloader config" config BOOTLOADER_CUSTOM_RESERVE_RTC bool "Reserve RTC FAST memory for custom purposes" + depends on SOC_RTC_FAST_MEM_SUPPORTED default n help This option allows the customer to place data in the RTC FAST memory, diff --git a/components/bootloader_support/src/bootloader_common.c b/components/bootloader_support/src/bootloader_common.c index 709504d386..27191de8ff 100644 --- a/components/bootloader_support/src/bootloader_common.c +++ b/components/bootloader_support/src/bootloader_common.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,6 +21,7 @@ #include "soc/gpio_periph.h" #include "soc/rtc.h" #include "soc/efuse_reg.h" +#include "soc/soc_caps.h" #include "hal/gpio_ll.h" #include "esp_image_format.h" #include "bootloader_sha.h" @@ -195,6 +196,7 @@ RESET_REASON bootloader_common_get_reset_reason(int cpu_no) uint8_t bootloader_flash_get_cs_io(void) { +#if SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE uint8_t cs_io; const uint32_t spiconfig = esp_rom_efuse_get_flash_gpio_info(); if (spiconfig == ESP_ROM_EFUSE_FLASH_DEFAULT_SPI) { @@ -203,4 +205,7 @@ uint8_t bootloader_flash_get_cs_io(void) cs_io = (spiconfig >> 18) & 0x3f; } return cs_io; +#else + return SPI_CS0_GPIO_NUM; +#endif } diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index 679c360baa..6db629f75f 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -40,10 +40,10 @@ typedef enum { #if SOC_PM_SUPPORT_RTC_PERIPH_PD ESP_PD_DOMAIN_RTC_PERIPH, //!< RTC IO, sensors and ULP co-processor #endif -#if SOC_RTC_SLOW_MEM_SUPPORTED +#if SOC_PM_SUPPORT_RTC_SLOW_MEM_PD ESP_PD_DOMAIN_RTC_SLOW_MEM, //!< RTC slow memory #endif -#if SOC_RTC_FAST_MEM_SUPPORTED +#if SOC_PM_SUPPORT_RTC_FAST_MEM_PD ESP_PD_DOMAIN_RTC_FAST_MEM, //!< RTC fast memory #endif ESP_PD_DOMAIN_XTAL, //!< XTAL oscillator diff --git a/components/esp_hw_support/port/esp32c2/rtc_clk.c b/components/esp_hw_support/port/esp32c2/rtc_clk.c index d9b1b43e66..12474d7f45 100644 --- a/components/esp_hw_support/port/esp32c2/rtc_clk.c +++ b/components/esp_hw_support/port/esp32c2/rtc_clk.c @@ -19,6 +19,8 @@ #include "soc/efuse_reg.h" #include "soc/syscon_reg.h" #include "soc/system_reg.h" +#include "soc/io_mux_reg.h" +#include "soc/soc.h" #include "regi2c_ctrl.h" #include "regi2c_bbpll.h" #include "esp_hw_log.h" @@ -35,6 +37,12 @@ static int s_cur_pll_freq; static void rtc_clk_cpu_freq_to_8m(void); +void rtc_clk_32k_enable_external(void) +{ + REG_SET_BIT(PERIPHS_IO_MUX_XTAL_32K_P_U, FUN_IE); + REG_SET_BIT(RTC_CNTL_PAD_HOLD_REG, RTC_CNTL_GPIO_PIN0_HOLD); +} + void rtc_clk_8m_enable(bool clk_8m_en, bool d256_en) { if (clk_8m_en) { diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 8d0cc3c8eb..0afac30632 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -101,8 +101,8 @@ #define DEFAULT_SLEEP_OUT_OVERHEAD_US (105) #define DEFAULT_HARDWARE_OUT_OVERHEAD_US (37) #elif CONFIG_IDF_TARGET_ESP32C2 -#define DEFAULT_SLEEP_OUT_OVERHEAD_US (105) -#define DEFAULT_HARDWARE_OUT_OVERHEAD_US (37) +#define DEFAULT_SLEEP_OUT_OVERHEAD_US (118) +#define DEFAULT_HARDWARE_OUT_OVERHEAD_US (9) #endif #define LIGHT_SLEEP_TIME_OVERHEAD_US DEFAULT_HARDWARE_OUT_OVERHEAD_US @@ -156,10 +156,10 @@ static sleep_config_t s_config = { #if SOC_PM_SUPPORT_RTC_PERIPH_PD ESP_PD_OPTION_AUTO, #endif -#if SOC_RTC_SLOW_MEM_SUPPORTED +#if SOC_PM_SUPPORT_RTC_SLOW_MEM_PD ESP_PD_OPTION_AUTO, #endif -#if SOC_RTC_FAST_MEM_SUPPORTED +#if SOC_PM_SUPPORT_RTC_FAST_MEM_PD ESP_PD_OPTION_AUTO, #endif ESP_PD_OPTION_AUTO, @@ -1157,6 +1157,26 @@ esp_err_t esp_sleep_disable_wifi_wakeup(void) #endif } +esp_err_t esp_sleep_enable_bt_wakeup(void) +{ +#if SOC_PM_SUPPORT_BT_WAKEUP + s_config.wakeup_triggers |= RTC_BT_TRIG_EN; + return ESP_OK; +#else + return ESP_ERR_NOT_SUPPORTED; +#endif +} + +esp_err_t esp_sleep_disable_bt_wakeup(void) +{ +#if SOC_PM_SUPPORT_BT_WAKEUP + s_config.wakeup_triggers &= (~RTC_BT_TRIG_EN); + return ESP_OK; +#else + return ESP_ERR_NOT_SUPPORTED; +#endif +} + esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause(void) { if (esp_rom_get_reset_reason(0) != RESET_REASON_CORE_DEEP_SLEEP && !s_light_sleep_wakeup) { @@ -1227,7 +1247,7 @@ static uint32_t get_power_down_flags(void) // If there is any data placed into .rtc.data or .rtc.bss segments, and // RTC_SLOW_MEM is Auto, keep it powered up as well. -#if SOC_RTC_SLOW_MEM_SUPPORTED && SOC_ULP_SUPPORTED +#if SOC_PM_SUPPORT_RTC_SLOW_MEM_PD && SOC_ULP_SUPPORTED // Labels are defined in the linker script extern int _rtc_slow_length; /** @@ -1242,7 +1262,7 @@ static uint32_t get_power_down_flags(void) } #endif -#if SOC_RTC_FAST_MEM_SUPPORTED +#if SOC_PM_SUPPORT_RTC_FAST_MEM_PD #if !CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP /* RTC_FAST_MEM is needed for deep sleep stub. If RTC_FAST_MEM is Auto, keep it powered on, so that deep sleep stub can run. @@ -1298,21 +1318,21 @@ static uint32_t get_power_down_flags(void) #if SOC_PM_SUPPORT_RTC_PERIPH_PD ESP_EARLY_LOGD(TAG, "RTC_PERIPH: %s", option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH]]); #endif -#if SOC_RTC_SLOW_MEM_SUPPORTED +#if SOC_PM_SUPPORT_RTC_SLOW_MEM_PD ESP_EARLY_LOGD(TAG, "RTC_SLOW_MEM: %s", option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM]]); #endif -#if SOC_RTC_FAST_MEM_SUPPORTED +#if SOC_PM_SUPPORT_RTC_FAST_MEM_PD ESP_EARLY_LOGD(TAG, "RTC_FAST_MEM: %s", option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_FAST_MEM]]); #endif // Prepare flags based on the selected options uint32_t pd_flags = 0; -#if SOC_RTC_FAST_MEM_SUPPORTED +#if SOC_PM_SUPPORT_RTC_FAST_MEM_PD if (s_config.pd_options[ESP_PD_DOMAIN_RTC_FAST_MEM] != ESP_PD_OPTION_ON) { pd_flags |= RTC_SLEEP_PD_RTC_FAST_MEM; } #endif -#if SOC_RTC_SLOW_MEM_SUPPORTED +#if SOC_PM_SUPPORT_RTC_SLOW_MEM_PD if (s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM] != ESP_PD_OPTION_ON) { pd_flags |= RTC_SLEEP_PD_RTC_SLOW_MEM; } diff --git a/components/esp_system/port/soc/esp32c2/clk.c b/components/esp_system/port/soc/esp32c2/clk.c index c07abd9d74..1a03ccf65c 100644 --- a/components/esp_system/port/soc/esp32c2/clk.c +++ b/components/esp_system/port/soc/esp32c2/clk.c @@ -147,6 +147,8 @@ static void select_rtc_slow_clk(slow_clk_sel_t slow_clk) * will time out, returning 0. */ ESP_EARLY_LOGD(TAG, "waiting for external clock by pin0 to start up"); + rtc_clk_32k_enable_external(); + // When SLOW_CLK_CAL_CYCLES is set to 0, clock calibration will not be performed at startup. if (SLOW_CLK_CAL_CYCLES > 0) { cal_val = rtc_clk_cal(RTC_CAL_EXT_CLK, SLOW_CLK_CAL_CYCLES); diff --git a/components/soc/esp32/include/soc/Kconfig.soc_caps.in b/components/soc/esp32/include/soc/Kconfig.soc_caps.in index ff4c037c10..4e845dd0a3 100644 --- a/components/soc/esp32/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32/include/soc/Kconfig.soc_caps.in @@ -579,6 +579,10 @@ config SOC_SPIRAM_SUPPORTED bool default y +config SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE + bool + default y + config SOC_SHA_SUPPORT_PARALLEL_ENG bool default y @@ -643,6 +647,14 @@ config SOC_PM_SUPPORT_RTC_PERIPH_PD bool default y +config SOC_PM_SUPPORT_RTC_FAST_MEM_PD + bool + default y + +config SOC_PM_SUPPORT_RTC_SLOW_MEM_PD + bool + default y + config SOC_SDMMC_USE_IOMUX bool default y diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index b67980489e..d5c7949bfd 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -310,6 +310,9 @@ /*-------------------------- SPIRAM CAPS -------------------------------------*/ #define SOC_SPIRAM_SUPPORTED 1 +/*-------------------------- SPI MEM CAPS ---------------------------------------*/ +#define SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE (1) + /*--------------------------- SHA CAPS ---------------------------------------*/ /* ESP32 style SHA engine, where multiple states can be stored in parallel */ #define SOC_SHA_SUPPORT_PARALLEL_ENG (1) @@ -346,9 +349,11 @@ #define SOC_PHY_DIG_REGS_MEM_SIZE (21*4) /*-------------------------- Power Management CAPS ---------------------------*/ -#define SOC_PM_SUPPORT_EXT_WAKEUP (1) +#define SOC_PM_SUPPORT_EXT_WAKEUP (1) #define SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP (1) /*!