From 7188f925f9aa85c4aaeab45fe9f0e91694881e8d Mon Sep 17 00:00:00 2001 From: Xudong Zheng <7pkvm5aw@slicealias.com> Date: Fri, 7 Jul 2023 22:56:09 -0400 Subject: [PATCH] logging: fix timestamp scaling with 64-bit timestamp In default_get_timestamp(), sys_clock_tick_get() is returned when CONFIG_LOG_TIMESTAMP_64BIT=y. The timestamp frequency should reflect this. Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com> --- subsys/logging/log_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c index 8e7f739d0c4..8322732d434 100644 --- a/subsys/logging/log_core.c +++ b/subsys/logging/log_core.c @@ -237,8 +237,9 @@ void log_core_init(void) if (sys_clock_hw_cycles_per_sec() > 1000000) { log_set_timestamp_func(default_lf_get_timestamp, 1000U); } else { - log_set_timestamp_func(default_get_timestamp, - sys_clock_hw_cycles_per_sec()); + uint32_t freq = IS_ENABLED(CONFIG_LOG_TIMESTAMP_64BIT) ? + CONFIG_SYS_CLOCK_TICKS_PER_SEC : sys_clock_hw_cycles_per_sec(); + log_set_timestamp_func(default_get_timestamp, freq); } if (IS_ENABLED(CONFIG_LOG_MODE_DEFERRED)) {