mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-15 15:00:02 +01:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user