diff --git a/components/esp32s2/Kconfig b/components/esp32s2/Kconfig index 04aa92425f..22f37f0691 100644 --- a/components/esp32s2/Kconfig +++ b/components/esp32s2/Kconfig @@ -457,6 +457,16 @@ menu "ESP32S2-specific" In case more value will help improve the definition of the launch of the crystal. If the crystal could not start, it will be switched to internal RC. + config ESP32S2_RTC_XTAL_CAL_RETRY + int "Number of attempts to repeat 32k XTAL calibration" + default 3 + depends on ESP32S2_RTC_CLK_SRC_EXT_CRYS + help + Number of attempts to repeat 32k XTAL calibration + before giving up and switching to the internal RC. + Increase this option if the 32k crystal oscillator + does not start and switches to internal RC. + config ESP32S2_DISABLE_BASIC_ROM_CONSOLE bool "Permanently disable BASIC ROM Console" default n diff --git a/components/esp32s2/clk.c b/components/esp32s2/clk.c index f698eb29db..49b8ec1355 100644 --- a/components/esp32s2/clk.c +++ b/components/esp32s2/clk.c @@ -42,6 +42,12 @@ */ #define SLOW_CLK_CAL_CYCLES CONFIG_ESP32S2_RTC_CLK_CAL_CYCLES +#ifdef CONFIG_ESP32S2_RTC_XTAL_CAL_RETRY +#define RTC_XTAL_CAL_RETRY CONFIG_ESP32S2_RTC_XTAL_CAL_RETRY +#else +#define RTC_XTAL_CAL_RETRY 1 +#endif + #define MHZ (1000000) /* Lower threshold for a reasonably-looking calibration value for a 32k XTAL. @@ -148,11 +154,7 @@ static void select_rtc_slow_clk(slow_clk_sel_t slow_clk) /* number of times to repeat 32k XTAL calibration * before giving up and switching to the internal RC */ -#ifdef CONFIG_IDF_TARGET_ESP32 - int retry_32k_xtal = 1; /* don't change the behavior for the ESP32 */ -#else - int retry_32k_xtal = 3; -#endif + int retry_32k_xtal = RTC_XTAL_CAL_RETRY; do { if (rtc_slow_freq == RTC_SLOW_FREQ_32K_XTAL) {