From 47c9382cc2bd005555241e58a9bb1eb65ed0042e Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Thu, 24 Oct 2024 16:28:05 +0800 Subject: [PATCH] fix(clk): add an inevitable kconfig option to be selected to use rc32k --- components/esp_hw_support/CMakeLists.txt | 4 ---- components/esp_hw_support/port/esp32c6/Kconfig.rtc | 10 ++++++++-- components/esp_hw_support/port/esp32h2/Kconfig.rtc | 9 ++------- components/esp_hw_support/port/esp32p4/Kconfig.rtc | 9 ++------- components/esp_system/port/soc/esp32h2/clk.c | 2 -- components/esp_system/port/soc/esp32p4/clk.c | 2 -- components/soc/esp32c6/include/soc/clk_tree_defs.h | 2 +- components/soc/esp32h2/include/soc/clk_tree_defs.h | 2 +- components/soc/esp32p4/include/soc/clk_tree_defs.h | 2 +- docs/en/api-reference/peripherals/clk_tree.rst | 6 ------ docs/en/api-reference/system/system_time.rst | 2 -- docs/zh_CN/api-reference/peripherals/clk_tree.rst | 6 ------ docs/zh_CN/api-reference/system/system_time.rst | 2 -- 13 files changed, 15 insertions(+), 43 deletions(-) diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index 5f09311acd..ba75fa1706 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -16,10 +16,6 @@ if(${target} STREQUAL "esp32c6") list(APPEND priv_requires hal) endif() -if(CONFIG_RTC_CLK_SRC_INT_RC32K) - message(WARNING "Internal RC32K clock is unstable at extreme temperatures and is not recommended for use.") -endif() - set(srcs "cpu.c" "port/${IDF_TARGET}/esp_cpu_intr.c" "esp_memory_utils.c" "port/${IDF_TARGET}/cpu_region_protect.c") if(NOT BOOTLOADER_BUILD) list(APPEND srcs "esp_clk.c" diff --git a/components/esp_hw_support/port/esp32c6/Kconfig.rtc b/components/esp_hw_support/port/esp32c6/Kconfig.rtc index 4a2e10d181..9e2c8df1db 100644 --- a/components/esp_hw_support/port/esp32c6/Kconfig.rtc +++ b/components/esp_hw_support/port/esp32c6/Kconfig.rtc @@ -13,12 +13,18 @@ choice RTC_CLK_SRC bool "External 32kHz oscillator at 32K_XP pin" select ESP_SYSTEM_RTC_EXT_OSC config RTC_CLK_SRC_INT_RC32K - bool "Internal 32kHz RC oscillator" + bool "Internal 32kHz RC oscillator (NOT RECOMMENDED TO USE, READ DOCS FIRST)" + depends on RTC_CLK_SRC_USE_DANGEROUS_RC32K_ALLOWED help - Internal RC32K clock is unstable at extreme temperatures and is not recommended for use. + To be able to select this option, please select `RTC_CLK_SRC_USE_DANGEROUS_RC32K_ALLOWED` first. This option will be removed in IDF v6.0. endchoice +config RTC_CLK_SRC_USE_DANGEROUS_RC32K_ALLOWED + bool "Confirm to use the unrecommended 32 kHz RC oscillator (READ DOCS FIRST)" + help + Internal RC32K clock is unstable at extreme temperatures and is not recommended for use. + config RTC_CLK_CAL_CYCLES int "Number of cycles for RTC_SLOW_CLK calibration" default 3000 if RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC || RTC_CLK_SRC_INT_RC32K diff --git a/components/esp_hw_support/port/esp32h2/Kconfig.rtc b/components/esp_hw_support/port/esp32h2/Kconfig.rtc index 4a2e10d181..69ebccc1b9 100644 --- a/components/esp_hw_support/port/esp32h2/Kconfig.rtc +++ b/components/esp_hw_support/port/esp32h2/Kconfig.rtc @@ -12,18 +12,13 @@ choice RTC_CLK_SRC config RTC_CLK_SRC_EXT_OSC bool "External 32kHz oscillator at 32K_XP pin" select ESP_SYSTEM_RTC_EXT_OSC - config RTC_CLK_SRC_INT_RC32K - bool "Internal 32kHz RC oscillator" - help - Internal RC32K clock is unstable at extreme temperatures and is not recommended for use. - This option will be removed in IDF v6.0. endchoice config RTC_CLK_CAL_CYCLES int "Number of cycles for RTC_SLOW_CLK calibration" - default 3000 if RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC || RTC_CLK_SRC_INT_RC32K + default 3000 if RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC default 1024 if RTC_CLK_SRC_INT_RC - range 0 8190 if RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC || RTC_CLK_SRC_INT_RC32K + range 0 8190 if RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC range 0 32766 if RTC_CLK_SRC_INT_RC help When the startup code initializes RTC_SLOW_CLK, it can perform diff --git a/components/esp_hw_support/port/esp32p4/Kconfig.rtc b/components/esp_hw_support/port/esp32p4/Kconfig.rtc index 1202c00841..b485be2951 100644 --- a/components/esp_hw_support/port/esp32p4/Kconfig.rtc +++ b/components/esp_hw_support/port/esp32p4/Kconfig.rtc @@ -14,18 +14,13 @@ choice RTC_CLK_SRC config RTC_CLK_SRC_EXT_OSC bool "External 32kHz oscillator at 32K_XP pin" select ESP_SYSTEM_RTC_EXT_OSC - config RTC_CLK_SRC_INT_RC32K - bool "Internal 32kHz RC oscillator" - help - Internal RC32K clock is unstable at extreme temperatures and is not recommended for use. - This option will be removed in IDF v6.0. endchoice config RTC_CLK_CAL_CYCLES int "Number of cycles for RTC_SLOW_CLK calibration" - default 3000 if RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC || RTC_CLK_SRC_INT_8MD256 + default 3000 if RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC default 1024 if RTC_CLK_SRC_INT_RC - range 0 8190 if RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_INT_RC32K + range 0 8190 if RTC_CLK_SRC_EXT_CRYS range 0 32766 if RTC_CLK_SRC_INT_RC help When the startup code initializes RTC_SLOW_CLK, it can perform diff --git a/components/esp_system/port/soc/esp32h2/clk.c b/components/esp_system/port/soc/esp32h2/clk.c index 5ad4f611bc..84a248e80e 100644 --- a/components/esp_system/port/soc/esp32h2/clk.c +++ b/components/esp_system/port/soc/esp32h2/clk.c @@ -87,8 +87,6 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_XTAL32K); #elif defined(CONFIG_RTC_CLK_SRC_EXT_OSC) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_OSC_SLOW); -#elif defined(CONFIG_RTC_CLK_SRC_INT_RC32K) - select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC32K); #else select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC_SLOW); #endif diff --git a/components/esp_system/port/soc/esp32p4/clk.c b/components/esp_system/port/soc/esp32p4/clk.c index 3ef6347f73..e3e2ff9409 100644 --- a/components/esp_system/port/soc/esp32p4/clk.c +++ b/components/esp_system/port/soc/esp32p4/clk.c @@ -73,8 +73,6 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_XTAL32K); #elif defined(CONFIG_RTC_CLK_SRC_EXT_OSC) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_OSC_SLOW); -#elif defined(CONFIG_RTC_CLK_SRC_INT_RC32K) - select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC32K); #else select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC_SLOW); #endif diff --git a/components/soc/esp32c6/include/soc/clk_tree_defs.h b/components/soc/esp32c6/include/soc/clk_tree_defs.h index 5480c62dff..c65dfda315 100644 --- a/components/soc/esp32c6/include/soc/clk_tree_defs.h +++ b/components/soc/esp32c6/include/soc/clk_tree_defs.h @@ -24,7 +24,7 @@ extern "C" { * This RC oscillator generates a ~136kHz clock signal output as the RC_SLOW_CLK. The exact frequency of this clock * can be computed in runtime through calibration. * - * 4) Internal 32kHz RC Oscillator: RC32K + * 4) Internal 32kHz RC Oscillator: RC32K [NOT RECOMMENDED TO USE] * * The exact frequency of this clock can be computed in runtime through calibration. * diff --git a/components/soc/esp32h2/include/soc/clk_tree_defs.h b/components/soc/esp32h2/include/soc/clk_tree_defs.h index 76dd38caab..c8df9097fd 100644 --- a/components/soc/esp32h2/include/soc/clk_tree_defs.h +++ b/components/soc/esp32h2/include/soc/clk_tree_defs.h @@ -24,7 +24,7 @@ extern "C" { * This RC oscillator generates a ~136kHz clock signal output as the RC_SLOW_CLK. The exact frequency of this clock * can be computed in runtime through calibration. * - * 4) Internal 32kHz RC Oscillator: RC32K + * 4) Internal 32kHz RC Oscillator: RC32K [NOT RECOMMENDED TO USE] * * The exact frequency of this clock can be computed in runtime through calibration. * diff --git a/components/soc/esp32p4/include/soc/clk_tree_defs.h b/components/soc/esp32p4/include/soc/clk_tree_defs.h index 6d84a96525..701c657b94 100644 --- a/components/soc/esp32p4/include/soc/clk_tree_defs.h +++ b/components/soc/esp32p4/include/soc/clk_tree_defs.h @@ -26,7 +26,7 @@ extern "C" { * This RC oscillator generates a ~136kHz clock signal output as the RC_SLOW_CLK. The exact frequency of this clock * can be computed in runtime through calibration. * - * 4) Internal 32kHz RC Oscillator: RC32K + * 4) Internal 32kHz RC Oscillator: RC32K [NOT RECOMMENDED TO USE] * * The exact frequency of this clock can be computed in runtime through calibration. * diff --git a/docs/en/api-reference/peripherals/clk_tree.rst b/docs/en/api-reference/peripherals/clk_tree.rst index 0784c062f4..eac4a94e52 100644 --- a/docs/en/api-reference/peripherals/clk_tree.rst +++ b/docs/en/api-reference/peripherals/clk_tree.rst @@ -75,12 +75,6 @@ Root clocks generate reliable clock signals. These clock signals then pass throu A clock signal generated by an external circuit can be connected to {IDF_TARGET_RC_SLOW_CLK} to be the clock source for the ``RTC_SLOW_CLK``. This clock can also be calibrated to get its exact frequency. - .. only:: SOC_CLK_RC32K_SUPPORTED - - - Internal 32 kHz RC Oscillator (RC32K) - - The exact frequency of this clock can be computed in runtime through calibration. - Typically, the frequency of the signal generated from an RC oscillator circuit is less accurate and more sensitive to the environment compared to the signal generated from a crystal. {IDF_TARGET_NAME} provides several clock source options for the ``RTC_SLOW_CLK``, and it is possible to make the choice based on the requirements for system time accuracy and power consumption. For more details, please refer to :ref:`rtc-clock-source-choice`. Module Clocks diff --git a/docs/en/api-reference/system/system_time.rst b/docs/en/api-reference/system/system_time.rst index f959f1c42c..5c55a7b271 100644 --- a/docs/en/api-reference/system/system_time.rst +++ b/docs/en/api-reference/system/system_time.rst @@ -47,8 +47,6 @@ The RTC timer has the following clock sources: :not esp32c6 and not esp32h2 and not esp32p4: - ``Internal {IDF_TARGET_INT_OSC_FRE} oscillator, divided by 256 ({IDF_TARGET_INT_OSC_FRE_DIVIDED})``: Provides better frequency stability than the ``Internal {IDF_TARGET_RTC_CLK_FRE} RC oscillator`` at the expense of a higher (by 5 μA) Deep-sleep current consumption. It also does not require external components. - :esp32c6 or esp32h2 or esp32p4: - ``Internal 32 kHz RC oscillator`` - The choice depends on your requirements for system time accuracy and power consumption in sleep modes. To modify the RTC clock source, set :ref:`CONFIG_RTC_CLK_SRC` in project configuration. More details about the wiring requirements for the external crystal or external oscillator, please refer to {IDF_TARGET_HARDWARE_DESIGN_URL}. diff --git a/docs/zh_CN/api-reference/peripherals/clk_tree.rst b/docs/zh_CN/api-reference/peripherals/clk_tree.rst index 0ef695d7a2..4533223231 100644 --- a/docs/zh_CN/api-reference/peripherals/clk_tree.rst +++ b/docs/zh_CN/api-reference/peripherals/clk_tree.rst @@ -75,12 +75,6 @@ 将外部电路生成的时钟信号连接到 {IDF_TARGET_RC_SLOW_CLK},可作为 ``RTC_SLOW_CLK`` 的时钟源。通过校准,可以计算该时钟信号的实际频率。 - .. only:: SOC_CLK_RC32K_SUPPORTED - - - 内部 32 kHz RC 振荡器 (RC32K) - - 在运行时,通过校准,可以计算该时钟信号的实际频率。 - 与晶振产生的信号相比,从 RC 振荡器电路产生的信号通常精度较低,且容易受环境影响。因此,{IDF_TARGET_NAME} 为 ``RTC_SLOW_CLK`` 提供了几种时钟源选项,可以根据对系统时间精度和对功耗的要求选择。更多详情,请参阅 :ref:`rtc-clock-source-choice`。 模块时钟 diff --git a/docs/zh_CN/api-reference/system/system_time.rst b/docs/zh_CN/api-reference/system/system_time.rst index f14dc18861..c12e4676c3 100644 --- a/docs/zh_CN/api-reference/system/system_time.rst +++ b/docs/zh_CN/api-reference/system/system_time.rst @@ -47,8 +47,6 @@ RTC 定时器有以下时钟源: :not esp32c6 and not esp32h2 and not esp32p4: - ``内置 {IDF_TARGET_INT_OSC_FRE} 振荡器的 256 分频时钟 ({IDF_TARGET_INT_OSC_FRE_DIVIDED})``:频率稳定性优于 ``内置 {IDF_TARGET_RTC_CLK_FRE} RC 振荡器``,同样无需外部元件,但 Deep-sleep 模式下电流消耗更高(比默认模式高 5 μA)。 - :esp32c6 or esp32h2 or esp32p4: - ``内置 32 kHz RC 振荡器`` - 时钟源的选择取决于系统时间精度要求和睡眠模式下的功耗要求。要修改 RTC 时钟源,请在项目配置中设置 :ref:`CONFIG_RTC_CLK_SRC`。 想要了解外置晶振或外置振荡器的更多布线要求,请参考 {IDF_TARGET_HARDWARE_DESIGN_URL}。