mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 01:27:11 +08:00
fix(log): Fix log time mismatch
When system startup, using 2*crystal as clock source.
This commit is contained in:
@ -178,11 +178,6 @@ bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_dat
|
|||||||
|
|
||||||
static const char *TAG = "bootloader_common";
|
static const char *TAG = "bootloader_common";
|
||||||
|
|
||||||
static inline uint32_t esp_log_early_timestamp()
|
|
||||||
{
|
|
||||||
return xthal_get_ccount() / (80 * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t bootloader_common_ota_select_crc(const esp_ota_select_entry_t *s)
|
uint32_t bootloader_common_ota_select_crc(const esp_ota_select_entry_t *s)
|
||||||
{
|
{
|
||||||
return crc32_le(UINT32_MAX, (uint8_t*)&s->ota_seq, 4);
|
return crc32_le(UINT32_MAX, (uint8_t*)&s->ota_seq, 4);
|
||||||
|
@ -200,6 +200,19 @@ config ESP8266_CORE_GLOBAL_DATA_LINK_IRAM
|
|||||||
help
|
help
|
||||||
Link libcore.a internal global data(.bss .data COMMON) from DRAM to IRAM.
|
Link libcore.a internal global data(.bss .data COMMON) from DRAM to IRAM.
|
||||||
|
|
||||||
|
choice CRYSTAL_USED
|
||||||
|
prompt "Crystal used in your module or board"
|
||||||
|
default CRYSTAL_USED_26MHZ
|
||||||
|
help
|
||||||
|
For most modules, 26MHz is the default crystal. If you use special module,
|
||||||
|
you can reconfigure this option.
|
||||||
|
|
||||||
|
config CRYSTAL_USED_26MHZ
|
||||||
|
bool "26MHz"
|
||||||
|
config CRYSTAL_USED_40MHZ
|
||||||
|
bool "40MHz"
|
||||||
|
endchoice
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu WIFI
|
menu WIFI
|
||||||
|
@ -19,10 +19,20 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
|
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_CRYSTAL_USED_26MHZ
|
||||||
|
#define CRYSTAL_USED 26
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_CRYSTAL_USED_40MHZ
|
||||||
|
#define CRYSTAL_USED 40
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ESP_MAC_WIFI_STA,
|
ESP_MAC_WIFI_STA,
|
||||||
ESP_MAC_WIFI_SOFTAP,
|
ESP_MAC_WIFI_SOFTAP,
|
||||||
|
@ -113,7 +113,7 @@ void esp_reset_reason_init(void)
|
|||||||
esp_reset_reason_clear_hint();
|
esp_reset_reason_clear_hint();
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_EARLY_LOGI(TAG, "RTC reset %u wakeup %u store %u, reason is %u", hw_reset, hw_wakeup, hint, s_reset_reason);
|
ESP_LOGI(TAG, "RTC reset %u wakeup %u store %u, reason is %u", hw_reset, hw_wakeup, hint, s_reset_reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,6 +78,16 @@ void esp_log_level_set(const char* tag, esp_log_level_t level);
|
|||||||
*/
|
*/
|
||||||
putchar_like_t esp_log_set_putchar(putchar_like_t func);
|
putchar_like_t esp_log_set_putchar(putchar_like_t func);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Function which returns timestamp to be used in log output
|
||||||
|
*
|
||||||
|
* This function uses HW cycle counter and does not depend on OS,
|
||||||
|
* so it can be safely used after application crash.
|
||||||
|
*
|
||||||
|
* @return timestamp, in milliseconds
|
||||||
|
*/
|
||||||
|
uint32_t esp_log_early_timestamp(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Write message into the log
|
* @brief Write message into the log
|
||||||
*
|
*
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "xtensa/hal.h"
|
#include "xtensa/hal.h"
|
||||||
|
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
#include "esp_system.h"
|
||||||
|
|
||||||
#ifdef CONFIG_LOG_COLORS
|
#ifdef CONFIG_LOG_COLORS
|
||||||
#define LOG_COLOR "\033[0;%dm"
|
#define LOG_COLOR "\033[0;%dm"
|
||||||
@ -52,9 +53,9 @@ static const char s_log_prefix[ESP_LOG_MAX] = {
|
|||||||
'V', // ESP_LOG_VERBOSE
|
'V', // ESP_LOG_VERBOSE
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint32_t IRAM_ATTR esp_log_early_timestamp()
|
uint32_t IRAM_ATTR esp_log_early_timestamp()
|
||||||
{
|
{
|
||||||
return xthal_get_ccount() / (80 * 1000);
|
return xthal_get_ccount() / ((CRYSTAL_USED * 2) * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOTLOADER_BUILD
|
#ifndef BOOTLOADER_BUILD
|
||||||
@ -191,7 +192,13 @@ static int esp_log_write_str(const char *s)
|
|||||||
|
|
||||||
static uint32_t esp_log_timestamp()
|
static uint32_t esp_log_timestamp()
|
||||||
{
|
{
|
||||||
return clock() * (1000 / CLOCKS_PER_SEC) + esp_log_early_timestamp() % (1000 / CLOCKS_PER_SEC);
|
static uint32_t base = 0;
|
||||||
|
|
||||||
|
if (base == 0) {
|
||||||
|
base = esp_log_early_timestamp();
|
||||||
|
}
|
||||||
|
|
||||||
|
return base + clock() * (1000 / CLOCKS_PER_SEC);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user