Git Product home page Git Product logo

rpi-cm4-ptp-guide's Introduction

Guide to using the hardware PTP support in the Raspberry Pi CM4

This is still a work-in-progress. Suggestions for improvements are very welcome and can be made by creating issues.

The Raspberry Pi Compute Module 4 (CM4) has hardware support for the Precision Time Protocol (PTP). This repository is a guide to how to use this to provide an accurate source of time within your local network.

Although the CM4 does not have an Ethernet jack, it does have an Ethernet PHY, the Broadcom BCM54210PE, which has support for PTP. Linux kernel support for this was added recently (2022), as discussed in raspberrypi/linux#4151. This support has now been merged into the mainline Linux kernel.

The PTP support involves the Ethernet PHY having its own clock, called the PTP hardware clock (PHC), and being able to use this clock to timestamp incoming and outgoing network packets. This enables the CM4 to make use of PTP, but it is not by itself particularly exciting: similar functionality is available on many NICs. The exciting part is that the CM4 provides a pin that allows the PHC to be synchronized with an external pulse per second (PPS) signal. When this pin is connected to the PPS output of a GPS receiver, the CM4 can providech a highly accurate source of time for PTP within a local area network. (As far as I know, the only other inexpensive, easy way to to get this functionality is using an Intel i210-T1 PCIe card.) The CM4 can also generate a PPS signal from the PHC on this pin: this makes it possible to measure the accuracy of the PHC.

There's a useful introductory blog from Jeff Geerling and also a video.

This goal of this repository is to be a guide to taking advantage of this. The guide is split into the following sections:

Results

This shows the results from using a TAPR TICC in interval mode with two CM4 PTP slaves

  • both slaves synchronized to a CM4 master using a u-blox RCB-F9T connected to a roof-mounted, dual-frequency antenna
  • E2E, UDP IPv4 multicast (i.e. linuxptp default)
  • all three machines connected to a FS IES3110-series switch (configured as transparent, one-step)
  • TICC 10Mhz reference is a BG7TBL

tdev-20221129 mtie-20221129

References

Fedora has great docs for PTP, although some details are different for Raspberry Pi OS, which is Debian-based.

rpi-cm4-ptp-guide's People

Contributors

bradh avatar jclark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpi-cm4-ptp-guide's Issues

testptp pulse width increase beyond 4095 nano seconds ?

Hi

Is it possible to increase alter the testptp program or something under it to allow a longer pulse from pps out pin on the cm4 ?

-w 4095 is the maximum which works ....from what I can see the testptp supports larger values ...however this is the maximum value allowed with this hardware without error ....is there anyway to increase this please ?

maybe there is good reason this cannot be done ?

Thanks

Jon G4TSN

GPS strange behavior

Hi,

I am noticing a strange behavior on the GPS module I have for the test.

When I power off the CM4 and leave it for about 5 minutes off and plug in the power the GPS is stalled no connection nothing. Now if remove the power and power on again it start working.

I have partially resolve this by remove the pin RXD on GPS. After that not an issue no many power cycles I do.
But it has be connected to be normal.

Is there any config that should do either to GPS or CM4?


And an other issue is that with the sernet can not connect via the ublox app on Windows. I have enter on the app tcp://192.168.2.142:2002 which .142 is the CM4 ip address but can not connect. Even with ts2phc stopped no response still.

Regards.

TimeBeat CM4 module does not fit Waveshare PoE board

I just bought the Waveshare CM4 PoE Board, and a TimeBeat module.

It seems the TimeBeat modules do not fit the Waveshare PoE board, due to the protrusion to the left for the SIT modules (as mentioned on the 'GPS receiver hardware options' page in this guide).

Since both the Waveshare board and the TimeBeat modules are discussed as possible hardware options in the guide, I thought it might be worth mentioning that they unfortunately don't fit together.

event time via /dev/ptp0 not in order sporadically

My CM4 modules (I have thee) have been up and running over one and half month, and I sometimes see unlock state reported by ts2phc like this.

root@gm2:/home/kondou# grep "master offset" /var/log/syslog|grep s0 | tail -10
Mar 17 16:10:38 gm2 ts2phc: [202588.984] eth0 master offset 999999999 s0 freq +1286
Mar 17 16:10:39 gm2 ts2phc: [202589.992] eth0 master offset 1 s0 freq +1286
Mar 18 08:10:51 gm2 ts2phc: [260201.988] eth0 master offset 1000000004 s0 freq +1186
Mar 18 08:10:52 gm2 ts2phc: [260202.996] eth0 master offset 3 s0 freq +1186
Mar 18 08:17:31 gm2 ts2phc: [260601.984] eth0 master offset 1000000002 s0 freq +1196
Mar 18 08:17:32 gm2 ts2phc: [260602.992] eth0 master offset -2 s0 freq +1196
Mar 18 10:01:08 gm2 ts2phc: [266819.024] eth0 master offset 1000000000 s0 freq +1196
Mar 18 10:01:09 gm2 ts2phc: [266820.032] eth0 master offset -3 s0 freq +1196
Mar 18 11:38:00 gm2 ts2phc: [272630.984] eth0 master offset 999999994 s0 freq +1217
Mar 18 11:38:01 gm2 ts2phc: [272631.992] eth0 master offset -15 s0 freq +1217

I tried to identify what was happening when these situation happened with this command.

root@gm2:/home/kondou# egrep 'extts|poll returns zero|ts2phc.*s0|nmea delay' /var/log/syslog | less

Here is the related logs for the last 2 lines in the above.

Mar 18 11:37:58 gm2 ts2phc: [272629.220] nmea delay: 308031218 ns
Mar 18 11:37:58 gm2 ts2phc: [272629.220] eth0 extts index 0 at 1679107115.000000003 corr 0 src 679107115.930324473 diff 3
Mar 18 11:37:59 gm2 ts2phc: [272630.228] nmea delay: 303697621 ns
Mar 18 11:37:59 gm2 ts2phc: [272630.228] eth0 extts index 0 at 1679107116.000000003 corr 0 src 1679107116.942360597 diff 3
Mar 18 11:38:00 gm2 ts2phc: [272630.984] nmea delay: 523486561 ns
Mar 18 11:38:00 gm2 ts2phc: [272630.984] eth0 extts index 0 at 1679107116.999999994 corr 0 src 1679107116.478568761 diff 999999994
Mar 18 11:38:00 gm2 ts2phc: [272630.984] eth0 master offset 999999994 s0 freq +1217
Mar 18 11:38:01 gm2 ts2phc: [272631.992] nmea delay: 369493444 ns
Mar 18 11:38:01 gm2 ts2phc: [272631.992] eth0 extts index 0 at 1679107117.999999985 corr 0 src 1679107118.640551973 diff -15
Mar 18 11:38:01 gm2 ts2phc: [272631.992] eth0 master offset -15 s0 freq +1217
Mar 18 11:38:02 gm2 ts2phc: [272633.000] nmea delay: 246871044 ns
Mar 18 11:38:02 gm2 ts2phc: [272633.000] eth0 extts index 0 at 1679107118.999999976 corr 0 src 1679107119.771175602 diff -24
Mar 18 11:38:03 gm2 ts2phc: [272634.008] nmea delay: 242543557 ns
Mar 18 11:38:03 gm2 ts2phc: [272634.008] eth0 extts index 0 at 1679107119.999999978 corr 0 src 1679107120.783509313 diff -22
Mar 18 11:38:04 gm2 ts2phc: [272635.016] nmea delay: 232726656 ns
Mar 18 11:38:04 gm2 ts2phc: [272635.016] eth0 extts index 0 at 1679107120.999999993 corr 0 src 1679107121.801321605 diff -7

I noticed src time for the 3rd one (1679107116.478568761) comes later at 2nd one (1679107116.942360597), and all of unlocked situation happened just after this kind of reversed ordered time.

This time information is obtained via read() from /dev/ptp0, and do I have to investigate at kernel side? Seeing from the log, it should have been okay, if event.t.sec for the 3rd one was 1679107117, not 1679107116...

CM4 P2P timestamping

Hi,
I could successfully setup a ptp master on a CM4 pi and when using E2E pdelay mechanism (UDP) then it seems to work fine. low nanosecond jitter and stead pdelay values.
when switching to P2P mode, then the pdelay values seem to jump around at the 60 to 80us mark as if it is being software timestamped. Therefore the sync is also inaccurate around those values. All settings and hardware timestamping etc seem fine, but it is as if the L2 packets are not timestamped right. any ideas?

When reboot the CM4 sometime halts

Hi,

I am try to solve an issue but I haven't success yet. When everything operate smoothly and do a normal reboot sometimes the CM4 hangs can not connect via ssh or send PTP packets. To resolve this I need to do a powercycle. It does not hang all the time but some off them.

Any idea what might be cause this?

Regards.

Kernel RT or LL question.

I have a simple question and I hope if someone can help with that.

I am wondering if an RT or LL Kernel would help the performance of PTP or would be the same with the generic kernel.

So far from what I am seeing with LL kernel and CPU Governor on Performance has almost the same response. The only difference is on client device that the deltas seems to be a bit better.

The LL kernel build by kdoren and can be found on below link:

https://github.com/kdoren/linux/releases/tag/rpi_6.1.54-rt15

If someone has try CM4 with RT or LL or if need that kernel please share the experience.

Regards.

Not working with TimeBeat M8F

Thank you very much for providing good instruction.

Recently, I received Timebeat CM4 module and configured as described.
It looks working, but the result of 'phc_ctl eth0 cmp' is far from -37 second after booting the OS. This looks fixed by setting 'phc_ctl eth0 "set;" adj 37'. So, setting PHC clock needs to be done while booting the system.

Or, am I missing something?

Wrong time after cable unplugged

If chrony with a PHC refclock and ts2phc are both running and the cable is unplugged for a time, the PHC will end up with the wrong time (many seconds out).

I have observed this with ts2phc -s generic. I am not sure if it happens with ts2phc -s nmea.

Attached is log showing what happens.

ptp-unplug.log

Cm4 PWM Fan issue

Hi,

Yesterday I received the metal case of the Waveshare which has the built in fan. The problem is when the overlay loads it stop spinning the fan. I have pushed the CM4 to almost 68 degrees of temperature but the fan still not working. I am seeing the cooling_device to be available on /sys/class/thermal/.

$ watch "grep -s . /sys/class/thermal/thermal_zone*/* /sys/class/thermal/cooling_device*/*"

/sys/class/thermal/thermal_zone0/available_policies:step_wise
/sys/class/thermal/thermal_zone0/integral_cutoff:0
/sys/class/thermal/thermal_zone0/k_d:0
/sys/class/thermal/thermal_zone0/k_i:0
/sys/class/thermal/thermal_zone0/k_po:0
/sys/class/thermal/thermal_zone0/k_pu:0
/sys/class/thermal/thermal_zone0/mode:enabled
/sys/class/thermal/thermal_zone0/offset:670040
/sys/class/thermal/thermal_zone0/policy:step_wise
/sys/class/thermal/thermal_zone0/slope:-487
/sys/class/thermal/thermal_zone0/sustainable_power:0
/sys/class/thermal/thermal_zone0/temp:47712
/sys/class/thermal/thermal_zone0/trip_point_0_hyst:2000
/sys/class/thermal/thermal_zone0/trip_point_0_temp:75000
/sys/class/thermal/thermal_zone0/trip_point_0_type:active
/sys/class/thermal/thermal_zone0/trip_point_1_hyst:2000
/sys/class/thermal/thermal_zone0/trip_point_1_temp:50000
/sys/class/thermal/thermal_zone0/trip_point_1_type:active
/sys/class/thermal/thermal_zone0/trip_point_2_hyst:0
/sys/class/thermal/thermal_zone0/trip_point_2_temp:110000
/sys/class/thermal/thermal_zone0/trip_point_2_type:critical
/sys/class/thermal/thermal_zone0/type:cpu-thermal
/sys/class/thermal/cooling_device0/cur_state:0
/sys/class/thermal/cooling_device0/max_state:10
/sys/class/thermal/cooling_device0/type:emc2305_fan

If someone have this case with the fan and is working please let me know how to make it work.

Best regards,
Jim

Make it easier for users to add arbitrary ptp4l configuration

Hi,

I am trying to put PTP port settings on ptp4l-gm config file but seems not to be working.

Example I want to decrease the logannounceinterval but seems not do anything.

The settings that need to make it work correct are:

logAnnounceInterval

logSyncInterval

logMinDelayReqInterval

announceReceiptTimeout

delay_mechanism

domainNumber

dscp_event

dscp_general

Regards.

LEA-M8F U-Center Timepulse issue

Hi,

I have upgraded from NEO-6m module to LEA-M8F and I am facing an issue. When I start the CM4 the PHY is not working although the NIC leds are on.

After troubleshooting a bit I am seeing that if I disconnect the PPS cable or disable the PPS from the U-center the CM4 operates normally.

If I connect most of the times it loses the PHC (on dmesg says that PHC not connected).

The settings on TP5 are below:

image

Any help is appreciated.

Regards.

configuring IES3110-8TF-R as TC

Hi,

Yesterday, I managed to obtain IES3110-8TF-R at last, and am trying to configure it as TC.
Anyone successfully has configured it? I've been fumbling even with the guide(ies3110-8tf-and-ies3110-8tf-p-switches-configuration-guide.pdf). There's no exact explanation in the guide about the profile... I tried one by one, but it does not work as TC. I might not have done something correctly...
image

MOTU AVB switch as TC

It looks like two types of MOTU AVB switch and both are slightly different, but I'm not sure if there is any differences in its functionality.

image
image

And I expected MOTU AVB switch behaves as TC and correction field in PTP data should have meaningful data, but seeing from the ethernet data via wireshark, correction field is always all zero. The result of tcpdump at slave shows all zero correlation data from GMC. All devices are connected to MOTU AVB switch. I have both types MOTU AVB switch, and I cannot see any data other than zero in correlation field for both type. The firmware of the switch is the latest one.

Do i misunderstand what TC does, or am I missing something?

CM4 SYNC_OUT does not have any signal output

I want to measure the pps accuracy of the output from phc. I follow the steps below.
sudo ./testptp -d /dev/ptp0 -L 0,2
sudo ./testptp -d /dev/ptp0 -p 1000000000 -w 1000

But SYNC_OUT does not have any signal output. I used an oscilloscope to measure J2 PIN9.

SYNC OUT PIN can be used as input to receive PPS signals. Referring to my following steps, you can see that PHC has received PPS events
root@raspberrypi:/home/falcon# ./testptp -d /dev/ptp0 -L 0,1
0,1
set pin function okay

root@raspberrypi:/home/falcon# ./testptp -e 5
external time stamp request okay
event index 0 at 124.523073480
event index 0 at 125.523075280
event index 0 at 126.523077072
event index 0 at 127.523078872
event index 0 at 128.523080640

jclark,do you have any idea, thanks,I am looking forward to your answer very much

parameter setting for grandmaster

I was trying to change some of parameters, like priority1 or priority2 for grandmaster, and I though it would be done at /etc/default/ptp4l-gm at first, but nothing was changed by seeing ethernet data via wireshark.
I also tried to change /usr/local/sbin/ptp4l-gm-set.sh, but this didn't also look like the right one to be modified.

Which file do I have to modify to change the default parameter for ptp4l?

Occasional bad, extra PPS pulses

I am seeing occasional (e.g. once every several days) extra PPS pulses, which cause ts2phc to perform some extreme adjustments. Here's an example, which is with a u-blox M8T with an outside, but ground-level antenna (so less than perfect sky-view).

Nov 13 16:38:42 wensleydale ts2phc: [104209.501] nmea sentence: GPRMC,093842.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:43 wensleydale ts2phc: [104210.488] nmea delay: 147943835 ns
Nov 13 16:38:43 wensleydale ts2phc: [104210.488] eth0 extts index 0 at 1668332359.999999995 corr 0 src 1668332360.987633605 diff -5
Nov 13 16:38:43 wensleydale ts2phc: [104210.488] eth0 master offset         -5 s2 freq  +13780
Nov 13 16:38:43 wensleydale ts2phc: [104210.504] nmea sentence: GPRMC,093843.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:44 wensleydale ts2phc: [104211.496] nmea delay: 150866287 ns
Nov 13 16:38:44 wensleydale ts2phc: [104211.496] eth0 extts index 0 at 1668332360.999999981 corr 0 src 1668332361.992675857 diff -19
Nov 13 16:38:44 wensleydale ts2phc: [104211.496] eth0 master offset        -19 s2 freq  +13765

Here it reads two nmea sentences without an intervening pulse

Nov 13 16:38:44 wensleydale ts2phc: [104211.504] nmea sentence: GPRMC,093844.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:45 wensleydale ts2phc: [104212.501] nmea sentence: GPRMC,093845.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:45 wensleydale ts2phc: [104212.504] nmea delay: 148658469 ns
Nov 13 16:38:45 wensleydale ts2phc: [104212.504] eth0 extts index 0 at 1668332361.999999998 corr 0 src 1668332362.2876398 diff -2
Nov 13 16:38:45 wensleydale ts2phc: [104212.504] eth0 master offset         -2 s2 freq  +13776
Nov 13 16:38:45 wensleydale ts2phc: [104213.008] nmea delay: 148658469 ns

This next pulse is is an extra, spurious pulse. I think 1668332362.43187178 is the PHC of the pulse. It's an extra one between the previous one, which is roughly 1668332362, and the next one, which is roughly 1668332363.

Nov 13 16:38:45 wensleydale ts2phc: [104213.008] eth0 extts index 0 at 1668332362.431871787 corr 0 src 1668332363.506861520 diff -568128213
Nov 13 16:38:45 wensleydale ts2phc: [104213.008] eth0 master offset -568128213 s2 freq -100000000
Nov 13 16:38:46 wensleydale ts2phc: [104213.505] nmea sentence: GPRMC,093846.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:46 wensleydale ts2phc: [104213.512] nmea delay: 152682848 ns
Nov 13 16:38:46 wensleydale ts2phc: [104213.512] eth0 extts index 0 at 1668332363.034413526 corr 0 src 1668332363.6911093 diff 34413526
Nov 13 16:38:46 wensleydale ts2phc: [104213.512] eth0 master offset   34413526 s2 freq +34427304
Nov 13 16:38:47 wensleydale ts2phc: [104214.504] nmea sentence: GPRMC,093847.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:47 wensleydale ts2phc: [104214.521] nmea delay: 151118484 ns
Nov 13 16:38:47 wensleydale ts2phc: [104214.521] eth0 extts index 0 at 1668332364.021504083 corr 0 src 1668332364.16857268 diff 21504083
Nov 13 16:38:47 wensleydale ts2phc: [104214.521] eth0 master offset   21504083 s2 freq +31841918
Nov 13 16:38:48 wensleydale ts2phc: [104215.502] nmea sentence: GPRMC,093848.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:48 wensleydale ts2phc: [104215.528] nmea delay: 149682950 ns
Nov 13 16:38:48 wensleydale ts2phc: [104215.528] eth0 extts index 0 at 1668332364.989240046 corr 0 src 1668332365.25860902 diff -10759954
Nov 13 16:38:48 wensleydale ts2phc: [104215.528] eth0 master offset  -10759954 s2 freq +6029106
Nov 13 16:38:49 wensleydale ts2phc: [104216.504] nmea sentence: GPRMC,093849.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:49 wensleydale ts2phc: [104216.536] nmea delay: 151196759 ns
Nov 13 16:38:49 wensleydale ts2phc: [104216.536] eth0 extts index 0 at 1668332365.978683997 corr 0 src 1668332366.32350224 diff -21316003
Nov 13 16:38:49 wensleydale ts2phc: [104216.536] eth0 master offset  -21316003 s2 freq -7754929
Nov 13 16:38:50 wensleydale ts2phc: [104217.504] nmea sentence: GPRMC,093850.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:50 wensleydale ts2phc: [104217.544] nmea delay: 151323978 ns
Nov 13 16:38:50 wensleydale ts2phc: [104217.544] eth0 extts index 0 at 1668332366.983917652 corr 0 src 1668332367.40235709 diff -16082348
Nov 13 16:38:50 wensleydale ts2phc: [104217.544] eth0 master offset  -16082348 s2 freq -8916075
Nov 13 16:38:51 wensleydale ts2phc: [104218.504] nmea sentence: GPRMC,093851.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:51 wensleydale ts2phc: [104218.552] nmea delay: 151517308 ns
Nov 13 16:38:51 wensleydale ts2phc: [104218.552] eth0 extts index 0 at 1668332367.992624769 corr 0 src 1668332368.48024659 diff -7375231
Nov 13 16:38:51 wensleydale ts2phc: [104218.552] eth0 master offset   -7375231 s2 freq -5033662
Nov 13 16:38:52 wensleydale ts2phc: [104219.502] nmea sentence: GPRMC,093852.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:52 wensleydale ts2phc: [104219.560] nmea delay: 148823090 ns
Nov 13 16:38:52 wensleydale ts2phc: [104219.560] eth0 extts index 0 at 1668332368.998448447 corr 0 src 1668332369.58759544 diff -1551553
Nov 13 16:38:52 wensleydale ts2phc: [104219.560] eth0 master offset   -1551553 s2 freq -1422554
Nov 13 16:38:53 wensleydale ts2phc: [104220.501] nmea sentence: GPRMC,093853.00,A,1343.91052,N,10038.68416,E,0.000,,131122,,,A,V
Nov 13 16:38:53 wensleydale ts2phc: [104220.568] nmea delay: 147817069 ns
Nov 13 16:38:53 wensleydale ts2phc: [104220.568] eth0 extts index 0 at 1668332370.000636084 corr 0 src 1668332370.67735419 diff 636084
Nov 13 16:38:53 wensleydale ts2phc: [104220.568] eth0 master offset     636084 s2 freq +299618

Alternatives to CM4 ?

First of all, a huge thank you @jclark and all the other people involved,
this is the most detailed and well curated place I could find about making a PTP enabled device for time keeping.

Unfortunately, I have been struggling with getting my hands on a CM4 for months and I really do need to find an alternative now.

This might not be the best place to post, but I wanted an opinion about possible alternatives that can be used to the CM4.

Note that I can't use ebay to source the CM4.

The only mention I found about IEEE 1588 support on a device similar to the Raspberry Pi that is also in stock is the Arduino Portenta X8

Could this be a valuable option? Are there other options you could suggest?

One thing I noticed is that in the Arduino documentation is specified the Ethernet port supports AVB and IEEE 1588.

You also mentioned in your documentation the Mikrotik Switch is designed for AVB, but it is not clear to me what this means in practice.

For example, would that imply the device can be used only as slave but not a master clock?

Can the rasp pi 5 provide the GPS locked time server with PTP ?

Hi Question
Does anyone know if the Pi 5 can be used to provide the GPS locked time server with PPS to GPIO and transmitting the PTP via network to several clients using this project with cm4 to supply PPS signal out to various devices for time sync ?

I believe from reading the Pi 5 can do the hardware time stamp as server, but not as client create the PPS to GPIO ....so clients would need to use cm4 as they have the sync pin out ? doesn't look like its possible to use a pi 5 as a client and output the network sync PPS via a GPIO ?

Can someone confirm this please I just want to decide to order some cm4 boards or pi 5's

Thanks

Jon

Support for linuxptp v4?

Thank you for a fantastic guide.

I run into this issue when trying to run linuxptp v4.2, the same as: raspberrypi/linux#5947 (comment). In particular, ts2phc runs fine while ptp4l prints this message

ptp4l[932.128]: timed out while polling for tx timestamp
ptp4l[932.128]: increasing tx_timestamp_timeout may correct this issue, but it is likely caused by a driver bug

I'm not sure how to fix this. The reason I ask is because I'd like to use a higher baud rate, and the support is only added in a later version of linuxptp.

PHC clock locked/unlocked?

About a week ago, I placed GNSS antenna on aluminum ground plate (150x200mm) in my veranda which is my best place toward the sky. I didn't see so much difference with and without ground plate in my environment (TimeBeat M8F).

On the other hand, ts2phc has been up and running for over 10 days. ts2phc also left offset information in syslog messages. I sometimes examine how it looks like. I'm not exactly sure what s0/s1/s2 means, but seeing from the explanation for ptp4l, s0 means 'unlocked', s1 means 'clock step' and s2 means 'locked'. If that is also applied to ts2phc, PHC is unlocked when I see s0. Is my understandings is correct? And for s2 state, ts2phc says 'locked', but the offset is fairly large. Is that 'locked' state means that trying to minimize the offset, not fairly small?

What I'm concerned is any PTP message as grandmaster may be useless when it's in s0 state...

And, I'm not sure why this s0 situation happens...

These messages are

# grep "master offset" /var/log/syslog | less
Mar 2 05:00:41 gm3 ts2phc: [976276.540] eth0 master offset -5 s2 freq +5257
Mar 2 05:00:42 gm3 ts2phc: [976277.548] eth0 master offset 1 s2 freq +5262
Mar 2 05:00:43 gm3 ts2phc: [976278.556] eth0 master offset -4 s2 freq +5257
Mar 2 05:00:44 gm3 ts2phc: [976279.564] eth0 master offset 3 s2 freq +5263
Mar 2 05:00:45 gm3 ts2phc: [976280.572] eth0 master offset 4 s2 freq +5265
Mar 2 05:00:46 gm3 ts2phc: [976281.580] eth0 master offset 999999996 s0 freq +5265
Mar 2 05:00:47 gm3 ts2phc: [976282.588] eth0 master offset 999999995 s0 freq +5265
Mar 2 05:00:48 gm3 ts2phc: [976283.596] eth0 master offset -6 s2 freq -100000000
Mar 2 05:00:49 gm3 ts2phc: [976284.604] eth0 master offset 87874350 s2 freq -12125650
Mar 2 05:00:51 gm3 ts2phc: [976286.620] eth0 master offset 123500359 s0 freq -12125650
Mar 2 05:00:52 gm3 ts2phc: [976287.629] eth0 master offset 135631336 s0 freq -12125650
Mar 2 05:00:53 gm3 ts2phc: [976288.637] eth0 master offset 147762314 s1 freq -60769523
Mar 2 05:00:54 gm3 ts2phc: [976289.644] eth0 master offset 405384 s2 freq -60364139
Mar 2 05:00:55 gm3 ts2phc: [976290.653] eth0 master offset 51771100 s2 freq -8876808
Mar 2 05:00:56 gm3 ts2phc: [976291.668] eth0 master offset 68442484 s2 freq +23325906
Mar 2 05:00:57 gm3 ts2phc: [976292.676] eth0 master offset 50297065 s2 freq +25713232
Mar 2 05:00:58 gm3 ts2phc: [976293.684] eth0 master offset 24977882 s2 freq +15483169
Mar 2 05:00:59 gm3 ts2phc: [976294.696] eth0 master offset 7816104 s2 freq +5814755
Mar 2 05:01:00 gm3 ts2phc: [976295.706] eth0 master offset 356642 s2 freq +700124
Mar 2 05:01:01 gm3 ts2phc: [976296.712] eth0 master offset -1227949 s2 freq -777474
Mar 2 05:01:02 gm3 ts2phc: [976297.720] eth0 master offset -707854 s2 freq -625764
Mar 2 05:01:03 gm3 ts2phc: [976298.728] eth0 master offset -48683 s2 freq -178949
Mar 2 05:01:04 gm3 ts2phc: [976299.736] eth0 master offset 221990 s2 freq +77119
Mar 2 05:01:05 gm3 ts2phc: [976300.744] eth0 master offset 201739 s2 freq +123465
Mar 2 05:01:06 gm3 ts2phc: [976301.752] eth0 master offset 93250 s2 freq +75498
Mar 2 05:01:07 gm3 ts2phc: [976302.760] eth0 master offset 12543 s2 freq +22766
Mar 2 05:01:08 gm3 ts2phc: [976303.768] eth0 master offset -16914 s2 freq -2928
Mar 2 05:01:09 gm3 ts2phc: [976304.776] eth0 master offset -14768 s2 freq -5856
Mar 2 05:01:10 gm3 ts2phc: [976305.784] eth0 master offset -4360 s2 freq +121
Mar 2 05:01:11 gm3 ts2phc: [976306.540] eth0 master offset 2282 s2 freq +5455
Mar 2 05:01:12 gm3 ts2phc: [976307.548] eth0 master offset 2133 s2 freq +5991
Mar 2 05:01:13 gm3 ts2phc: [976308.556] eth0 master offset 1415 s2 freq +5913
Mar 2 05:01:14 gm3 ts2phc: [976309.564] eth0 master offset 765 s2 freq +5687
Mar 2 05:01:15 gm3 ts2phc: [976310.572] eth0 master offset 326 s2 freq +5478
Mar 2 05:01:16 gm3 ts2phc: [976311.580] eth0 master offset 104 s2 freq +5354
Mar 2 05:01:17 gm3 ts2phc: [976312.588] eth0 master offset 0 s2 freq +5281
Mar 2 05:01:18 gm3 ts2phc: [976313.596] eth0 master offset -29 s2 freq +5252
Mar 2 05:01:19 gm3 ts2phc: [976314.604] eth0 master offset -26 s2 freq +5246
Mar 2 05:01:20 gm3 ts2phc: [976315.612] eth0 master offset -16 s2 freq +5248
Mar 2 05:01:21 gm3 ts2phc: [976316.620] eth0 master offset -8 s2 freq +5251
Mar 2 05:01:22 gm3 ts2phc: [976317.628] eth0 master offset -3 s2 freq +5254
Mar 2 05:01:23 gm3 ts2phc: [976318.636] eth0 master offset -1 s2 freq +5255

PTP enabled switch as a Slave

Hi,

This is not an issue, but just fyi.

I have two grandmaster on the same network, and one of them is for backup.
Now I tried to make IES3110-8TF-R as Slave with this backup just as an experiment.

  1. create Slaveonly clock
    image
  2. enable port where grandmaster is connected, and go to Ports Configuration
    image
  3. change Not Slave to True
    image
  4. IES3110-8TF-R now runs as slave
    image

Offset From Master looks like 120μs, but help page says 'measured in ns' which I don't think so... If the offset is really 120μs, it seems large number. This may due to Clock Adjustment method, but I have no idea how to use internal Timer as Clock Adjustment method like E2eTransp does, but it's always Software.

Serial port

Hi,

After I have replaced the module I did a complete refresh on CM4 all ok so far.

But now the /dev/ttyAMA0 is not visible anymore, instead is serial0 or /dev/ttyS0. Is that an issue if I leave it like this?

My CM4 has not wifi built in, only EMMC.

Document need to use dhcpcd on bookworm.

HI,

I have installed the Raspbian 12 (Bookworm) on a new CM4 setup followed the instructions and on reboot (or power on) the service are not auto starting.

If manually hit the command "sudo systemctl start ptp4l-gm phc2shm" is working and services are starting.

I have tried on Raspbian 11 (again) and work as supposed to be.

Probably this is due to Network Manager, so the dhcpd hook not working as it does on Raspbian 11 (Bullseye)?

A bit help would be appreciated.

Best regards.

P.S.

I add the output of the three services:

ptp4l-gm.service - Precision Time Protocol (PTP) grandmaster service Loaded: loaded (/etc/systemd/system/ptp4l-gm.service; disabled; preset: en> Active: inactive (dead)

ts2phc.service - Synchronize PTP hardware clock (PHC) to external time stamp signal Loaded: loaded (/etc/systemd/system/ts2phc.service; disabled; preset: enabled) Active: inactive (dead)

phc2shm.service - Output samples of PTP hardware clock (PHC) to NTP-compatible shared memory segment Loaded: loaded (/etc/systemd/system/phc2shm.service; disabled; preset: enabled) Active: inactive (dead) raspberrypi systemd[1]: /etc/systemd/system/phc2shm.service:4: Failed to add dependency on ts2phc>

PTP client behavior

Today, I received additional CM4 and standard IO board. This is for PTP client to confirm if grandmaster does its role correctly or not from the standpoint of PTP client, hence there's no GNSS related stuff attached on IO board.

I followed https://github.com/jclark/rpi-cm4-ptp-guide/blob/main/time-config.md#ptp-client-with-ntp-on-cm4, and I see this log message in syslog.

interface 'eth0' does not support requested timestamping

Then, I created [email protected] file as instructed in the page along with two commands. But still I see the above log message in syslog.
Am I still missing something? And I don't see any meaningful status for PTP0 in the result of chronyc sources like this.
192168.1.7 is grandmaster which has been up and running.

root@ocs1:/home/kondou# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
#? PTP0 0 2 0 - +0ns[ +0ns] +/- 0ns
^- 2a01:b740:a20:3000::1f2 1 8 377 184 +4803us[+4803us] +/- 125ms
^- 2003:a:47f:abe4:48ba:cd4> 2 8 377 57 -757us[ -756us] +/- 138ms
^- ntp3.ds.network 3 8 377 189 +2549us[+2549us] +/- 43ms
^- ntp.no-sense.net 2 8 373 186 -2821us[-2821us] +/- 152ms
^* 192.168.1.7 1 4 377 2 -887ns[ -953ns] +/- 131us

I don't see any PTP related messages in syslog after ptp4l started while I can see many of them on a host which is doing grandmaster role.

And phc_ctl eth0 cmp does not show meaningful result...

root@ocs1:/home/kondou# phc_ctl eth0 cmp
phc_ctl[2884.113]: offset from CLOCK_REALTIME is 1679298645732591320ns

I don't replace any ptp4l stuff which can be obtained from sourceforge yet.

Document need to use `ptp_minor_version` in LinuxPTP v4

Fairly recently, LinuxPTP 4.0 launched, which broke due to the CM4's (apparently) broken PTP implementation.
It took me hours to realize this, and then even more to fix it.

In case anyone wants to run 4.0 on their CM4, here's the patch you need: https://github.com/FoxDenHome/ntpi/blob/main/input/src/linuxptp-minor-version-2-0.patch

(Essentially, a common theme with broken PTP hardware seems to be it enforcing a specific version on the packets while it SHOULD be tolerant to minor version changes, but isn't, so this changes the minor back to 0 allowing everything to function)

Can the GNSS module for PTP be used for data acquisition too?

I'm looking into implementing a grandmaster clock using the CM4 + IO Board + Ardusimple RTK2B (i.e. ublox F9P).

Because the CM4 has several UARTs, and the F9P has two, I was wondering if I can use the device to both feed the ptp server and also pull data from it, or if I need two devices.

TLDR

In particular, I'd need to run this ROS wrapper which accesses the serial port, takes raw measurements and sends them over the ROS network via TCP/IP.

The way the ROS wrapper is used normally, is to just plug the device to the computer via USB and the wrapper would take the data off the serial ttyACM0.

I'm trying to understand if there's a hardware way to use only one device for both applications (ptp grandmaster and ROS driver) without rewriting code, e.g. by modifying the driver to take data off a gpspipe as suggested here or using some interprocess communication like shared memory.

For example, I was wondering if the same serial could be accessed by both the ROS wrapper and gpsd or if there's a way to plug both UARTs from the FP9 to the raspberry Pi and use one for PTP and the other for the ROS wrapper.

Any ideas?

Driving GPIO when PTP frame is received.

Hi, I have question. Is there any way to drive some GPIO when PTP frame is received? Preferaly directly from BCM54210 eth phy. I assume that doing this in Kernel is not so hard ?
Best regards Karol

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.