Ethernet Time Sync in Yocto with SysVInit

Hi,

I am trying to sync the hwclock/system clock with NTP time. From what I’ve gathered so far, the Toradex BSPs use connman running on Systemd to sync the NTP time to the system clock.

Unfortunately, to save resources, I have to use Yocto with SysVInit.

Could you please tell me how I can accomplish the time synchronization in Yocto with SysVInit.

Thanks,
Zyc

Hi @zycamedis

Thanks for writing to the Toradex Community!

You need to write a SysVinit Script and use the commands discussed here.

Best regards,
Jaski

Hi

Assuming you use OE/Yocto, when you use the ntp recipe from meta-openembedded you already get the SysV init scripts and configuration files.

Note that the configuration files contain no or dummy time server addresses, you will have to change the configuration. Have a look here why that is so.

Max

Thanks @jaski.tx and @max.tx ! I’ve made some progress thanks to your answers.

But I’m curious about the current behavior.

Once the system has completely booted up. The NTP time kicks in and synchronizes with the system clock. This I confirm with the “date” command.

I then check the hardware clock time with “hwclock -r” and it is old.

So I write using “hwclock -w”. I’m assuming this writes the system clock time to the hardware clock.

I readback the time with “hwclock -r” and it shows the correct time.

[upload|qYBausc2CEcyAJokgvv2qaUpz1o=]

But on the next power cycle I still get this:

[upload|uZ105rb/dELBNBHkzXWdhurpwhs=]

Now I don’t have an RTC on my custom board so I don’t expect the value to get retained.

[upload|tBAEfSocEPbcp4bFOlnAzFfel88=]

But I’m curious about this particular timestamp [Fri Oct 11 17:53:56 UTC 2019] that is always retained on every power cycle. This was assigned when my VF50 module was last connected to the Toradex Colibri Eval board.

How does this parameter get updated when my module is connected to the Eval board? If it continues to display when I place the module on my custom board, I guess it means this value is present in the module firmware so I should be able to write to it too?

Hi

SysV Init:

Have a look at this and this.
The first initscript sets /etc/timestamp to the systemtime on a proper shutdown, the second sets the systemtime on boot to /etc/timestamp if /etc/timestamp is more recent than the current systemtime. /etc/timestamp is initialized at image creation time.

Assuming you do proper shutdowns you get at least a monotonic advancing systemtime even without an RTC.

So ‘Fri Oct 11 17:53:56 UTC 2019’ is when you did your last proper shutdown or, if you never did a shutdown it is image creation time.

Note that we use a similar behaviour with systemd..

Max

Thanks @max.tx ! That’s exactly what I was looking for!