summaryrefslogtreecommitdiff
path: root/README
blob: cd66fd870e0ce2d299b383c29ca875f69f741bc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
$Id: README 1.2 2017/07/06 09:48:07 martin REL_M $

This is the README file for mbgtools-fbsd-1.0.0
-----------------------------------------------

Please send comments and required modifications to
Meinberg support <support@meinberg.de>


Contents
--------
  1.   Notes and description
  2.   Driver files and programs
  3.   Installation
  3.1  Unpacking the sources
  3.2  Compiling the driver
  3.3  Installing the driver
  3.4  Loading the kernel module
  4.   Using the driver with NTP


1. Notes and description
------------------------
The driver package supports all PCI card types manufactured by Meinberg
which have been introduced up to the release date of this driver version.

The driver should compile fine under FreeBSD 8.1 through 12, and eventually
on older versions. Supported platforms are x86 and amd64.


2. Driver files and programs
----------------------------
mbgtools for FreeBSD is based on Meinberg's common driver library mbglib
and implements the following programs each of which can be found in
its own subdirectory.

Each of the user space programs can be run with parameter '-?' to show
the supported parameters.

mbgclock.ko
  A kernel module which implements the device driver.

mbgsvcd
  The Meinberg Service Daemon which needs to be started to feed the
  timestamps from the device(s) to the NTP daemon's shared memory driver.

  This program periodically calls the kernel driver to retrieve
  time stamps of both the system time and the PCI card as close
  as possible after each other, and feeds the time stamp pairs
  into a shared memory segment compatible with the NTP daemon, ntpd.
  This allows ntpd to use up to 4 PCI card(s) as refererence time
  source, if configured accordingly.

  Usually the program runs as daemon, but using the -f parameter
  it can also run in the foreground where it also prints the time
  stamps and the time differences between the system time and the
  PCI card's time on the console.

  This mode can be used to monitor how accurately the system time
  is actually disciplined, even if the system time is disciplined
  by some other means.

mbgstatus
  This program prints some status information for a device. The
  kind of information to be printed depends on the specific type
  of the card. One or more parameters '-v' increase verbosity.

mbgctrl
  This program can be used to do some basic configuration of a card.

mbgirigcfg
  This program can be used to check and configure IRIG settings of
  cards which provide an IRIG input or output.

mbgsetsystime
  This program reads the time from a device and sets the system time.
  If NTP is used on a system which has an unreliable clock, this
  program can be used to set the system time initially (before the
  NTP daemon starts). The program should not be run if NTP is active
  and controls the system time since NTP achieves a higher accuracy.

mbgshowsignal
  This program displays the modulation (i.e. the second marks) of a
  received longwave signal, e.g. from DCF77, if supported by the device.

mbggpscap
  This example program reads time capture events from a card's time
  capture buffer. This works only with cards that provide time capture
  inputs, and the DIP switches on those cards must have been set up
  properly to enable time capturing.

mbghrtime
  This example program checks whether a card supports high-resolution
  time and reads those time stamps from the device, if supported.

mbgfasttstamp
  This examle program demonstrates how to read high resolution time stamps
  from a card very much faster than mbghrtime. However, this works only
  with cards that support memory mapped I/O.
  Current PCI Express cards support this feature, but older PCI cards may
  not.

mbgxhrtime
  !! This program has not yet been fully ported to FreeBSD,
  !! and thus is not yet available
  This example program also shows how to get time stamps faster than
  shown in mbghrtime. This is not as easy as mbgfasttstamp but can be
  used with every card which can be used with mbghrtime, even if the
  card does not support memory mapped I/O.
  The program starts a polling thread which reads a high resolution
  time stamp from the card once per second, and then uses the CPU's
  time stamp counter to extrapolate the time.
  A limitation of this approach is that the CPU's time stamp counters
  may return different values on different CPUs. So the program
  takes care to have the code executed always on the same CPU. Also,
  power saving mechanisms (Intel Speedstep, or AMD Cool'n'Quiet)
  should be disabled to prevent the extrapolated times from being
  messed up.



3. Installation
---------------

3.1 Unpacking the sources
-------------------------
Unpack the archive file using the command

  tar xvzf mbgtools-fbsd*.tar.gz

After the archive file has been unpacked cd to the base directory
that has been created corresponding to the name and version of
the package.



3.2 Compiling the driver
------------------------
If the driver package has already been built before then

  make clean

should be run first to remove old object files and binaries.

Make sure your working directory is the driver base directory and
simply type

  make

to compile the utility programs first, then the kernel module.
If *any* error or warning messages are displayed then please
report to Meinberg <support@meinberg.de>.



3.3 Installing the driver
-------------------------
Installation must be done as user root. Type

  make install

to copy the compiled binaries to their target directories. Programs
which only read the clock to display some information are copied to
/usr/local/bin, whereas programs which may change the device
configuration, or set the system time, are copied to /usr/local/sbin.



3.4 Loading the kernel module
-----------------------------
After the binaries have been installed the module can be loaded
for the first time. The command syntax is:

  kldload mbgclock

When the module is loaded some some startup messages are generated which
can be checked in the syslog, or using the dmesg command. If the module
was loaded successfully it should be listed if you type

  kldstat

You may try to display the device status by entering

  mbgstatus

The output shows some information on the device status,
depending on the type of the clock.

Once the module has been loaded, the other utility programs can be
used accordingly.



4. Making sure programs are loaded after boot
---------------------------------------------

First we need to make sure that the kernel module is loaded automatically
at boot time.

Edit or create the text file /boot/loader.conf and add the following line:

mbgclock_load="YES"


If ntpd is to use the PCI card as reference time source make sure
the mbgsvcd daemon is started. Run the following command to copy
the service control script to the appropriate directory:

  cp scripts/mbgsvcd /etc/rc.d/


Then edit the text file /etc/rc.conf and add the following line:

mbgsvcd_enable="YES"



5. Using the driver with NTP
----------------------------
The NTP daemon can be configured to use up to 4 Meinberg PCI cards
as reference time source to discipline the system time. In order to
achieve this, ntpd needs to be configured to use its shared memory
driver (SHM, type 28).

The following entries need to be made in the ntp.conf file
to enable support for 4 PCI cards:

  server 127.127.28.0 minpoll 4 maxpoll 4 iburst
  fudge 127.127.28.0 refid SHM0

  server 127.127.28.1 minpoll 4 maxpoll 4 iburst
  fudge 127.127.28.1 refid SHM1

  server 127.127.28.2 minpoll 4 maxpoll 4 iburst
  fudge 127.127.28.2 refid SHM2

  server 127.127.28.3 minpoll 4 maxpoll 4 iburst
  fudge 127.127.28.3 refid SHM3

Of course, only the first entry is required if only a single PCI card
is installed.

Please keep in mind the mbgsvcd program also needs to be running to feed
time stamp pairs of the system time and the PCI card's time into the
shared memory segment(s).

If the NTP daemon is already running restart it and check the syslog file
for messages generated by the daemon.

The NTP daemon shipped with a FreeBSD may have been compiled without
support for the SHM driver. If this is the case you will find a message
in the syslog saying the daemon is unable to handle 127.127.28.<n>.
In this case you need to recompile the NTP package with support
for the SHM driver.

Simply download the NTP source packge of your choice from
http://support.ntp.org

Then unpack the sources and compile the package with the usual instructions:

./configure
make
make install

By default this installs the NTP binaries under /usr/local rather than /usr/sbin,
so be sure the right instance of ntpd is started on reboot or when you run the
"service ntpd start" command.