twteamware / raspberrypi-ptp

How to run IEEE-1588 on RaspberryPi hardware
78 stars 23 forks source link

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

Open lineker10 opened 5 years ago

lineker10 commented 5 years ago

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.

fortrieb commented 5 years ago

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.

lineker10 commented 5 years ago

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

mikebrady commented 4 years ago

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:~ $ 
lineker10 commented 4 years ago

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

yobertyosua commented 4 years ago

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 commented 3 years ago

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 commented 3 years ago

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

gizero commented 3 years ago

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

yobertyosua commented 3 years ago

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

michael-gosselin commented 1 year ago

there is a Kernel 5.x at Raspberry Pi kernel repository (https://github.com/raspberrypi/linux/tree/rpi-5.3.y)

@fortrieb thanks for this, super helpful. Does it have to be kernel 5.3.y ? I tried this with a newer kernel (5.15.y) and it didn't work:

$ sudo ethtool -T eth0

gives:

Time stamping parameters for eth0:
Capabilities:
    software-transmit
    software-receive
    software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none

I also notice that ptp4l is not running after I boot:

$ sudo systemctl status ptp4l

gives,

Unit ptp4l.service could not be found.

I am using a raspberry pi 4B.

fortrieb commented 1 year ago

Hi @michael-gosselin, i didn't try a newer kernel then 5.3.y.

Grisly00 commented 1 year ago

@michael-gosselin Similarly I am using a new Kernel (5.15.0-1024-raspi) with a RPI4 and I have the exact same issue as you with ethtool not showing support and ptp4l.service not found. Did you manage to find a workaround? According to the readme (https://github.com/twteamware/raspberrypi-ptp#enable-software-timestamping-in-ptp4l-configuration) it should be enough to enable software support.