]> granicus.if.org Git - esp-idf/commitdiff
deep sleep: fix regression due to moving ets_update_cpu_frequency into IRAM
authorIvan Grokhotkov <igrokhotkov@gmail.com>
Wed, 11 Jan 2017 09:17:13 +0000 (17:17 +0800)
committerIvan Grokhotkov <igrokhotkov@gmail.com>
Thu, 12 Jan 2017 06:15:25 +0000 (14:15 +0800)
Deep sleep stub may call ets_update_cpu_frequency, which has been moved from ROM to IRAM.
Restore the ROM version in the linker script, call it ets_update_cpu_frequency_rom, use it in the deep sleep stub.

components/esp32/deep_sleep.c
components/esp32/include/rom/ets_sys.h
components/esp32/ld/esp32.rom.ld

index 7f59c21635098fee6edba62f64f60e083ac300a1..774fd4ce7afdc3fea93685e555130b6235f3ec1a 100644 (file)
@@ -91,7 +91,7 @@ void RTC_IRAM_ATTR esp_default_wake_deep_sleep(void) {
 #if CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY > 0
     // ROM code has not started yet, so we need to set delay factor
     // used by ets_delay_us first.
-    ets_update_cpu_frequency(ets_get_detected_xtal_freq() / 1000000);
+    ets_update_cpu_frequency_rom(ets_get_detected_xtal_freq() / 1000000);
     // This delay is configured in menuconfig, it can be used to give
     // the flash chip some time to become ready.
     ets_delay_us(CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY);
index 690691675af8c6afd23abd15f679f25d2ac869ba..0f972f2c3387a0e2db6e19a9cb32a0258ca5b00e 100644 (file)
@@ -383,6 +383,18 @@ void ets_delay_us(uint32_t us);
   */
 void ets_update_cpu_frequency(uint32_t ticks_per_us);
 
+/**
+  * @brief  Set the real CPU ticks per us to the ets, so that ets_delay_us will be accurate.
+  *
+  * @note This function only sets the tick rate for the current CPU. It is located in ROM,
+  *       so the deep sleep stub can use it even if IRAM is not initialized yet.
+  *
+  * @param  uint32_t ticks_per_us : CPU ticks per us.
+  *
+  * @return None
+  */
+void ets_update_cpu_frequency_rom(uint32_t ticks_per_us);
+
 /**
   * @brief  Get the real CPU ticks per us to the ets.
   *         This function do not return real CPU ticks per us, just the record in ets. It can be used to check with the real CPU frequency.
index 33309894dc294ffec11f1ae8151561d97104e8c9..7543fa42aa7245b6e75cdbc81c754ac9a9c5aed6 100644 (file)
@@ -202,7 +202,7 @@ PROVIDE ( ets_timer_init = 0x400084e8 );
 PROVIDE ( ets_timer_setfn = 0x40008350 );
 PROVIDE ( ets_unpack_flash_code = 0x40007018 );
 PROVIDE ( ets_unpack_flash_code_legacy = 0x4000694c );
-/* PROVIDE ( ets_update_cpu_frequency = 0x40008550 ); */ /* Updates g_ticks_per_us on the current CPU only; not on the other core */
+PROVIDE ( ets_update_cpu_frequency_rom = 0x40008550 ); /* Updates g_ticks_per_us on the current CPU only; not on the other core */
 PROVIDE ( ets_waiti0 = 0x400067d8 );
 PROVIDE ( exc_cause_table = 0x3ff991d0 );
 PROVIDE ( _exit_r = 0x4000bd28 );