Created attachment 151857 [details] Patch for adding pps function to ucom(4) driver Hi, I wrote a patch to add pluse capturing support function to the ucom diver. This can be used to set up a stratum 1 NTP servers using a PPS1 USB GPS device (e.g. Navisys GR-701W). I've tested this patch with Navisys GR-701W and ntpd in ntp-4.2.8p1b5. -- example result of ntpq -p -c kern pll offset: 24.0225 pll frequency: 1.66617 maximum error: 0.423459 estimated error: 0.029453 kernel status: pll ppssignal nano pll time constant: 8 precision: 1e-06 frequency tolerance: 495.911 pps frequency: 6.8631 pps stability: 57.1917 pps jitter: 0.909 calibration interval 256 calibration cycles: 59 jitter exceeded: 122 stability exceeded: 3 -- How-To-Repeat: Apply the patch: cd /usr/src patch -p0 < freebsd-pps-ucom-20150119.patch Build the kernel module: cd /usr/src/sys/modules/usb/ucom make && make install
It looks like this may not handle the UART_PPS_ON_CTS case or capture-clear of DCD correctly. I think I've got hardware here that can test both conditions, I'll give it a try and perhaps propose an alternative patch if I can.
A commit references this bug: Author: hselasky Date: Sat Mar 7 18:23:34 UTC 2015 New revision: 279728 URL: https://svnweb.freebsd.org/changeset/base/279728 Log: Add mutex support to the pps_ioctl() API in the kernel. Bump kernel version to reflect structure change. PR: 196897 MFC after: 1 week Changes: head/sys/kern/kern_tc.c head/sys/sys/param.h head/sys/sys/timepps.h
A commit references this bug: Author: hselasky Date: Sat Mar 7 18:25:59 UTC 2015 New revision: 279729 URL: https://svnweb.freebsd.org/changeset/base/279729 Log: Add PPS support to USB serial drivers. Bump kernel version to reflect structure change. PR: 196897 MFC after: 1 week Changes: head/sys/dev/usb/serial/usb_serial.c head/sys/dev/usb/serial/usb_serial.h head/sys/sys/param.h
Please verify the feature in FreeBSD 11-current. --HPS
Could you update the ucom manual page about this new feature aswell? Thank you! Don't forget to set hw.usb.ucom.pps_mode=xxx in /boot/loader.conf or /etc/sysctl.conf --HPS
A commit references this bug: Author: hselasky Date: Sat Mar 7 22:46:36 UTC 2015 New revision: 279756 URL: https://svnweb.freebsd.org/changeset/base/279756 Log: Use correct mode variable for PPS support. PR: 196897 Submitted by: ian @ MFC after: 1 week Changes: head/sys/dev/usb/serial/usb_serial.c
A commit references this bug: Author: hselasky Date: Sun Mar 8 08:34:50 UTC 2015 New revision: 279773 URL: https://svnweb.freebsd.org/changeset/base/279773 Log: Switch polarity of PPS events. PR: 196897 Submitted by: ian @ MFC after: 1 week Changes: head/sys/dev/usb/serial/usb_serial.c
Test results, using a 700MHz single-core TI AM335x ARM system (Beaglebone). The PPS(0) device is an on-chip timer configured as a latching time interval counter with a resolution of approximately 40nS. The PPS(1) device is an FTDI 2232H usb-serial adapter with PPS input on the DCD line. The same PPS signal is fed to both devices via a splitter and equal-length cables. As shown in this ntpq -p output, the latency of capturing the PPS via the USB pathway is approximately 45 microseconds compared to the TIC that latches a hardware counter. Even under heavy system load including bulk traffic to a USB drive on the same bus the latency increased to no more than 100uS. The second-to-second jitter is so low it's near the threshold of being measurable. remote refid st t when poll reach delay offset jitter ============================================================================== +PPS(0) .PPS. 0 l 6 16 377 0.000 -0.040 0.002 oPPS(1) .PPS. 0 l 16 16 377 0.000 -0.086 0.002 +dvb.hippie.lan .GPS. 1 u 15 64 377 1.296 0.147 1.838 The FDTI parts can reliably work with a PPS pulse as narrow as 50uS. Other brands may require a wider pulse, but consumer radio and GPS gear typically emits pulses 1mS wide.
The polling interval of USB host controllers is typically 125us. Your results come as no surprise :-) --HPS
Thank you for your hard work. I can use my PPS USB device at ease.