Sysadmin > NtP > RaspberryGpsNtpServer

Raspberry with a gps clock and a etc

RTC

  • apt-get install i2c-tools
  • cat /etc/modules
pps-gpio    <<<< PPS
i2c-bcm2708
i2c-dev
rtc-ds1307
  • modprobe i2c-bcm2708
    • modprobe rtc-ds1307
  • cat /etc/rc.local
...
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -s
/bin/echo -e '$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n' > /dev/ttyAMA0
exit 0
  • update-rc.d hwclock.sh enable
  • update-rc.d fake-hwclock remove
  • apt-get remove fake-hwclock
  • rm /etc/cron.hourly/fake-hwclock
  • rm /etc/init.d/fake-hwclock
  • cat /boot/config.txt
...
gpu_mem=16
dtparam=i2c=on
dtparam=i2c_arm=on
dtoverlay=pps-gpio,gpiopin=23    <<< PPS
  • i2cdetect -y 1
  • hwclock --systohc -D --noadjfile --utc

NTP

Download: http://www.ntp.org/downloads.html

  • apt-get install ntp
  • apt-get remove ntp
  • cat /etc/udev/rules.d/80-gps-to-ntp.rules
# Change MODE of ttyAMA0 so it is readable by NTP and provide a symlink to
# /dev/gps0
KERNEL=="ttyAMA0", SUBSYSTEM=="tty", DRIVER=="", SYMLINK+="gps0", MODE="0666"
# Symlink /dev/pps0 to /dev/gpspps0
KERNEL=="pps0", SUBSYSTEM=="pps", DRIVER=="", SYMLINK+="gpspps0", MODE="0666"
  • apt-get install libcap-dev pps-tools
  • compile ntpd
./configure --prefix=/usr --enable-all-clocks --enable-parse-clocks --enable-SHM --enable-debugging --sysconfdir=/var/lib/ntp --with-sntp=no --with-lineeditlibs=edit --without-ntpsnmpd --disable-local-libopts --disable-dependency-tracking (--enable-linuxcaps)
make 
make install
alternativ mal probieren NtpBuildOptions
./configure  --disable-all-clocks  --disable-parse-clocks  --without-lineeditlibs  --enable-NMEA  --enable-LOCAL-CLOCK  --enable-SHM  
--enable-linuxcaps  --enable-ATOM

  • change /etc/init.d/ntp
sed -i 's/DAEMON=' /etc/init.d/ntp

  • hwclock -r
  • ntpq -p
  • vim /boot/cmdline.txt
  • vim /boot/cmdline.txt
  • cd /etc/
  • grep ttyAMA0 *
  • grep -q ttyAMA0 *
  • grep -binr ttyAMA0 *
  • vim securetty
  • grep -binr ttyAMA0 *
  • apt-get remove ntp
  • cat /etc/udev/rules.d/80-gps-to-ntp.rules

  • cat - > /etc/udev/rules.d/80-gps-to-ntp.rules
  • apt-get install libcap-dev pps-tools
  • find / -name ntpd

  • systemctl enable ntp.service
  • systemctl status ntp.service
  • ntpdate 134.34.3.18
  • systemctl start ntp.service
  • systemctl status ntp.service
  • journalctl -xn
  • aptitude purge ntp
  • ls -al /etc/init.d/ntp
  • /etc/init.d/ntp start
  • journalctl -xn
  • groupadd -g 123 ntp
  • useradd -d /home/ntp -s /bin/false -u 123 -g 123 ntp
  • chown ntp:ntp /var/lib/ntp
  • mkdir -p /var/log/ntpstats/
  • chown ntp:root /var/log/ntpstats/

  • systemctl start ntp.service
  • systemctl enable ntp.service
  • vim /etc/dhcp/dhclient.conf # remove ntp-stuff

ppstest /dev/pps0

  • systemctl disable getty@ttyAMA0
  • systemctl stop getty@ttyAMA0
  • /etc/init.d/ntp start
  • systemctl stop serial-getty@ttyAMA0.service
  • systemctl disable serial-getty@ttyAMA0.service
  • systemctl mask serial-getty@ttyAMA0.service

# enable clibrate and make a average of the drift
tail -20 /var/log/ntpstats/peerstats | grep 127.127.22.0 | awk '{SUM=SUM+$5; COUNT=COUNT+1;} END {print SUM/COUNT}'

#Optimisation
echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
setserial /dev/ttyAMA0 low_latency

/boot/cmdline.txt smsc95xx.turbo_mode=N

#Check PPS
lsmod | grep pps
ppstest /dev/pps0

ntpd -g -l /var/log/ntpd.log -p var/run/ntpd.pid -c /etc/ntp.conf

gpis readall

sudo apt-get install minicom

minicom -b 115200 -o -D /dev/ttyAMA0

Raspberry ntp-server comparison

device tree

Banana pi

GPS-HAT

Instructions for raspberry nap-server