I have conducted accuracy verification of the RTC on AGX

I referred to the information on dumping the RTC register at the following link: Clocks: Linux System Time vs TSC vs RTC

Upon reviewing the results, it was consistently observed that the RTC’s diff time did not change.
Considering the possibility of individual differences,
I conducted the verification using two AGX units.
I initially thought that the condition for verifying the accuracy of the RTC would be that the RTC diff time becomes smaller. However, even when running in sync with the NTP server, individual differences in the RTC diff time did not occur.

The NTP setting was implemented as “server xx.xx.xx.xx iburst minpoll 9 maxpoll 9.”
When using “chronyc tracking” in the NTP sync state to check the ppm, one value was 57.199 ppm slow and the other was significantly off at 2399.317 ppm fast, and the values differed from the diff time.

Regarding this, I would like to ask what we can rely on to verify the accuracy of the RTC.
Is it true that a smaller RTC diff time indicates better accuracy?
Does a smaller ppm value in the Frequency result from chronyc tracking lead to better RTC accuracy?
If there are recommended methods for verifying the accuracy of RTC’s deviation range, please let me know.

Execution script

#get all the times
#read rtc via registers (not via date)
#first read millisecs. This causes update of shadow secs. Read those next
#read shadow secs
rtcdmsec1=$(printf "%d\n" $(busybox devmem 0x0c2a0010 W))
rtcdsec1=$(printf "%d\n" $(busybox devmem 0x0c2a000c W))

#Read higher bits
list2=$(busybox devmem 0x03010004 W)

#read lower bits andrtc
nsecsrtc1=$(date +%s%N)
list=$(busybox devmem 0x03010000 W)
nsecsrtc2=$(date +%s%N)
rtcdmsec2=$(printf "%d\n" $(busybox devmem 0x0c2a0010 W))
rtcdsec2=$(printf "%d\n" $(busybox devmem 0x0c2a000c W))

#Convert time to RTC
rtctime1=$(echo "($rtcdsec1 * 1000 + $rtcdmsec1)" | bc)
rtctime2=$(echo "($rtcdsec2 * 1000 + $rtcdmsec2)" | bc)
rtctime=$(echo "($rtctime1 + $rtctime2)/2" |bc)
rtctimesec=$(echo "$rtctime/1000" | bc)

#average to account for scheduling and other delays
nsecsrtc=$(echo "($nsecsrtc1+$nsecsrtc2)/2" | bc)

rtcdiff=$(echo "$rtctime - $nsecsrtc/1000000" | bc)

convs=$(printf "%d\n" $list)
convs2=$(printf "%d\n" $list2)

#shift over bits
higherbits=$(echo $(($convs2<<32)))
decn=$(echo "($higherbits + $convs)/31.249" | bc)
secs=$(echo "$decn/1000000.0" | bc)
secsrtc=$(echo "$nsecsrtc/1000000000" | bc)
delta=$(echo "(-($decn-$nsecsrtc/1000))"| bc)
deltams=$(echo "($delta/1000)"|bc)
systimems=$(echo "$nsecsrtc / 1000000" | bc)

echo "------------------------------start------------------------------------------------------------" 
echo "Difference between TKE_AON_SHARED_TKETSC0_0 /31.249 (is supposed to be 31.25) and linux clock." 
echo "RTC Direct time (millisec): $rtctime\t (secs) $rtctimesec" 
echo "System time     (millisec): $systimems\t (secs) $secsrtc" 
echo "Theoretically RTC and system time could line up but typically they can be quite different" 
echo "System time vs. RTC diff (millisec): $rtcdiff" 
echo "TSC:Microsecs:  $decn\t Secs: $secs \n" 
echo "Difference between the system time and TSC:\nDelta (Microsec): $delta\tMillisecs $deltams" 
echo "------------------------------end------------------------------------------------------------" 
echo "------------------------------start----------------------------------------------------------" 
chronyc tracking
echo "------------------------------end------------------------------------------------------------" 

For checking accuracy of RTC time, you may try the steps:

  1. Disable ntp service:
   $ sudo timedatectl set-ntp false
  1. Synchronize system time and RTC time with NTP server:
   # ntpdate tock.stdtime.gov.tw
   # hwclock -w
   # timedatectl 
  1. Keep device for 24 hours.
   # timedatectl 
  1. Synchronize system time and RTC time with NTP server again and check the drift:
   # ntpdate tock.stdtime.gov.tw && hwclock -s && ntpdate -u tock.stdtime.gov.tw

Thank you for your reply.
I will try using the method you suggested.


I confirmed it.
Thank you very much.

Since timedatectl has a resolution in seconds, if you want to check the accuracy of RTC in ms order, please do so if there is another way to check.
If not, I will check it from now on using the method you developed.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.