BBB RTC synchronization with NTP

30 views
Skip to first unread message

jaka.ko...@gmail.com

unread,
Jul 15, 2020, 9:29:55 AM7/15/20
to BeagleBoard
Current Beaglebone Black images offer support for high resolution timers in Linux kernel. They are controlled by ktime.h library and depend on system's clocks (CLOCK_MONOTONIC, CLOCK_REALTIME,...). The clocks can be looked up from userspace programs with commands clock_gettime, clock_settime and clock_getres from time.h library.
What I would like to do is make/write a protocol in c that would synchronize realtime clocks between two boards over ethernet cable connection or internet. My goal is testing how accurately two clocks can be set to the same global time under different protocols. I'm planning to start with ntp, would using an existing library or client make sense here? I read BBB sometimes comes with daemons for ntp, in that case how would I set one board to act as a server in protocol?

acheesehead

unread,
Jul 15, 2020, 11:13:36 AM7/15/20
to BeagleBoard
Look at gPTP.

Dennis Lee Bieber

unread,
Jul 15, 2020, 12:07:55 PM7/15/20
to Beagleboard
On Wed, 15 Jul 2020 00:19:18 -0700 (PDT), in
gmane.comp.hardware.beagleboard.user
jaka.koren.isys-Re5...@public.gmane.org wrote:


>What I would like to do is make/write a protocol in c that would
>synchronize realtime clocks between two boards over ethernet cable
>connection or internet. My goal is testing how accurately two clocks can be
>set to the same global time under different protocols. I'm planning to
>start with ntp, would using an existing library or client make sense here?
>I read BBB sometimes comes with daemons for ntp, in that case how would I
>set one board to act as a server in protocol?

debian@beaglebone:~$ apt search ntpd
Sorting... Done
Full Text Search... Done
<SNIP NNTP related items>
ntpdate/stable 1:4.2.8p12+dfsg-4 armhf
client for setting system time from NTP servers (deprecated)

ntpsec-ntpdate/stable 1.1.3+dfsg1-2+deb10u1 armhf
client for setting system time from NTP servers

openntpd/stable 1:6.2p3-4 armhf
OpenBSD NTP daemon

debian@beaglebone:~$man openntpd #after installing it
"""
DESCRIPTION
The ntpd daemon synchronizes the local clock to one or more remote NTP
servers or local
timedelta sensors. ntpd can also act as an NTP server itself,
redistributing the local
time. It implements the Simple Network Time Protocol version 4, as
described in RFC
5905, and the Network Time Protocol version 3, as described in RFC
1305.
"""

debian@beaglebone:~$ man ntpd.conf
"""
DESCRIPTION
This manual page describes the format of the ntpd(8) configuration
file.

ntpd.conf has the following format:

Empty lines and lines beginning with the ‘#’ character are ignored.

Keywords may be specified multiple times within the configuration
file. The basic con-
figuration options are as follows:

listen on address [rtable table-id]
ntpd(8) has the ability to sync the local clock to remote NTP
servers and, if
this directive is specified, can act as NTP server itself,
redistributing the
local clock.

Specify a local IP address or a hostname the ntpd(8) daemon
should listen on to
enable remote clients synchronization. If it appears multiple
times, ntpd(8)
will listen on each given address. If ‘*’ is given as an
address, ntpd(8) will
listen on all local addresses using the specified routing
table. ntpd(8) does
not listen on any address by default. The optional rtable
keyword will specify
which routing table to listen on, if the operating system
supports rdomains. By
default ntpd(8) will listen using the current routing table.
For example:
"""


--
Dennis L Bieber

Tarmo

unread,
Jul 16, 2020, 5:54:11 AM7/16/20
to BeagleBoard
On Wednesday, 15 July 2020 16:29:55 UTC+3, jaka.k...@gmail.com wrote:
Current Beaglebone Black images offer support for high resolution timers in Linux kernel. They are controlled by ktime.h library and depend on system's clocks (CLOCK_MONOTONIC, CLOCK_REALTIME,...). The clocks can be looked up from userspace programs with commands clock_gettime, clock_settime and clock_getres from time.h library.
What I would like to do is make/write a protocol in c that would synchronize realtime clocks between two boards over ethernet cable connection or internet. My goal is testing how accurately two clocks can be set to the same global time under different protocols. I'm planning to start with ntp, would using an existing library or client make sense here? I read BBB sometimes comes with daemons for ntp, in that case how would I set one board to act as a server in protocol?

Note that the Beaglebone Debian images use a small systemd service called systemd-timesyncd to set the system RTC. This service queries current time via SNTP (on boot, and periodically while the system is running) and updates /dev/rtc0 with the received time. Perhaps you can get started with that simple, out-of-box feature?


--
Kind regards,
Tarmo Kuuse
Reply all
Reply to author
Forward
0 new messages