fix(global, log): fix esp_log(_early)_timestamp readings after startup by correct the CCOUNT register when switching CPU clock.

TW#13332, Closes #700
This commit is contained in:
michael
2017-09-13 17:34:43 +08:00
parent 01aad8f386
commit 9d9e771933
3 changed files with 23 additions and 2 deletions

View File

@@ -310,10 +310,13 @@ static inline void heap_swap(int i, int j)
#define ATTR
#endif // BOOTLOADER_BUILD
//the variable defined in ROM is the cpu frequency in MHz.
//as a workaround before the interface for this variable
extern uint32_t g_ticks_per_us_pro;
uint32_t ATTR esp_log_early_timestamp()
{
return xthal_get_ccount() / (CPU_CLK_FREQ_ROM / 1000);
return xthal_get_ccount() / (g_ticks_per_us_pro * 1000);
}
#ifndef BOOTLOADER_BUILD
@@ -324,7 +327,7 @@ uint32_t IRAM_ATTR esp_log_timestamp()
return esp_log_early_timestamp();
}
static uint32_t base = 0;
if (base == 0) {
if (base == 0 && xPortGetCoreID() == 0) {
base = esp_log_early_timestamp();
}
return base + xTaskGetTickCount() * (1000 / configTICK_RATE_HZ);