Wednesday, February 3, 2010

FreeBSD with GPS to give Stratum 0 time source

I have ordered a bu-353 gps mouse. I hope to add this to Freebsd as it uses a prolific chipset, so using ucom and uplcom it should map as /dev/ttyU0 .

To use this as a time source , I can configure NTPd via ntp.conf , to use the serial port, or I can used gpsd to manage the gps, and tell ntp.conf to use shared memory to read from gpsd.

not using gpsd is attractive as it's relatively large, 1.5MB statically compiled.

To statically compile, you need to run configure, in my case like this

./configure --disable-python --enable-static --disable-shared --prefix=/usr/local/m0n0/ --disable-sirf --disable-tsip --disable-fv18 --disable-tripmate --disable-earthmate --disable-itrax --disable-ashtech --disable-navcom --disable-garmin --disable-ubx --disable-evermore --disable-gpsclock --disable-rtcm104 --disable-ntrip --enable-fixed-port-speed=4800

then modify the Makefile to add -all-static like this;

LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -all-static -o $@

CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) \
$(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -all-static -o $@

then run gpsd like this;

./gpsd -n /dev/ttyU0


ntp.conf should contain this line for directly using the serial port. But you should make /dev/gps0 first by

ln /dev/ttyU0 /dev/gps0

server minpoll 4
fudge time1 0.000 refid GPS0

or to use shared memory and gpsd

server minpoll 4
fudge refid GPSD

and use PPS

ln /dev/ttyU0 /dev/pps0

server minpoll 4
fudge time1 0.000 refid PPS0