From 835cc551384b47f9e5147236817f69804f9e3bf6 Mon Sep 17 00:00:00 2001 From: Wu Jian Gang Date: Wed, 21 Sep 2016 16:15:42 +0800 Subject: [PATCH 1/2] esp32: wait uart tx finish before cpu freq change --- components/esp32/cpu_freq.c | 13 ++++++++++++- components/esp32/include/soc/cpu.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/components/esp32/cpu_freq.c b/components/esp32/cpu_freq.c index c4bca44f0e..327ea63867 100644 --- a/components/esp32/cpu_freq.c +++ b/components/esp32/cpu_freq.c @@ -14,6 +14,7 @@ #include #include "rom/ets_sys.h" +#include "rom/uart.h" #include "sdkconfig.h" typedef enum{ @@ -42,10 +43,15 @@ extern void rtc_set_cpu_freq(xtal_freq_t xtal_freq, cpu_freq_t cpu_freq); * components which want to be notified of CPU frequency * changes. */ -void esp_set_cpu_freq() +void esp_set_cpu_freq(void) { uint32_t freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; phy_get_romfunc_addr(); + + // freq will be changed to 40MHz in rtc_init_lite, + // wait uart tx finish, otherwise some uart output will be lost + uart_tx_wait_idle(0); + rtc_init_lite(); cpu_freq_t freq = CPU_80M; switch(freq_mhz) { @@ -62,6 +68,11 @@ void esp_set_cpu_freq() freq = CPU_80M; break; } + + // freq will be changed to freq in rtc_set_cpu_freq, + // wait uart tx finish, otherwise some uart output will be lost + uart_tx_wait_idle(0); + rtc_set_cpu_freq(XTAL_AUTO, freq); ets_update_cpu_frequency(freq_mhz); } diff --git a/components/esp32/include/soc/cpu.h b/components/esp32/include/soc/cpu.h index 9943a2783e..c74ba317c8 100644 --- a/components/esp32/include/soc/cpu.h +++ b/components/esp32/include/soc/cpu.h @@ -76,6 +76,6 @@ static inline void cpu_configure_region_protection() * This is a temporary function which will be replaced once dynamic * CPU frequency changing is implemented. */ -void esp_set_cpu_freq(); +void esp_set_cpu_freq(void); #endif From 134649141c683380ad0a96a39eef72a8d382fde3 Mon Sep 17 00:00:00 2001 From: Wu Jian Gang Date: Wed, 21 Sep 2016 16:49:30 +0800 Subject: [PATCH 2/2] esp32/lib: update to 9f26b9a1 1. Fix reboot halt bug, TW7355 2. Fix system crash when calling system_deep_sleep(), TW7356 --- components/esp32/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp32/lib b/components/esp32/lib index 9403d944b6..9f26b9a190 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit 9403d944b6cfe682025e2ed9eef7e5d0841c6592 +Subproject commit 9f26b9a190e6a6ca42656685df9287253badfa46