mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 20:54:32 +02:00
Merge branch 'bugfix/recalib_bbpll_before_tuning_v5.0' into 'release/v5.0'
fix(bbpll): fix bbpll may not lock or not stable bug for stop early (ESP32C2/S3/C6/H2) (v5.0) See merge request espressif/esp-idf!28286
This commit is contained in:
@@ -128,6 +128,7 @@ static void rtc_clk_bbpll_configure(rtc_xtal_freq_t xtal_freq, int pll_freq)
|
|||||||
clk_ll_bbpll_set_config(pll_freq, xtal_freq);
|
clk_ll_bbpll_set_config(pll_freq, xtal_freq);
|
||||||
/* WAIT CALIBRATION DONE */
|
/* WAIT CALIBRATION DONE */
|
||||||
while(!regi2c_ctrl_ll_bbpll_calibration_is_done());
|
while(!regi2c_ctrl_ll_bbpll_calibration_is_done());
|
||||||
|
esp_rom_delay_us(10);
|
||||||
/* BBPLL CALIBRATION STOP */
|
/* BBPLL CALIBRATION STOP */
|
||||||
regi2c_ctrl_ll_bbpll_calibration_stop();
|
regi2c_ctrl_ll_bbpll_calibration_stop();
|
||||||
|
|
||||||
@@ -350,6 +351,24 @@ bool rtc_dig_8m_enabled(void)
|
|||||||
return clk_ll_rc_fast_digi_is_enabled();
|
return clk_ll_rc_fast_digi_is_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Workaround for bootloader not calibrated well issue.
|
||||||
|
// Placed in IRAM because disabling BBPLL may influence the cache
|
||||||
|
void rtc_clk_recalib_bbpll(void)
|
||||||
|
{
|
||||||
|
rtc_cpu_freq_config_t old_config;
|
||||||
|
rtc_clk_cpu_freq_get_config(&old_config);
|
||||||
|
|
||||||
|
// There are two paths we arrive here: 1. CPU reset. 2. Other reset reasons.
|
||||||
|
// - For other reasons, the bootloader will set CPU source to BBPLL and enable it. But there are calibration issues.
|
||||||
|
// Turn off the BBPLL and do calibration again to fix the issue.
|
||||||
|
// - For CPU reset, the CPU source will be set to XTAL, while the BBPLL is kept to meet USB Serial JTAG's
|
||||||
|
// requirements. In this case, we don't touch BBPLL to avoid USJ disconnection.
|
||||||
|
if (old_config.source == SOC_CPU_CLK_SRC_PLL) {
|
||||||
|
rtc_clk_cpu_freq_set_xtal();
|
||||||
|
rtc_clk_cpu_freq_set_config(&old_config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Name used in libphy.a:phy_chip_v7.o
|
/* Name used in libphy.a:phy_chip_v7.o
|
||||||
* TODO: update the library to use rtc_clk_xtal_freq_get
|
* TODO: update the library to use rtc_clk_xtal_freq_get
|
||||||
*/
|
*/
|
||||||
|
@@ -140,6 +140,7 @@ static void rtc_clk_bbpll_configure(rtc_xtal_freq_t xtal_freq, int pll_freq)
|
|||||||
clk_ll_bbpll_set_config(pll_freq, xtal_freq);
|
clk_ll_bbpll_set_config(pll_freq, xtal_freq);
|
||||||
// Wait until calibration finishes
|
// Wait until calibration finishes
|
||||||
while (!regi2c_ctrl_ll_bbpll_calibration_is_done());
|
while (!regi2c_ctrl_ll_bbpll_calibration_is_done());
|
||||||
|
esp_rom_delay_us(10);
|
||||||
// Prevent BBPLL clock jitter
|
// Prevent BBPLL clock jitter
|
||||||
regi2c_ctrl_ll_bbpll_calibration_stop();
|
regi2c_ctrl_ll_bbpll_calibration_stop();
|
||||||
s_cur_pll_freq = pll_freq;
|
s_cur_pll_freq = pll_freq;
|
||||||
|
@@ -162,6 +162,7 @@ static void rtc_clk_bbpll_configure(rtc_xtal_freq_t xtal_freq, int pll_freq)
|
|||||||
clk_ll_bbpll_set_config(pll_freq, xtal_freq);
|
clk_ll_bbpll_set_config(pll_freq, xtal_freq);
|
||||||
/* WAIT CALIBRATION DONE */
|
/* WAIT CALIBRATION DONE */
|
||||||
while(!regi2c_ctrl_ll_bbpll_calibration_is_done());
|
while(!regi2c_ctrl_ll_bbpll_calibration_is_done());
|
||||||
|
esp_rom_delay_us(10);
|
||||||
/* BBPLL CALIBRATION STOP */
|
/* BBPLL CALIBRATION STOP */
|
||||||
regi2c_ctrl_ll_bbpll_calibration_stop();
|
regi2c_ctrl_ll_bbpll_calibration_stop();
|
||||||
|
|
||||||
@@ -458,6 +459,25 @@ static bool rtc_clk_set_bbpll_always_on(void)
|
|||||||
return is_bbpll_on;
|
return is_bbpll_on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Workaround for bootloader not calibrated well issue.
|
||||||
|
// Placed in IRAM because disabling BBPLL may influence the cache
|
||||||
|
void rtc_clk_recalib_bbpll(void)
|
||||||
|
{
|
||||||
|
rtc_cpu_freq_config_t old_config;
|
||||||
|
rtc_clk_cpu_freq_get_config(&old_config);
|
||||||
|
|
||||||
|
// There are two paths we arrive here: 1. CPU reset. 2. Other reset reasons.
|
||||||
|
// - For other reasons, the bootloader will set CPU source to BBPLL and enable it. But there are calibration issues.
|
||||||
|
// Turn off the BBPLL and do calibration again to fix the issue.
|
||||||
|
// - For CPU reset, the CPU source will be set to XTAL, while the BBPLL is kept to meet USB Serial JTAG's
|
||||||
|
// requirements. In this case, we don't touch BBPLL to avoid USJ disconnection.
|
||||||
|
if (old_config.source == SOC_CPU_CLK_SRC_PLL) {
|
||||||
|
rtc_clk_cpu_freq_set_xtal();
|
||||||
|
rtc_clk_cpu_freq_set_config(&old_config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Name used in libphy.a:phy_chip_v7.o
|
/* Name used in libphy.a:phy_chip_v7.o
|
||||||
* TODO: update the library to use rtc_clk_xtal_freq_get
|
* TODO: update the library to use rtc_clk_xtal_freq_get
|
||||||
*/
|
*/
|
||||||
|
@@ -543,6 +543,15 @@ menu "ESP System Settings"
|
|||||||
(2). For special workflow, the chip needs do more things instead of restarting directly. This part
|
(2). For special workflow, the chip needs do more things instead of restarting directly. This part
|
||||||
needs to be done in callback function of interrupt.
|
needs to be done in callback function of interrupt.
|
||||||
|
|
||||||
|
config ESP_SYSTEM_BBPLL_RECALIB
|
||||||
|
bool "Re-calibration BBPLL at startup"
|
||||||
|
depends on IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32S3
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
This configuration helps to address an BBPLL inaccurate issue when boot from certain bootloader version,
|
||||||
|
which may increase about the boot-up time by about 200 us. Disable this when your bootloader is built with
|
||||||
|
ESP-IDF version v5.2 and above.
|
||||||
|
|
||||||
endmenu # ESP System Settings
|
endmenu # ESP System Settings
|
||||||
|
|
||||||
menu "IPC (Inter-Processor Call)"
|
menu "IPC (Inter-Processor Call)"
|
||||||
|
@@ -428,8 +428,16 @@ void IRAM_ATTR call_start_cpu0(void)
|
|||||||
* In this stage, we re-configure the Flash (and MSPI) to required configuration
|
* In this stage, we re-configure the Flash (and MSPI) to required configuration
|
||||||
*/
|
*/
|
||||||
spi_flash_init_chip_state();
|
spi_flash_init_chip_state();
|
||||||
|
|
||||||
|
// In earlier version of ESP-IDF, the PLL provided by bootloader is not stable enough.
|
||||||
|
// Do calibration again here so that we can use better clock for the timing tuning.
|
||||||
|
#if CONFIG_ESP_SYSTEM_BBPLL_RECALIB
|
||||||
|
extern void rtc_clk_recalib_bbpll(void);
|
||||||
|
rtc_clk_recalib_bbpll();
|
||||||
|
#endif
|
||||||
#if CONFIG_IDF_TARGET_ESP32S3
|
#if CONFIG_IDF_TARGET_ESP32S3
|
||||||
//On other chips, this feature is not provided by HW, or hasn't been tested yet.
|
// This function needs to be called when PLL is enabled
|
||||||
|
// On other chips, this feature is not provided by HW, or hasn't been tested yet.
|
||||||
spi_timing_flash_tuning();
|
spi_timing_flash_tuning();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user