How to communicate with PTP linux PC? Topic is solved

New to XMOS and XCore? Get started here.
etori90
Active Member
Posts: 34
Joined: Thu Sep 05, 2019 6:49 am

How to communicate with PTP linux PC?

Post by etori90 »

I downloaded PTP_server in TSN example on explorer 200 and connected with PTP linux PC.
But Xmos only send path_delay msg by perodic function ... can not process any received PTP msg..

So i thought like this

1. receiving port problem -> i tested for udp and http example and it works well
2. mac filter -> i found PTP msg filter is added in ptp_init function
3. using lwip -> I'm trying...



in main code:

on tile[1]: rgmii_ethernet_mac(i_eth_rx_lp, NUM_ETH_RX_LP_CLIENTS,
i_eth_tx_lp, NUM_ETH_TX_LP_CLIENTS,
c_eth_rx_hp, c_eth_tx_hp,
c_rgmii_cfg,
rgmii_ports,
ETHERNET_DISABLE_SHAPER);

on tile[1].core[0]: rgmii_ethernet_mac_config(i_eth_cfg, NUM_ETH_CFG_CLIENTS, c_rgmii_cfg);

on tile[1].core[0]: rtl8211f_phy_driver(i_smi, i_eth_cfg[MAC_CFG_TO_PHY_DRIVER]); <- I used another phy chip

on tile[0]: ptp_server(i_eth_rx_lp[MAC_TO_MEDIA_CLOCK_PTP],
i_eth_tx_lp[MEDIA_CLOCK_PTP_TO_MAC],
i_eth_cfg[MAC_CFG_TO_MEDIA_CLOCK_PTP],
c_ptp, NUM_PTP_CHANS, PTP_GRANDMASTER_CAPABLE);


void ptp_server(client interface ethernet_rx_if i_eth_rx,
client interface ethernet_tx_if i_eth_tx,
client interface ethernet_cfg_if i_eth_cfg,
chanend ptp_clients[], int num_clients,
enum ptp_server_type server_type)
{
timer ptp_timer;
int ptp_timeout;
ptp_server_init(i_eth_cfg, i_eth_rx, ptp_clients[0], server_type, ptp_timer, ptp_timeout);

while (1) {
select
{
case i_eth_rx.packet_ready():
printf("ptp_ptacket_ready");
ptp_recv_and_process_packet(i_eth_rx, i_eth_tx); <- can't enter function ... is this i_eth_rx.packet_ready problem? then, mac problem?
break; \
case (int i=0;i<num_clients;i++) ptp_process_client_request(ptp_clients, ptp_timer):
break;
case ptp_timer when timerafter(ptp_timeout) :> void:
ptp_periodic(i_eth_tx, ptp_timeout);
ptp_timeout += PTP_PERIODIC_TIME;
break;
}
}
}

I don't know what is the problem for this exam help me...................................pls
View Solution
nick
Active Member
Posts: 42
Joined: Tue Jan 07, 2020 10:35 am

Post by nick »

Hi,
I'm interested in this application too.
As I understand there are two functions: ptp_server and gptp_media_clock_server (used by the AVB application note). The latter can be used to tune the master clock on the xmos board.
I tried to use both of them without any success.
Let me know if you did something new.
User avatar
akp
XCore Expert
Posts: 580
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Do you have a project that builds, I might be able to take a look. I have a fair amount of experience with gptp. Just to make sure, you have GPTP running on the linux machine?
etori90
Active Member
Posts: 34
Joined: Thu Sep 05, 2019 6:49 am

Post by etori90 »

I found this is layer problem so I set linux ptp to send L2 layer message ( sudo ptp4l -2 -P -i enterface -m)
first linux ptp send ptp message by two types
Both types have different destination address types , so you should add mac filter at ptp_server init function.

1. LLDP 0x01,0x80, 0xc2, 0x0, 0x0, 0xe ---sync. announce
2. IEEE....something 0x01,0x1b,0x19,0x00,0x00,0x00 ----peer to peer message(pdelay request, pdelay resposnse)

To enter the message processing function, we need to modify some conditions.

1.PTP_NEIGHBOR_PROP_DELAY_THRESH_NS
2.GET_PTP_TRANSPORT_SPECIFIC
3.PTP_DEFAULT_DEST_ADDR

at ptp_recv function .....at this line -> ptp_port_info[src_port].delay_info.pdelay <= PTP_NEIGHBOR_PROP_DELAY_THRESH_NS
I modified PTP_NEIGHBOR_PROP_DELAY_THRESH_NS get more higher value then it works well
I think it's important to enter set_ascapable function

PTP_TRANSPORT_SPECIFIC field maybe zero value at linux ptp for default but in xmos ptp this value should be 1 to process message.
i don't know how to configure linux ptp so i changed xmos source code.

PTP_DEFAULT_DEST_ADDR needs two type of destination address above. LLDP and IEEE something
sync or announce uses LLDP and peer-to peer message use second mac address
you don't need this configuration to communicate between xmos boards. but to process ptp packet at linux pc then you will need this.

so i checked both pps signals
ah one more !
if you trying this between Xmos boards each boards should have unique source mac address

1. my_port_id.data
2. sourceportidentity
3. source_port_id

check this at ptp_init or other function..

now i 'm solving a new problem

xrun: Cannot load image, XCore 0 is not enabled

after uploading at flash memory this phenomenon appears.
do you know how to solve this.

I'm getting crazy
etori90
Active Member
Posts: 34
Joined: Thu Sep 05, 2019 6:49 am

Post by etori90 »

how I can show you my project? I'm using default configuration at linux ptp not gptp configuration..
etori90
Active Member
Posts: 34
Joined: Thu Sep 05, 2019 6:49 am

Post by etori90 »

akp wrote: Wed Jul 22, 2020 5:24 pm Do you have a project that builds, I might be able to take a look. I have a fair amount of experience with gptp. Just to make sure, you have GPTP running on the linux machine?
how I can show you my project? I'm using default configuration at linux ptp not gptp configuration..
etori90
Active Member
Posts: 34
Joined: Thu Sep 05, 2019 6:49 am

Post by etori90 »

nick wrote: Tue Jul 21, 2020 7:47 am Hi,
I'm interested in this application too.
As I understand there are two functions: ptp_server and gptp_media_clock_server (used by the AVB application note). The latter can be used to tune the master clock on the xmos board.
I tried to use both of them without any success.
Let me know if you did something new.
I didn't use media server only ptp_server and gpio output function
nick
Active Member
Posts: 42
Joined: Tue Jan 07, 2020 10:35 am

Post by nick »

Hi etori90,
I'm trying to connect an XMOS board to a PC running a virtual machine with Ubuntu.
In the XMOS code, I modified what you said, but I'm missing something.

In the main I call the ptp_server() task.

I noticed this sequence:
- ptp_init() calls ptp_reset() for each port and I see printed on screen "PTP Port 0 Role: Master" (because of the reset)
- in ptp_recv_and_process_packet(), when the link goes up, another reset is called
- in ptp_recv(), it goes in the case PTP_ANNOUNCE_MESG when it receives an announce message from linux. But here the function bmca_update_roles() it is not called because asCapable is always 0.

I think that the only way to set asCapable is to call set_ascapable() in the case PTP_PDELAY_RESP_FOLLOW_UP_MESG. But it never goes in this case.

I also tried to capture packets with wireshark and I didn't see any announce message from the XMOS, but only the announce messages from linux.

What am I missing?
Thank you
nick
Active Member
Posts: 42
Joined: Tue Jan 07, 2020 10:35 am

Post by nick »

UPDATE

The problem was in two parts of the code:
1) in addition to add a mac address filter for 01:1B:19:00:00:00 you should add instructions to send announce, sync and follow up messages to this address. 802.1AS sends every message to 01:80:C2:00:00:0E but IEEE1588 sends only pdelay messages to this address.
2) in addition to change the condition of "if (GET_PTP_TRANSPORT_SPECIFIC(msg) != 0)" to 0 (and not to 1) you should also change the macro #define PTP_TRANSPORT_SPECIFIC_HDR (0x0 << 4) in order to use the correct field in the header (802.1AS uses 1 but IEEE1588 uses 0)

I have another question: as I understand IEEE1588 is used to synchronize two systems clocks. gPTP gives a method to recovery a media clock from an AVB stream.
Supposing I only want to use PTP to synchronize system clocks of two systems, I'm wondering in what way is done in the XMOS code.
I found where the media clock is output to the PLL as a reference clock but I don't find where the system clock is tuned (if this is what is done).

Thank you
User avatar
akp
XCore Expert
Posts: 580
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

The XMOS reference design doesn't recover the media clock directly from the PTP clock. It does it indirectly I suppose by synchronizing the media clock to the input stream (which is itself timestamped with PTP clock).