mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-26 18:07:52 +00:00
esp32: Fix backwards compatibility for pre-v2.1 bootloaders
Older bootloaders don't set RTC_XTAL_FREQ_REG or call rtc_clk_init(), app needs to pick this up. Reported at https://esp32.com/viewtopic.php?f=2&t=3939&p=17836
This commit is contained in:

committed by
Angus Gratton

parent
8688f0ec05
commit
c69af42b96
@@ -776,6 +776,22 @@ config ESP_TIMER_PROFILING
|
||||
used for timer storage, and should only be used for debugging/testing
|
||||
purposes.
|
||||
|
||||
config COMPATIBLE_PRE_V2_1_BOOTLOADERS
|
||||
bool "App compatible with bootloaders before IDF v2.1"
|
||||
default n
|
||||
help
|
||||
Bootloaders before IDF v2.1 did less initialisation of the
|
||||
system clock. This setting needs to be enabled to build an app
|
||||
which can be booted by these older bootloaders.
|
||||
|
||||
If this setting is enabled, the app can be booted by any bootloader
|
||||
from IDF v1.0 up to the current version.
|
||||
|
||||
If this setting is disabled, the app can only be booted by bootloaders
|
||||
from IDF v2.1 or newer.
|
||||
|
||||
Enabling this setting adds approximately 1KB to the app's IRAM usage.
|
||||
|
||||
endmenu # ESP32-Specific
|
||||
|
||||
menu Wi-Fi
|
||||
|
@@ -27,10 +27,10 @@
|
||||
#include "soc/soc.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/i2s_reg.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "xtensa/core-macros.h"
|
||||
#include "bootloader_clock.h"
|
||||
|
||||
/* Number of cycles to wait from the 32k XTAL oscillator to consider it running.
|
||||
* Larger values increase startup delay. Smaller values may cause false positive
|
||||
@@ -54,6 +54,22 @@ void esp_clk_init(void)
|
||||
{
|
||||
rtc_config_t cfg = RTC_CONFIG_DEFAULT();
|
||||
rtc_init(cfg);
|
||||
|
||||
#ifdef CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS
|
||||
/* Check the bootloader set the XTAL frequency.
|
||||
|
||||
Bootloaders pre-v2.1 don't do this.
|
||||
*/
|
||||
rtc_xtal_freq_t xtal_freq = rtc_clk_xtal_freq_get();
|
||||
if (xtal_freq == RTC_XTAL_FREQ_AUTO) {
|
||||
ESP_EARLY_LOGW(TAG, "RTC domain not initialised by bootloader");
|
||||
bootloader_clock_configure();
|
||||
}
|
||||
#else
|
||||
/* If this assertion fails, either upgrade the bootloader or enable CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS */
|
||||
assert(rtc_clk_xtal_freq_get() != RTC_XTAL_FREQ_AUTO);
|
||||
#endif
|
||||
|
||||
rtc_clk_fast_freq_set(RTC_FAST_FREQ_8M);
|
||||
|
||||
#ifdef CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
|
||||
|
Reference in New Issue
Block a user