PPS driver, assigning gpio

I've made some progress. So keep in mind this is a learning exercise -- I realize I don't really need 3 stratum 1's on my home network, but it's forcing me to learn some things.

So first off I could use some help assigning the GPIO pin on my AR150. I've tried or considered:

  • Locating image-ar9330_glinet_gl-ar150.dtb on the device like I did for my Turris Omnia below. It seems the boot process on the AR150 doesn't use it.
  • Updating image-ar9330_glinet_gl-ar150.dtb in the imagebuilder directory and building a new image, but despite the file existing in the tree, the imagebuilder doesn't seem to make use of it.
  • Building from the SDK: I can't get it to work following Build system usage. The step make kernel_menuconfig fails with make: *** [/home/mjf/OpenWrt/openwrt-sdk-22.03.2-ath79-generic_gcc-11.2.0_musl.Linux-x86_64/include/toplevel.mk:223: toolchain/install] Error 1
  • Some patches on GitHub look promising, but if I can't get the SDK working, that probably won't help.
  • More mods from a very detailed Blog look even more promising, again perhaps if I could get the SDK to work.

So help on the above would be appreciated.

Things I did get working: on my Turris Omnia, it's as easy as mount /dev/mmcblk0p1 /boot to access the .dtb file and dtc -I dtb <armada-385-turris-omnia.dtb >armada-385-turris-omnia.dts to access the device tree file. Then just patch it similar to the previously mentioned article:

*** armada-385-turris-omnia.dts.orig	2022-11-20 08:43:35.081744891 -0800
--- armada-385-turris-omnia.dts	2022-11-08 08:20:56.000000000 -0800
***************
*** 476,481 ****
--- 476,483 ----
  				#interrupt-cells = <0x02>;
  				interrupts = <0x00 0x35 0x04 0x00 0x36 0x04 0x00 0x37 0x04 0x00 0x38 0x04>;
  				clocks = <0x04 0x00>;
+ 				linux,phandle = <0x1f>;
+ 				phandle = <0x1f>;
  			};
  
  			gpio@18140 {
***************
*** 1097,1100 ****
--- 1099,1108 ----
  		status = "disabled";
  		phandle = <0x11>;
  	};
+ 
+ 	pps@18 {
+ 		gpios = <0x1f 0x12 0x00>;
+ 		compatible = "pps-gpio";
+ 		status = "okay";
+ 	};
  };

and turn it back into a dtb file with dtc -I dts <armada-385-turris-omnia.dts >armada-385-turris-omnia.dtb (obviously you'll want to make a backup) and /dev/pps0 magically appears.

Other articles and things I found useful:

  • Stratum 1 NTP server using USB GPS for necessary OpenWRT packages and configs.
  • Microsecond accurate NTP with a Raspberry Pi and PPS GPS for doing this on a Pi (which I also did in the antenna picture below, and the electronics info there and NTP / Chrony config still apply to OpenWrt).
  • UART GPS NEO-6M: you can find these for 9-12 USD on Amazon and the like, but make sure you get one with the PPS pin.
  • Antennas are weird. I was having difficulty getting enough of a lock for PPS indoors. After reading various sites and my GPS' documentation, I saw reference to a ground plane for improving reception. So you can buy a 7cm ground plane on Amazon for like 15 USD (5 more than the GPS itself), or you can wrap a beer coaster in aluminum foil like I did, and voila! GPS lock and PPS output: