I have just set up a GL-MT300N-V2 as an NTP server with a GPS/PPS reference clock. Seems to be working well, but I need a better GPS signal to be sure.
I pretty much followed the Raspberry Pi method given in Building a Raspberry-Pi Stratum-1 NTP Server but needed to modify the device tree and build my own kernel as openwrt doesn’t support device tree overlays.
Here is an outline:
- uBlox NEO-7M 3.3V GPS module from eBay
- GPS wired to GL-MT300N-V2 using second serial port /dev/ttyS1 (GND, 3.3V, TX1,RX1, PPS to GPIO4)
- openwrt 18.06 snapshot with device tree patch below and pps and pps-gpio kernel modules
- gpsd connected to /dev/ttyS1
- disable sysntpd
- ntpd and ntp-utils packages
- hacks to ntp startup files to append reference clock info (below)
After stabilizing for a couple of hours the NTP daemon on the router has an offset and jitter of a few microseconds compared to the GPS/PPS clock. Happy to provide further details, but this is my first attempt at modifying and building openwrt.
Note: Initially I tried using the first serial port /dev/ttyS0, but the router wouldn’t boot. I assume that data returned from the GPS interrupted uboot.
---------- reference clock configuration for /etc/ntpd.conf ----------
# At least one server or reference clock must have "prefer" for PPS to work
# time1 value - here 0.125s - must be adjusyed to suit
server 127.127.28.0 minpoll 4 maxpoll 4
fudge 127.127.28.0 refid GPS stratum 5 time1 0.125 flag1 1
#added for PPS accuracy:
server 127.127.22.0 minpoll 4 maxpoll 4
fudge 127.127.22.0 refid PPS
---------- patch to GL-MT300N-V2.dts ----------
--- a/target/linux/ramips/dts/GL-MT300N-V2.dts
+++ b/target/linux/ramips/dts/GL-MT300N-V2.dts
@@ -74,6 +74,11 @@
};
};
+ pps {
+ compatible = "pps-gpio";
+ gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
+ status = "okay";
+ };
};
&pinctrl {
-----------------------------------------------------------------