raspberrypi-ptp icon indicating copy to clipboard operation
raspberrypi-ptp copied to clipboard

How to implement Precision Time Protocol (PTP) on Rpi4?

Open lineker10 opened this issue 4 years ago • 12 comments

I used Precision Time Protocol (PTP)/IEEE-1588 on Raspberry pi3b+ by linuxptp refereed this site. Recently, I upgraded to Raspberry pi 4 and I try to use PTP on Raspberry pi 4. Unfortunately, I cannot use it on raspberry pi 4. Because, I don't see SOF_TIMESTAMPING_TX_SOFTWARE listed. If anybody knows the solution of it, please answer my problem.

lineker10 avatar Oct 01 '19 00:10 lineker10

Hi @lineker10 ,

there is a Kernel 5.x at Raspberry Pi kernel repository (https://github.com/raspberrypi/linux/tree/rpi-5.3.y). I get PTP working on Raspberry Pi 4 with this kernel and following official documentation on compiling custom kernel (https://www.raspberrypi.org/documentation/linux/kernel/building.md).

Adding mentioned configuration option here after make bcm2711_defconfig and continue compiling.

fortrieb avatar Oct 18 '19 13:10 fortrieb

Hi @fortrieb Thank you very much. I will try your advice.

lineker10 avatar Nov 13 '19 00:11 lineker10

Thanks @lineker10. I was able to get software timestamping on the ethernet port with your hint.

pi@raspberryPi4B:~ $ uname -a
Linux raspberryPi4B 5.3.18-v7l+ #1 SMP Wed Jan 8 09:57:24 GMT 2020 armv7l GNU/Linux
pi@raspberryPi4B:~ $ sudo ethtool -T eth0
Time stamping parameters for eth0:
Capabilities:
	software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
	software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
	software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
pi@raspberryPi4B:~ $ sudo ethtool -T wlan0
Time stamping parameters for wlan0:
Capabilities:
	software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
	software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
pi@raspberryPi4B:~ $ 

mikebrady avatar Jan 09 '20 18:01 mikebrady

Thank you @mikebrady I try to run by your help...

lineker10 avatar Jan 14 '20 01:01 lineker10

Hi @lineker10 ,

there is a Kernel 5.x at Raspberry Pi kernel repository (https://github.com/raspberrypi/linux/tree/rpi-5.3.y). I get PTP working on Raspberry Pi 4 with this kernel and following official documentation on compiling custom kernel (https://www.raspberrypi.org/documentation/linux/kernel/building.md).

Adding mentioned configuration option here after make bcm2711_defconfig and continue compiling.

Hey, i did your guidance and actually i was able to get software timestamping on ethernet port. But, when i tried to use ptp4 -i eth0 -m -S, it didn't work.

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.4.77-v7l+ #1 SMP Thu Nov 19 20:28:48 CET 2020 armv7l GNU/Linux
pi@raspberrypi:~ $ ethtool -T eth0
Time stamping parameters for eth0:
Capabilities:
	software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
	software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
	software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none


pi@raspberrypi:~ $ ptp4l -i eth0 -m -S
ptp4l[1874.772]: failed to set the clock status: Operation not permitted
ptp4l[1874.773]: failed to adjust the clock: Operation not permitted
ptp4l[1874.774]: bind failed: Permission denied
ptp4l[1874.774]: port 1: INITIALIZING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
ptp4l[1874.774]: uds: bind failed: Permission denied
ptp4l[1874.775]: port 0: INITIALIZING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)

Any hint about it? Thanks before

yobertyosua avatar Nov 20 '20 11:11 yobertyosua

Hi @lineker10 , there is a Kernel 5.x at Raspberry Pi kernel repository (https://github.com/raspberrypi/linux/tree/rpi-5.3.y). I get PTP working on Raspberry Pi 4 with this kernel and following official documentation on compiling custom kernel (https://www.raspberrypi.org/documentation/linux/kernel/building.md). Adding mentioned configuration option here after make bcm2711_defconfig and continue compiling.

Hey, i did your guidance and actually i was able to get software timestamping on ethernet port. But, when i tried to use ptp4 -i eth0 -m -S, it didn't work.

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.4.77-v7l+ #1 SMP Thu Nov 19 20:28:48 CET 2020 armv7l GNU/Linux
pi@raspberrypi:~ $ ethtool -T eth0
Time stamping parameters for eth0:
Capabilities:
	software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
	software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
	software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none


pi@raspberrypi:~ $ ptp4l -i eth0 -m -S
ptp4l[1874.772]: failed to set the clock status: Operation not permitted
ptp4l[1874.773]: failed to adjust the clock: Operation not permitted
ptp4l[1874.774]: bind failed: Permission denied
ptp4l[1874.774]: port 1: INITIALIZING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
ptp4l[1874.774]: uds: bind failed: Permission denied
ptp4l[1874.775]: port 0: INITIALIZING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)

Any hint about it? Thanks before

i did something wrong. i should be root

yobertyosua avatar Nov 20 '20 13:11 yobertyosua

I have a question again. I wanna try to install PTP on my RaspPi 4, but for another Kernel (4.19.y-rt). I did the step https://github.com/twteamware/raspberrypi-ptp for the current Kernel and it works. But if I try to do the same steps but into Kernel 4.19.y-rt, it didnt work. Is PTP not support Kernel 4.19.y-rt?

Thanks before

yobertyosua avatar Jan 18 '21 13:01 yobertyosua

What exactly "didn't work"? where did you get your kernel 4.19.y-rt from?

gizero avatar Jan 19 '21 09:01 gizero

Thanks for the response. So, here are what i got:

where did you get your kernel 4.19.y-rt from?

I got it from https://github.com/raspberrypi/linux/tree/rpi-4.19.y-rt. I typed git clone https://github.com/raspberrypi/linux.git -b rpi-4.19.y-rt on my terminal to get the kernel 4.19.y.rt. Here is the picture of my actual kernel: kernel

What exactly "didn't work"?

SOF_TIMESTAMPING_TX_SOFTWARE is missing after i rebooted the kernel 4.19.y-rt. I noticed it after i checked it using ethtool -T eth0

missing tx

Correct me if I'm wrong. I think the answer is https://github.com/twteamware/raspberrypi-ptp/blob/master/kernel-patching.md. And I should patch https://github.com/twteamware/raspberrypi-ptp/blob/master/patches/0001-smsc95xx-use-generic-ethtool_op_get_ts_info-callback.patch using patch Should I put that patch file in the same folder, where my linux kernel is?

Actually I dont understand how to patch. I just did this: patch Can you please help me to understand it? I already read https://github.com/twteamware/raspberrypi-ptp/issues/3, but it still doesnt help me to understand, how to patch it.

Sorry if I ask too much

yobertyosua avatar Jan 19 '21 10:01 yobertyosua