How to get NTP working with custom I/O Pin?

Does your kernel have PPS support?

$ grep PPS /boot/config-$(uname -r)
# PPS support
CONFIG_PPS=m
# CONFIG_PPS_DEBUG is not set
# PPS clients support
# CONFIG_PPS_CLIENT_KTIMER is not set
CONFIG_PPS_CLIENT_LDISC=m
CONFIG_PPS_CLIENT_PARPORT=m
CONFIG_PPS_CLIENT_GPIO=m
# PPS generators support

Is ldattach installed?

$ which ldattach
/usr/sbin/ldattach

You may not need ldattach. It was mentioned in the LinuxPPS installation instructions. However, it appears that it is only used for PPS sent over a serial line (e.g. RS-232).

Are the pps-tools installed?

$ which ppstest
/usr/bin/ppstest

Is the pps-gpio.ko module installed?

$ modinfo pps-gpio
filename:       /lib/modules/4.4.0-38-generic/kernel/drivers/pps/clients/pps-gpio.ko
version:        1.0.0
license:        GPL
description:    Use GPIO pin as PPS source
author:         James Nuss <[email protected]>
author:         Ricardo Martins <[email protected]>
srcversion:     D2C22B0A465DA63746EFB59
alias:          of:N*T*Cpps-gpio*
depends:        pps_core
intree:         Y
vermagic:       4.4.0-38-generic SMP mod_unload modversions 

You can tell the kernel that a GPIO pin will be used as a PPS signal by adding something like this to your kernel line in your GRUB config:

dtoverlay=pps-gpio,gpiopin=18

You will need to change "18" to the GPIO pin you are using.

You will need to add a couple of lines like this to your ntp.conf:

server 127.127.22.1            # ATOM(PPS)
fudge 127.127.22.1 flag3 1     # enable PPS API

References:

http://www.ntp.org/ntpfaq/NTP-s-config-adv.htm

http://linuxpps.org/wiki/index.php/Main_Page

http://rdlazaro.info/compu-Raspberry_Pi-RPi-stratum0.html

http://doc.ntp.org/4.1.1/refclock.htm

http://doc.ntp.org/4.1.1/driver22.htm

Tags:

Ntp