Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM3358: Linux kernel wall time

Part Number: AM3358

Tool/software: Linux

Just a question out of curiosity. I know that there are wall time (main system timeline) and  two mechanisms of timekeeping in modern linux kernel - timewheel and hrtimers. AM3358 SoC has seven DMTimers, the question is what is the source of wall time in AM3358, I mean for example when we  print 'date' command it has to read the value of some register from somewhere with the number of cycles passed from the start and then convert it to nanoseconds, so what is the source of that register on AM335x, is it one of DMTimers? Can we control that clock source? Are there some bindings for that clock source in the device tree? Also when ptp client's adjusting algorithm is working (ptp4l stack), does it just add the calculated Δt value to source clock register every time when the wall time is accessed (for example by gettimeofday() function) without modifying source clock register itself? Are hrtimers also use DMTimers, and if they do which one? Thanks!)

  • Andrey,

    There are quite a few questions here so I'll try to go through and answer what I can.

    If available, the RTC is used for wall clock. The hwclock command can be utilized to view these interactions.

    For PTP, by default I believe there is a simple PID loop that is used to "lock" the reference clock. You have to use something like phc2sys to synchronize PTP to the system clock.

    Yes, hrtimers use DM_Timers. You can see some of this relationship with cat /proc/timer_list.

    I hope this helps alleviate your curiosity.
  • Thank you for reply!) Just one more question. As far as I understand getnstimeofday() reads some timestamp from somewhere. Where is it timestamp actually located? Is it in some DM_Timer?
  • Andrey,

    The timestamp is a structure maintained by the kernel using clocksource. I found the below kernel documentation helpful:

    www.kernel.org/.../timekeeping.txt

    You can find the timer used for clocksource with:

    cat /sys/devices/system/clocksource/clocksource0/current_clock

    When I do this on a Beaglebone Black, it returns timer1 which I believe corresponds to DM_timer1 as named in the device tree.

    I hope this is helpful to you.