Automatic time sync

Can anyone clearly explain how date/time sync should to work in legato framework?
From my understanding it should automatically sync date with network, but for me it doesn’t happen.

Ideally device time also should be synced when data connections is established (i am connecting to airvantage). According to logs system tries to do this but fails (incorrect time set intentionally):

Apr 20 18:17:04 fx30 user.warn Legato: -WRN- | dcsDaemon[26811]/dcsDaemon T=main | dcsServer.c GetTimeServer() 881 | No server configured, use the default one
Apr 20 18:17:14 fx30 user.err Legato: =ERR= | dcsDaemon[26811] | rdate: timeout connecting to time server
Apr 20 18:17:14 fx30 user.err Legato: =ERR= | dcsDaemon[26811]/dcsDaemon T=main | dcsServer.c RetrieveTimeFromServer() 2077 | Unable to retrieve time from server
Apr 20 18:17:14 fx30 user.err Legato: =ERR= | avcDaemon[27360]/avcDaemon T=main | avcClient.c CheckDateTimeValidity() 223 | Unable to retrieve date or time from server

but where the time server is configured? is it an ntpd server from /etc/time_service.conf?
running ntpd -p doesn’t work for me as well…

My device: Sierra FX30 (WP7702). Mobile network connection only.
Worth to mentions that this device is not intended to work in Europe (Ireland) so it falls to 2G connection. This may be causing issues with network time sync but why time is not synced over data connection?

Am i missing something?

Does this help?

If it’s the same as running (/usr/sbin/ntpd -p ntpserver) in terminal with root privileges - no it doesn’t work.

How about setting it to qualcomm time to receive time from network?
You can also check at+cclk?

When we had a problem like this our issue was that not all cellular network providers would have this option to get time from them so we switched to using some ntpd servers and edited the init.d script that updates time.
We edited it in a way that it triggers contacting ntdp server only when there is internet connectivity. So what we do, we ping ntpd servers until internet connectivity is available, then we obtain time from ntpd and we don’t even use cellular network time.

Thanks for the reply @lazzox
Yes it looks like my issue. I would write script but the problem is ntpd -p also doesn’t work. Did you have such issues? Would you mind sharing the script?

As @lazzox mentioned it may not be a reliable way to sync date.

I don’t see problem, please see below:

root@swi-mdm9x28-wp:~# date
Thu Jan 1 08:08:44 +08 1970
root@swi-mdm9x28-wp:~# /etc/init.d/ntpd_time_service start
root@swi-mdm9x28-wp:~# date
Wed May 6 10:54:21 +08 2020
root@swi-mdm9x28-wp:~# cm info
Device: WP7607
IMEI: 359779081234565
FSN: VN730485080103
[ 199.814275] i2c-msm-v2 78b8000.i2c: NACK: slave not responding, ensure its powered: msgs(n:1 cur:0 tx) bc(rx:0 tx:2) mode:FIFO slv_addr:0x3a MSTR_STS:0x0c1300c8 OPER:0x00000090
Firmware Version: SWI9X07Y_02.28.03.03 000000 jenki[ 199.831380] i2c-msm-v2 78b8000.i2c: NACK: slave not responding, ensure its powered: msgs(n:1 cur:0 tx) bc(rx:0 tx:2) mode:FIFO slv_addr:0x3a MSTR_STS:0x0c1300c8 OPER:0x00000090
ns 2019/05/21 03:33:04
Bootloader Version: SWI9X07Y_02.28.03.03 000000 jenkins 2019/05/21 03:33:04
MCU Version: 002.011
PRI Part Number (PN): 9908958
PRI Revision: 001.000
Carrier PRI Name: GENERIC
Carrier PRI Revision: 002.068_000
SKU: 1104301
Last Reset Cause: Reset, User Requested
Resets Count: Expected: 112 Unexpected: 5
root@swi-mdm9x28-wp:~# cat /etc/time_service.conf
#TIME_SERVICES=“qcom_time ntpd_time”
root@swi-mdm9x28-wp:~# cm data
Index: 1
APN: hkcsl
PDP Type: IPV4V6
Connected: yes
Interface: rmnet_data0
Family[IPv4]: inet
root@swi-mdm9x28-wp:~# ping
PING ( 56 data bytes
64 bytes from seq=0 ttl=47 time=433.913 ms
64 bytes from seq=1 ttl=47 time=392.103 ms
^C ping statistics —
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 392.103/413.008/433.913 ms

Thanks, @jyijyi
Unfortunately this doesn’t work for me. Ntpd doesn’t return any error but date also remains incorrect.

Then probably you need to capture wireshark to investigate what happen during " /etc/init.d/ntpd_time_service start"

FYI @jyijyi
I got the trace…
If i am getting this correctly - server does not respond… Maybe because of incorrect configuration on client side. Request looks pretty weird. Any tips?
fx30_time_sync.pcap (611 Bytes)

It actually returns a valid date (i stopped utility too soon first time)

Still… date is not updated.

Then can you try my ntp server above?

it is configured to:

But the ip address is not the same

Ping gives me different address, but it doesn’t matter i guess.
a - it doesn’t work anyway.
b - pool gives you different time server address (best for you)
i can see correct time coming from the server, i don’t understand why system does not accept it

Can you try the qcom time?

I started with qcom_time. In some cases it may sync time, but it’s very inconsistent. I cant rely on it.

As i cannot reproduce the issue, i can only give suggestion like shutting down firewall

iptables -I INPUT -j ACCEPT

it worked
now i feel myself an idiot, that i didn’t try it before, haha
Thank you very much :slight_smile:

I accepted the solution, but it doesn’t mean i’d recommend using it (it’s terribly insecure).
However it solves my initial issue.