LinuxPPS installation
From EnneEnneWiki
Contents |
| If you like LinuxPPS make a donation with PayPal - it's fast, free and secure! |
Downloading the code
As of kernel 2.6.34 there is no need for patching to get basic LinuxPPS support working. You can use kernel.org 2.6.34 directly.
The latest code is available via git. You can browse the revision control history in your web browser by visiting the LinuxPPS gitweb.
You can also download a patch and patch the kernel yourself for older kernel versions. You can find some patches against specific Linux versions on the LinuxPPS HTTP/FTP site but take note that some of them implement old LinuxPPS versions!
Cloning my repository
The easiest way to get the LinuxPPS code is to use git. It is strongly suggested to use git, contrary to popular belief, it is quite simple to use.
The simplest, but most time consuming, way to get the code is to clone the LinuxPPS git repository. You will need to do this if you want to use any of the git commands documented elsewhere in this wiki.
WARNING: this will download about 120MB of data over a slowish line.
$ git clone git://git.enneenne.com/linuxpps my-linuxpps-clone
When this command completes, you will have a Linux kernel source tree in the my-linuxpps-clone directory, with the LinuxPPS patches already integrated.
Whenever new patches are added to my repository, you can update your repository by giving the following commands:
$ cd my-linuxpps-clone $ git pull
If you already have a git clone of the Linux kernel, you may want to follow these instructions to merge my changes into your tree.
Using a patch
If you are unable to use git, you can use the old-style patch method to obtain the code.
NOTE: I have provided patches only for a few LinuxPPS versions and kernels.
You can get the patches at the LinuxPPS HTTP/FTP site. Please refer to the README file for an explanation of which versions are available.
Patches can be applied with the following sequence:
$ cd your-linux-source-tree $ patch -p1 < ntp-pps-version.diff
Compiling the code
The kernel code
Once you have downloaded the code by following the instructions above, you will need to compile the kernel with PPS support.
When you run the kernel configuration tool of your choice (such as make menuconfig you will find the following in the PPS support section. The following options will enable serial line support.
<M> PPS support
[ ] Use low level IRQ timestamps
[ ] PPS debugging messages
*** PPS clients support ***
<M> Kernel timer client (Testing client, use for debug)
<M> PPS line discipline
[ ] Parallel printer support
If you cannot locate the PPS support section, you may not have enabled experimental drivers. You will find the following options in the Code maturity level options section.
[*] Prompt for development and/or incomplete code/drivers [*] Select only drivers expected to compile cleanly (NEW)
NOTE: the PPS support -> Parallel printer support may be forced off if you selected PPS support as a module and Character devices -> Parallel printer support as a kernel built-in. Please make them both modules to resolve the issue.
Now recompile the kernel and reboot.
The userland tools
Now that you have a kernel with PPS support, you will need to build the LinuxPPS userspace tools.
You can browse the pps-tools repository via gitweb.
Please get the code:
$ cd /usr/src $ git clone git://git.enneenne.com/pps-tools pps-tools
Header files
Optionally, when we have older header files, we update the header files using the versions from your new kernel.
$ cd /usr/include $ mv linux linux.old $ mv asm asm.old $ mv asm-generic asm-generic.old $ ln -s /lib/modules/$(uname -r)/build/include/linux linux $ ln -s /lib/modules/$(uname -r)/build/arch/x86/include/asm asm $ ln -s /lib/modules/$(uname -r)/build/include/asm-generic asm-generic
Optionally, for building ntpd later:
$ cd /usr/include $ cp /usr/src/pps-tools/timepps.h timepps.h
Building the tools
Now we will build the ppstest tool.
$ cd /usr/src/pps-tools $ make
If you encounter an error, you most likely did not follow the instructions above.
Now you have the ppstest userspace tool.
You will also need the ldattach tool, which can be found in the util-linux-ng package v2.14 and up.
If your distribution does not provide you such a package, or a working version of ldattach is not yet included, then you will have to build this tool from it's sources. Please refer to kernel.org for the sourcecode and your distro provider for an updated util-linux package.
You can optionally apply this patch: (being discussed)
--- a/sys-utils/ldattach.c 2009-07-04 01:20:03.000000000 +0200
+++ b/sys-utils/ldattach.c 2010-02-19 17:40:00.054134773 +0100
@@ -242,6 +242,10 @@
ts.c_cflag |= (PARENB|PARODD);
break;
}
+
+ if (ldisc == N_PPS)
+ ts.c_iflag |= (IGNBRK|ICRNL);
+
ts.c_cflag |= CREAD; /* just to be on the safe side */
if (tcsetattr(tty_fd, TCSAFLUSH, &ts) < 0)
err(EXIT_FAILURE, _("cannot set terminal attributes for %s"), dev);
The patch makes ldattach work with ntpd. The PPS line discipline patches for ldattach have been partly accepted by the util-linux-ng maintainers.
It appears you can also do these same settings by using stty.
And perhaps these settings could be done by ntpd?
Testing the new system
After you have loaded LinuxPPS, you should see a new directory in sysfs: /sys/class/pps. In that directory you will find all of your clients.
$ find /sys/class/pps/ /sys/class/pps/ /sys/class/pps/pps0 /sys/class/pps/pps1 $ tree /sys/class/pps/pps0 /sys/class/pps/pps0 |-- assert |-- clear |-- dev |-- echo |-- mode |-- name |-- path |-- power | `-- wakeup |-- subsystem -> ../../../../class/pps `-- uevent
If you do not see anything, you have not loaded a client module. As an example, to load the 8250 serial line support, run the following commands to use /dev/ttyS0 as a PPS source:
$ sudo modprobe 8250 $ ldattach 18 /dev/ttyS0
You should now verify that you have the proper device nodes in the /dev directory. You should get something like this:
$ ls -l /dev/pps* crw-rw-r-- 1 root dialout 253, 0 Aug 8 18:58 /dev/pps0 crw-rw-r-- 1 root dialout 253, 1 Aug 8 18:58 /dev/pps1
If you do not see them, add the following into your udev configuration file:
SUBSYSTEM=="pps", MODE="0664" GROUP="dialout"
Alternatively, you can create the proper device nodes with the mknod utility. Please refer to the appropriate manual pages in either case.
Now you can test the PPS support by running the ppstest tool (as root). You should get output like the following:
$ sudo ppstest /dev/pps0 trying PPS source "/dev/pps0" found PPS source "/dev/pps0" ok, found 1 source(s), now start fetching data... source 0 - assert 1186592699.388832443, sequence: 364 - clear 0.000000000, sequence: 0 source 0 - assert 1186592700.388931295, sequence: 365 - clear 0.000000000, sequence: 0 source 0 - assert 1186592701.389032765, sequence: 366 - clear 0.000000000, sequence: 0
If you wish to find a specific source, you can use the ppsfind utility. The following is an example of how to locate the ktimer testing device:
$ ppsfind ktimer pps0: name=ktimer path=
You may also wish to view the /sys/class/pps/*/{assert,clear} files. These record the PPS event times. Depending on your PPS source's capabilities, one of them may be empty.
$ ls -l /sys/class/pps/*/{assert,clear}
/sys/class/pps/pps0/assert /sys/class/pps/pps1/assert
/sys/class/pps/pps0/clear /sys/class/pps/pps1/clear
The ktimer test module only creates assert events, so you will only see things in the assert file. The clear file will be empty. Reading the assert file will show you the last assert event time and sequence number:
$ cat /sys/class/pps/pps0/assert 1148727816.24772000#326 $ cat /sys/class/pps/pps0/assert 1148727817.24872000#327
You should get a different number each time your PPS source generates an event. This should take exactly one second between events.
| If you like LinuxPPS make a donation with PayPal - it's fast, free and secure! |
