A sub-$150, FreeBSD based, GPS NTP server

Summary

This document is intended to be a quick guide for how to build your own compact GPS NTP server using a Motorola Oncore timing GPS receiver (VP/UT), Soekris net4801, and FreeBSD 9 or 10.

Bill of materials:

Item Approx. cost, USD
Soekris NET4801, used, with case $50
Motorola Oncore VP/UT+ $30
MCX <-> Female SMA bulkhead pigtail $5
5v GPS Antenna $15
4-8G CF Card $15
Set of 0.1" header jumpers $5
USB<->CF Adapter $10
2G CF Card $10
PCB standoffs and screws $5
* Typical eBay prices, February 2014

Hardware installation:

Mark and drill the case for your bulkhead SMA connector, as well as the GPS receiver (if you're using an Oncore series receiver (VP or UT), the template in the Mechanical section of the Motorola Oncore UT+ Engineering Notes will prove handy, as will the net4801 manual available from Soekris. Then install the GPS module, and MCX/SMA pigtail. You may consider a dab of purple or blue Permatex threadlocker on the fasteners as appropriate.

Connecting the GPS receiver

Color mappings are at your discretion, but this is how I chose to cross-connect the pictured system:
Connector Connector Connector Wire
net4801 JP4 net4801 JP5 Oncore J1 Color
NC 01 (+3.3 VDC) 01 (Bat) Yellow
NC 02 (+5 VDC) 02 (+5 VDC) Red
N 11 (GND) 03 (GND) Black
NC NC 04 (Vpp) N/A
NC NC NC N/A
01 (DCD*) 03 (GPIO0*) 06 (1PPS) Orange
05 (GND) NC 07 (1PPS RTN) Gray
NC 18 (TTL RXD) 08 (TTL TXD1) Blue
NC 19 (TTL TXD) 09 (TTL RXD1) Green
NC 20 (TTL GND) 10 (TTL RTN) White
* Use one or the other, as appropriate. DCD is easier, but potentially less accurate. GPIO instructions are not covered in this document.

Software environment

If you have no PXE environment, use a CF<->USB adapter and write the FreeBSD USB memstick image to the smaller CF card using another host. This step is necessary because comBIOS cannot boot from USB.

Install the CF card into the Soekris, and then connect the larger (target) CF card to the Soekris via the USB<->CF adapter.

The following parameters will need to be set via the loader to install, subsequently on the system for it to boot without panicing.

Append to /boot/device.hints (all versions):

    hint.acpi.0.disabled="1"
   

/boot/loader.conf For FreeBSD 9.1:

    kern.cam.ctl.disable=1
    vm.kmem_size_scale=1
    hw.ata.ata_dma=0
    console="comconsole"
   

/boot/loader.conf For FreeBSD 9.2 & 10.0:

    hw.ata.ata_dma="0"
    console="comconsole"
   

These can be set in /boot/device.hints and /boot/loader.conf on the install media if you have another FreeBSD host available.

Boot and install the system to the target disk, and include source if you wish to recompile the kernel. Before quitting the installer, make the same changes as above, in /boot/device.hints, and /boot/loader.conf, and don't forget to rename the root partition in /etc/fstab so it boots normally from ada0 (If you installed via USB, it will be configured for ad0, which will no longer be true after the CF cards are swapped.)

You should also set the following:

In /boot.conf:

    -h
   

In /etc/ttys, change the console entry to read:

    console	"/usr/libexec/getty Pc" 	vt100	on  secure
   

In /etc/rc.conf, ensure the following are set:

    sshd_enable="YES"
    ntpd_enable="YES"
    dumpdev="NO"
    sendmail_submit_enable="NO"
    sendmail_msp_queue_enable="NO"

   

And finally, if you're intending on rebuilding your kernel (recommended to reclaim about 10M of DRAM on this 128M platform), set the following in /etc/make.conf (this is needed to prevent the kernel compilation process from building unselected items as modules, which will take several hours on a net4801.):

    NO_MODULES=true
   

Then shutdown the system, move the CF card from the USB adapter to the internal slot, and boot normally.

FreeBSD configuration:

Here is a NET4801 kernel configuration file for 9.x Remove options ATA_CAM if you're building a new 10.x kernel: /usr/src/sys/i386/conf/NET4801

NTP configuration:

Add the following to /etc/devfs.conf:

    link	cuau1	oncore.serial.0
    link	cuau1	oncore.pps.0
   

NTP is available from support.ntp.org, download a current (development) version of ntpd 4.2.7, and run configure with the following parameters:

    ./configure --prefix=/usr --enable-debugging --enable-ONCORE --enable-SHM --with-crypto --enable-autokey --enable-ipv6

With that built and installed, here is a simple /etc/ntp.conf

    # Drift cache
    driftfile /etc/ntp/ntp.drift
  
    # Statistics logging
    statsdir /var/log/ntpstats/
    statistics loopstats peerstats clockstats 
    filegen loopstats file loopstats type day enable
    filegen peerstats file peerstats type day enable
    filegen clockstats file clockstats type day enable
   
    # Servers and Peers
    server ntp-nist.ldsbc.edu
    server montpelier.caltech.edu
    server tick.ucla.edu
   
    # Reference Clocks
    # Motorola Oncore/PPS
    server 127.127.30.0 prefer minpoll 16 maxpoll 16
    fudge 127.127.30.0 time1 0.000
   
    # Permit chimes, but not monitoring
    restrict -4 ntp-nist.ldsbc.edu notrap nomodify nopeer
    restrict -6 ntp-nist.ldsbc.edu notrap nomodify nopeer
    restrict -4 montpelier.caltech.edu notrap nomodify nopeer
    restrict -6 montpelier.caltech.edu notrap nomodify nopeer
    restrict -4 tick.ucla.edu notrap nomodify nopeer
    restrict -6 tick.ucla.edu notrap nomodify nopeer
    restrict -4 default notrap nomodify noquery nopeer
    restrict -6 default notrap nomodify noquery nopeer
  
    # Localhost
    restrict 127.0.0.1
    restrict ::1
     

And /etc/ntp.oncore0 (You can start in mode 4, give it lots of time to survey your position, or skip this step by using a handheld GPS or your phone to get your location for configuration purposes.):

   # /etc/ntp.oncore0
   #
   # Reference Clock configuration for Motorola Oncore UT+
   #
   # Five Choices for MODE
   #    (0) ONCORE is preinitialized, don't do anything to change it.
   #          nb, DON'T set 0D mode, DON'T set Delay, position...
   #    (1) NO RESET, Read Position, delays from data file, lock it in, go to 0D mode.
   #    (2) NO RESET, Read Delays from data file, do SITE SURVEY to get position,
   #                  lock this in, go to 0D mode.
   #    (3) HARD RESET, Read Position, delays from data file, lock it in, go to 0D mode.
   #    (4) HARD RESET, Read Delays from data file, do SITE SURVEY to get position,
   # [SITE SURVEY]
   #MODE 1
   #     NB. If a POSITION is specified in the config file with mode=(2,4) 
   #         then this position is set as the INITIAL position of the ONCORE.
   #         This can reduce the time to first fix.
   MODE 1
   LAT 33 29.00000 # + == North
   LONG -112 0.00000 # - == West
   HT 340.00 # GPS height, meters
   ASSERT
   HARDPPS
   MASK 10 # Elevation mask, degrees
   SHMEM /var/log/ntpstats/oncore.0
   TRAIM YES
   
Questions or comments should be sent to: msa@latt.net
$Header: /home/majdi/public_html/ntp/index.html,v 1.10 2014/03/17 01:54:18 majdi Exp majdi $