FreeBSD 12, NTP, 1pps, Parallel Port Device Name ?

Hi,

Workng with an experimental ntp test rig, with 3 local hardware time server references and one external from an internet ntp pool. The 1pps sync via the serial port dcd line is working fine, but having trouble with the parallel port ack alternative, as not sure which /dev name to use. From docs, it seems that there are 3 possible parallel port devices, lpt0, ppi0 and ppbus0. Both ppi0 and lpt0 appear in /dev. but not the ppbus entry, nor ppc1, which is found during boot. Have tried using lpt0 and ppi0, but both return errors:

ppi0: Inappropriate ioctl for device

lpt0: Device busy.

Hardare in use is a mini itx atom machine. /var/log/messages reports:

Aug 14 04:56:04 ntp-host kernel: ppc1: <Parallel port> port 0x378-0x37f irq 5 on acpi0
Aug 14 04:56:04 ntp-host kernel: ppc1: Generic chipset (NIBBLE-only) in COMPATIBLE mode
Aug 14 04:56:04 ntp-host kernel: ppbus0: <Parallel port bus> on ppc1
Aug 14 04:56:04 ntp-host kernel: lpt0: <Printer> on ppbus0
Aug 14 04:56:04 ntp-host kernel: lpt0: Interrupt-driven port
Aug 14 04:56:04 ntp-host kernel: ppi0: <Parallel I/O> on ppbus0

From that, looks like ppc1 is closest to the hardware, but nothing in /dev, so which is the correct device to use ?. Ntp docs are pretty good, but nothing at that sort of FreeBSD specific level...

Thanks

Chris
 
What specific hardware are you trying to connect?
Have you checked ppc(4) for compatibility?
Have you set any hints in /boot/device.hints?
 
ppc is a low level device. It gets "eaten" by the next-level devices that are built on top of it, which are ppi and lpt. I think the ppc devices don't have /dev/ entries, because there is no user API for actually using them; instead their only user is the ppbus subsystem in the kernel, which then provides services for higher-level drivers like lpt (parallel printer), ppi (bit-banging) and plip (IP over parallel port, a.k.a. LapLink).

To use the ppi interface, you have to use specialized ioctl() calls. No idea whether ntp has FreeBSD-specific support for that or not.

If I remember right (might be wrong), there is no support for bit-banging in the lpt driver.

I think the reason that you get 'device busy' when trying to use ppi is that the same physical port has also been absorbed by the lpt subsystem. In my vague recollection, to use ppi you have to disable lpt in the boot config file, at least for that port.
 
That's great, thanks for the explanation. Not expert on either ntp or FreeBSD internals. However, FreeBSD is one of the main supported os's for ntp server use, because of it's real time capability and has been for many years now.

Ntp uses a single interface line for the pulse per second signal. For the serial port, at rs232 level to the dcd line, for the parallel port, at ttl level to the the ack line. In both cases, receipt of a pps pulse generates an interrupt, which reads the current system clock value and saves it to a queue. Ntp knows about pps0, so a link must be setup in devfs.conf to point that at the chosen device, such as:

link cuau0 pps0 for the serial port.

There must be code in ntp to recognise which is in use and set up the interrupt handler for it.

device.hints is stock, with the following entry for the par port device:

hint.ppc.0.at="isa"
hint.ppc.0.irq="7"

However, the /var/log/messages file has an entry for ppc1, none for ppc0:

Aug 14 23:09:55 ntp-host kernel: ppc1: <Parallel port> port 0x378-0x37f irq 5 on acpi0
Aug 14 23:09:55 ntp-host kernel: ppc1: Generic chipset (NIBBLE-only) in COMPATIBLE mode
Aug 14 23:09:55 ntp-host kernel: ppbus0: <Parallel port bus> on ppc1

So, a confict between ntp and whatever else initialises the port as suggested ?. It does look like something might need to be disabled, but at what layer in the stack ?. Disable ppbus perhaps, and / or lpt0 ?. No boot.config file in /boot...

Thanks,

Chris
 
Still trying to track down the lpt - ntp issue

* Fixed dual ppc device issue at boot, comment out ppc0 in /boot/device.hints
That defined int=7, when system (?) later finds it and sets irq=5, creating
a second device, ppc1.

* The device error returned busy, so maybe a hardware problem ?. Jumpered
printer busy line to gnd. ie: printer not busy, but still same result.

* Even with all ntp config disabled, lptcontrol -e or any other option
returns device busy, so this starts to look like a bug. Doing a bit
more digging, we find a bug report from 2004:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=57630

Comment 4 describes what i'm seeing exactly.

Wonder if this was ever fixed ?.

Have both the first and second editions of the internals book, but not enough
info to work out how the parallel port device and associated layers work. Ideally,
a diagram showing the various modules and how they interact would be a great
help. No point in looking at sources until that mental model is in place.

Whatever, stumped at the mo, any other suggestions appreciated. I know ntp pps
support is a bit of an obscure corner case, but it is claimed to work...

Thanks,

Chris
 
There is something suspicious about the fact that you have ppc1 without having ppc0. Anyone know how that device numbering works?
 
There is something suspicious about the fact that you have ppc1 without having ppc0. Anyone know how that device numbering works?

In fact, had both, ppc0 and ppc1, which looks like the same device layer was being setup twice in 2 parts of the system. If the interrupt is set at 5 in the hints file, then we just get a single example...
 
Back
Top