This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[TM4C + H/W Timestamp problem] - lwip + ptpd

Other Parts Discussed in Thread: TM4C129ENCPDT, TM4C1294NCPDT

Hello all,


After a great deal of effort, I manged to get 3 devices to synchronise using ptpd+lwip.

What I have found out today is that hardware timestamping does not work despite being enabled:

1) the ptp functionality is enabled in the EMAC, i.e., the 64-bit time registers (sec/nsec) are updated just fine

2) the fine adjustment works as it should, i.e., the slaves' PPS signals are as close as 100ns.

3) The master is offset by as much as 1ms from the slaves.

4) After tests to resolve this issue I concluded that there has to be an issue with the timestamps' timing.

After experimenting I found out that the hardware unit is not doing any hardware timestamping! The relevant dma/buf descriptor control bit is set when the packet is to be handled. If I disable software timestamping from the ptpd part then the packets come out without any timestamps; i.e., when examined with wireshark the timestamps are constant, i.e., do not change and the protocol does not work. However if I do software timestamping then it works to the degree mentioned above.

Any ideas are welcome.

Evrps

  • Hello Evros,

    I have asked the concerned engineer to look into it.

    Did you do a search of the Forum? In Jan-Feb 2016 time frame there was another post on the same on the forum, where the user got it to work but was having an issue with the readout stability.

    Regards
    Amit
  • Hello Amit,

    Are you talking about this one:

    e2e.ti.com/.../481631

    If yes then the OP had a different issue. The 64-bit timers (ptp time) is working fine, that I have tested and it works, actually that is where the software timestamping gets the timestamps.

    The issue I have is that the EMAC does not timestamp the outgoing frames. By reading the datasheet and driverlib this is what I understand; that the h/w is responsible for timestamping; have a look here on page 1425

    www.ti.com/.../tm4c1294ncpdt.pdf

    Thanks for the quick response. I have another post open with Stellaris Sai in which he still hasn't responded about other issues in the T.I ports of the lwip. The bug I reported in the lwip tracker got accepted, and this bug was present since the stellarisware. I am guessing ptp has been problematic since then, but in those processors, the timestamping was being handled in a different way.

    Regards,
    Evros
  • The tiva4c ports for lwip and ptpd needs to be rectified in many places.

    The changes are more than a few to get it to work with the tm4c. The datasheet also needs to be updated to make more clear what the device is able to do, especially with the abundance of solutions out there.

    This is all I can report for now.

    Evros

  • Hello Evros,

    Just to clarify, what you are saying is that the TM4C port for ptpd in the folder "/third_party/ptpd-1.1.0/src" is not enabling the hardware to do the hardware timestamp?

    Thanks,
    Sai
  • Hi Evros,

    I'm just about to dig into enabling PTPd on my TM4C129ENCPDT project, and have read your posts with great interest.

    Would you mind sharing the code that you got working so far? I'll be happy to share any progress or insights that I make with you (and thre rest of E2E).

    Regards,
    Simon
  • Hi Simon,

    I have been meaning to update this post but I am in the middle of something at work and at home so not had the time really. I am not even sure what I am allowed to share because some of this code is proprietary and some is open source. For the open-source code I have no problem. The rest is modifications/rectifications to the T.I code which despite being free, it is not open source.


    The basics:


    1) The driver provided with lwip (in the ports/netif directory) needs support for the descriptors/dma to do the timestamp. Then  wait until the descriptor is free'd from the dma and read the timestamp.This is for outgoing frames. For incoming frames some modification is also required.

    2)  At the same level the driver has to be modified to pass the timestamp up the stack to be included in the followup message (two-step clock).

    3) Ptpd as included in the stellaris example is only a one step clock and it pretty much works in software mode. You will only be able to take it down to 1-3 ms between master-slave and 500 ns between slaves.

    4) From there, the relevant functions (udp) need to be modified to pass the timestamp to the applciation level, i.e., if you send a ptp message you will know its timestamp and then put it in the followup message. T.I mention 1588 timestamping but the datasheet is very obscure and lacks  lot of information. Parts of it for 1588 have been copied/pasted from an intel datasheet (moderators are you reading this ?).

    5) Modification at the driver level to accept multicast messages (lwip). I got a confirmed bug report on this on lwip bug tracker and a confirmed fix.

    6) Modification at the application layer (ptpd) to the statemachine to be able to send followup messages without having to enable igmp or loopback. PTPD v1 works this way.

    7)  Implement the ptpd gettime/settime/rand funtions using the tiva driver library. This is sort of the easy bit as you just use wrappers for tiva drl functions.

    8) If you want to use binary rollover mode instead of digital rollover mode (i.e., different control on the pps signal) you need to change the submicrosecond increase register when initialising in the tiva lwip port.

    9) I have both ptpd v1 and ptpd v2 working with the rough guidelines above.


    This is all I can remember from the top of my head at the moment.


    Hopefully be back with more.

    Regards,

    Evros

  • Hi Evros,

    Thank you very much for the guide. Awesome work! As you mentioned in a previous post, there a quite a few changes that need to made to the tiva4c ports of LwIP and ptpd to get PTP working with TivaWare.

    Maybe Sai or Amit can say if TI has plans to implement these changes and release a working PTPd code example for Tivaware like the example that exists for Stellarisware? Perhaps with a future release of the Tivaware package?

    Best regards,
    Simon
  • Hi Simon,

    There are changes to be made in the ptpd_net.c in the ptpd dependencies folder.


    The issue is with pbuf_realloc function not being able to reallocate pbuf memory properly. When sending out general/event messages the relevan buffer needs to be freed and then allocated as when trying to send a message smaller than the one previously sent the pbuf_realloc function returns an error and the message (for example a followup message 60 octets in v1 could not be sent after a sync message, 134 octets).

    Evros

  • Hi ,I working on using TM4C1294NCPDT for IEEE 1588.Do you have any sample code???Thank you so much

  • Hi all,

    I also need any example code or working code to get the HW timestamp working with Tiva.

    Thanks

  • Hi, Evros:

    Could you contribute your change back to TI so they can release it in the next Tivaware release?
  • Hi Evripidis,

    Can you post the link to the final project folder or the example code for getting the ptp implementation working in TIVA?

    Thanks