Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a patch for PTP #103

Open
sunwell1994 opened this issue Jul 5, 2022 · 4 comments
Open

Add a patch for PTP #103

sunwell1994 opened this issue Jul 5, 2022 · 4 comments

Comments

@sunwell1994
Copy link

Hi, I have one question to add a patch to the kernel.
I am inspired by this raspberrypi example. https://github.com/twteamware/raspberrypi-ptp
We can patch the kernel to enable SOF_TIMESTAMPING_TX_SOFTWARE.

How to enable the SOF_TIMESTAMPING_TX_SOFTWARE in the usb drivers?
I can find the smsc95xx.ko file. It should be able to make the patch and enable the PTP over the USB.

@giuliomoro
Copy link
Contributor

giuliomoro commented Jul 5, 2022

on a Linux machine (or container), you should clone this repo https://github.com/RobertCNelson/ti-linux-kernel-dev/tree/ti-linux-xenomai-4.14.y and checkout the ti-linux-xenomai-4.14.y branch. Then you can use the build_deb.sh file to build a kernel. This will create some deb files in the deploy/ folder which you can then copy to your board and install. If you replace the .config file in the folder with this file, you will obtain a kernel that is the same as the one that is on Bela image ≥ v0.3.8.

According to this you need the following flags to be set in you config file:

CONFIG_NETWORK_PHY_TIMESTAMPING=y
CONFIG_PTP_1588_CLOCK=y

The second one is already enabled on the config file I linked above. You can add the first line to that file and then run build_deb.sh and get a kernel which has both flags set.

Not sure whether this achieves your result, but you can repeat the workflow above to change any flags you may need. Keep in mind that on the Pi3 there is an external USB-connected ethernet interface (which is what - I believe - the linked repo talks about), whereas the USB port on Bela uses the on-board USB phy with a Linux USB gadget driver to show up as a multi-function device on the host. This means that the smsc95xx file won't be relevant here and that overall the way it is achieved on Pi3 vs BB may be very different.

By the way, if you run ethtool -T eth0 on Bela to inspect the properties of the ethernet port's you will get that hw timestamping is supported:

Time stamping parameters for usb0:
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
Time stamping parameters for eth0:
Capabilities:
	hardware-transmit     (SOF_TIMESTAMPING_TX_HARDWARE)
	software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
	hardware-receive      (SOF_TIMESTAMPING_RX_HARDWARE)
	software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
	software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
	hardware-raw-clock    (SOF_TIMESTAMPING_RAW_HARDWARE)
PTP Hardware Clock: 0
Hardware Transmit Timestamp Modes:
	off                   (HWTSTAMP_TX_OFF)
	on                    (HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
	none                  (HWTSTAMP_FILTER_NONE)
	ptpv1-l4-event        (HWTSTAMP_FILTER_PTP_V1_L4_EVENT)
	ptpv2-event           (HWTSTAMP_FILTER_PTP_V2_EVENT)

so you already have that if it's relevant to your application.

@sunwell1994
Copy link
Author

sunwell1994 commented Jul 5, 2022

Thanks. My master board only has one eth port but it has two slaves. One slave only has eth while Bela board has the USB port. Let me follow your great instructions. But I have several questions.

  1. which config file should I replace
  2. Do I just need to install all deb in the deploy directory to the bela board to enable the config?

@giuliomoro
Copy link
Contributor

One slave only has eth while Bela board has the USB port.

So how would the USB port of Bela and the other two ethernet devices be on the same network, such that ptp synchronization can take place? Maybe what you need is an ethernet switch and have them all connected together via ethernet through the switch?

@sunwell1994
Copy link
Author

One slave only has eth while Bela board has the USB port.

So how would the USB port of Bela and the other two ethernet devices be on the same network, such that ptp synchronization can take place? Maybe what you need is an ethernet switch and have them all connected together via ethernet through the switch?

I prefer not to add a switch to the compact system. I hope to use the PTP of SW by the USB and the PTP of HW by the ethernet on the master clock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants