Re: RTC synchronization with system time

2023-03-21 Thread Tomek CEDRO
On Tue, Mar 21, 2023 at 4:02 AM Nathan Hartman wrote: > On Mon, Mar 20, 2023 at 10:36 PM Gregory Nutt wrote: > > > NuttX offers a function clock_synchronize() that synchronizes system > > clock > > > with clock from RTC (internal or external). The synchronization is done > > > during board initiali

Re: RTC synchronization with system time

2023-03-21 Thread Gregory Nutt
What is your view on adding some sort of automatic synchronization that would ensure system clock stays in sync with RTC (or at least error is less than some value) even when i drifts away from "real time"? Quite simple solution is to let clock_gettime() to update base time after N reads howeve

Re: RTC synchronization with system time

2023-03-21 Thread Gregory Nutt
No, I don't want to do this from application level hence why I am looking for an alternative. NuttX also has function clock_resynchronize() that should solve the problem with time going backwards but not sure if it has ever been tested and used. There is an RTC timer driver in drivers/timers

Re: RTC synchronization with system time

2023-03-21 Thread Michal Lenc
as ever been tested and used. Thank you for the link and issue about adjtime(), that seems like a good alternative and way to go. Best regards, Michal Lenc -- Původní e-mail -- Od: Gregory Nutt Komu: dev@nuttx.apache.org Datum: 21. 3. 2023 0:20:43 Předmět: Re: RTC synchro

Re: RTC synchronization with system time

2023-03-20 Thread Gregory Nutt
NuttX offers a function clock_synchronize() that synchronizes system clock with clock from RTC (internal or external). The synchronization is done during board initialization and I suppose this can also be called from an application level if required. I think clock_synchronize() is okay for st

Re: RTC synchronization with system time

2023-03-20 Thread Nathan Hartman
On Mon, Mar 20, 2023 at 10:36 PM Gregory Nutt wrote: > > > NuttX offers a function clock_synchronize() that synchronizes system > clock > > with clock from RTC (internal or external). The synchronization is done > > during board initialization and I suppose this can also be called from an > > app

Re: RTC synchronization with system time

2023-03-20 Thread Gregory Nutt
NuttX offers a function clock_synchronize() that synchronizes system clock with clock from RTC (internal or external). The synchronization is done during board initialization and I suppose this can also be called from an application level if required. I think clock_synchronize() is okay for sta

Re: RTC synchronization with system time

2023-03-20 Thread Gregory Nutt
  adjtime() is not properly configured as an OS interface; it would need system call hooks in syscall/ and include/sys in order to be usable in all build configurations. I see a few other issues with adjtime() that I documented here: https://github.com/apache/nuttx/issues/8858

Re: RTC synchronization with system time

2023-03-20 Thread Gregory Nutt
On 3/20/2023 5:15 PM, Gregory Nutt wrote: You wouldn't really do this from application level, right? There is currently no POSIX-compatible application interface to do that. There is no /POSIX /interface to do this, but the Linux interface adjtime() -- see https://man7.org/linux/man-pages/man

Re: RTC synchronization with system time

2023-03-20 Thread David S. Alessio
Hello, Michal, You might want to take a look at PTP (Precision Time Protocol) https://en.wikipedia.org/wiki/PTPd and PTPd, a BSD-licensed implementation: https://github.com/ptpd/ptpd PTP is designed to sync the

Re: RTC synchronization with system time

2023-03-20 Thread Gregory Nutt
You wouldn't really do this from application level, right? There is currently no POSIX-compatible application interface to do that.  But you could implement a kernel thread that is started in your board initialization logic that can call clock_synchronize() according to whatever criteria you ne

RTC synchronization with system time

2023-03-20 Thread Michal Lenc
Hello all, NuttX offers a function clock_synchronize() that synchronizes system clock with clock from RTC (internal or external). The synchronization is done during board initialization and I suppose this can also be called from an application level if required. However I was not able to find