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/PROCESSOR-SDK-AM335X: Hardware clock is shifted after connecting Ethernet

Part Number: PROCESSOR-SDK-AM335X

Tool/software: Linux

Hello, 

distro: arago-base (TISDK-05-02)
board: custom-am335x-based

In my project, I use a hardware clock to accurately measure time intervals.

But when I connect an Ethernet cable, the hardware time shifts (most likely when initializing network drivers).

Here is log of the program measuring the past time using the function std::chrono::high_resolution_clock::now()

root@am335x-evm:~# test-now
0.000065
1.000882
2.001716
3.002334
4.002954
5.003577
6.004197
7.004869
8.005542
9.006217
10.006798
11.007365
12.008000   #####  PLUG  ETHERNET   #######
13.008693
[ 75.202505] cpsw 4a100000.ethernet eth0: Link is Up - 100Mbps/Full - flow con
trol rx/tx
[ 75.210788] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
14.009388
15.010000
16.010378
17.010888
18.011579
19.012273
20.012965
21.013663
22.014354
23.015051
24.015746
25.016444
26.017140                        ##### HERE SOMETHING HAPPENS    ###### 
7836171.959968
7836172.960673
7836173.961379
7836174.962083
7836175.962604
7836176.963305
7836177.963968
7836178.964637
7836179.965359
7836180.966053
7836181.966754     #####  UNPLUG  ETHERNET   #######
7836182.967454
7836183.967926
[ 101.231703] cpsw 4a100000.ethernet eth0: Link is Down
7836184.968623
7836185.969289
7836186.969996
7836187.970464
7836188.971100
7836189.971806
7836190.972506
7836191.973108
7836192.973809
7836193.974455
7836194.975103
7836195.975810
7836196.976507
7836197.977153
7836198.977861
7836199.978509
7836200.979155
7836201.979861
7836202.980524
7836203.981177
7836204.981882
7836205.982706
7836206.983166
7836207.983875
7836208.984521
7836209.985219

Is there any idea how to avoid such behavior?

Thanks!

  • Andrey,

    Which hardware timer are you using for your application?

    It seems this may be a PTP or NTP issue where the time is being synced to either a PTP host or the network time? What kind of network are you plugging into? Is it possible to plug into a "private" network where these things likely wouldn't be running to see if the problem goes away?

    Thanks.
  • You're right. Indeed, it turned out that time is synchronized by the service. But systemd uses timedatectl instead of ntpd.
    So I switch off synchronization by command:

    timedatectl set-ntp 0

    and the problem was resolved.
    Thank you very much!