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.

[TM4C1294] - Tivaware & PTPD port

Other Parts Discussed in Thread: EK-LM3S8962

Hello all,

I am trying to port a ptpd example written for the stellaris ek-lm3s8962 (stellarisware) into tivaware.

Obviously the differences on how PTP1588 is implemented on the tiva processors these have to be reflected on the software as well. As one might guess most of the functions needed to port the example are available in the tivaware\utils for the EMAC.


I have a particular question for the implementation of ptpd function

Boolean adjFreq(Integer32 adj)

defined in:

C:\StellarisWare\third_party\ptpd-1rc1\src\dep-lmi\ptpd_servo.c

and implemented in:

C:\StellarisWare\boards\ek-lm3s8962\enet_ptpd\enet_ptpd.c

I am asking if this is to be replaced by the tivaware driver function:

EMACTimestampSysTimeUpdate().

Any info will be appreciated.

Regards,

Evros

  • Hello Evros,

    We have not tested the PTPD utility in TivaWare, so cannot advice much at this time. I will have to test it and it will take some time before I can come up with an answer.

    Thanks,
    Sai
  • Hello Sai,


    I will me diving into this very soon and from sudying the code and API/libraries it should be relatively painless, touch wood.


    I will ask another question which might help things a bit;

    In the stellaris the ptp functionality (basically the 63-bit timer) was emulated by a set of peripheral timers. In the tiva the ptp employs its own timers and procedures. So even abstractly; in the tiva all you have to do is implement the relevant code sections by using the driverlib for the EMAC (timestamp related) instead of altering the timer/ticks/systick like in the stellaris.


    Regards,

    Evros

  • Hello Evros,

    I will have to look into this example to answer your question. I am not sure if I can work on this example in time to answer your question. But I will try to reach out to other colleagues who might have worked on this library to get you some answers.

    Thanks,
    Sai
  • Hello Sai,

    I got it working but it needs debugging. I will probably put it on github or something when it gets to a certain point. Then I am sure a lot more debugging will take place as more people start looking into it.

    Keep this open if you think it will help or that you can come back with more info.

    The basic functionality that needs to be ported is easy to figure out once you spend some time on the code of all three; stellaris, ptpd, lwip. Then implement it on the Tiva framework.

    Regards,
    Evros
  • Hello Evros,

    This is great! Thanks for sharing the progress.

    I have come across this TI Design on PTP Transceiver. This TI Design does not have software, but I am taking to the person who did this TI Design if they can help.

    I will keep you posted. I think we should keep this thread open for now.

    Regards,

    Sai

  • Hello Sai,

    I will check it out. It is using the phyter chip which was one of my other options along with a hercules processor to go with it. The tiva won since it means one chip less on a smaller target board.

    In any case; the problem I am facing at the moment is the inability of the launchpads (I have two of them) to work with multicast addresses for the ptp (en.wikipedia.org/.../Precision_Time_Protocol. The way I got this to work (among other things) was to hardcode the each other's ip address into the other device. This manages to get them into sync but it is not desirable obviously. I have followed the ptpd call graph and state machine all the way down the the udp ports and it seems as if no multicast packet ever gets though. The EMAC filter is set to accept anything by the way.

    Evros

  • Hello Evros,

    Did you already try to enable IGMP option in lwipopts.h file?

    It might be a long shot, but I looked at the udp.c file in lwIP and looks like the multicast is handled, but only when LWIP_IGMP is set. As far as I understand, IGMP does not use UDP. In fact IGMP operates only on Network layer. So I am hoping that setting LWIP_IGMP in lwipopts.h file might enable multicast support for UDP.

    Hope this works!

    Thanks,
    Sai
  • Hello Sai,

    I got it working. The answer was somewhere in between.


    PTP uses multicast addresses but lwip-1.4.1 only uses multicast IP addresses for incoming packets only for when IGMP is enabled. The problem is that IGMP is not used for PTP so the necessary flags are not set in the packets.

    An easy way around is to modify the lwip-1.4.1\src\core\ipv4\ip.c file (line 412, if statement) to include the multicast address case.So in effect you have the following changes (basically an extra #if );

            if (           ip_addr_cmp(&current_iphdr_dest, &(netif->ip_addr))
                    ||     ip_addr_isbroadcast(&current_iphdr_dest, netif)
    #if    LWIP_PTPD
                    ||     ip_addr_ismulticast(&current_iphdr_dest)
    #endif /* LWIP_PTPD */
               )

    It is working fine now with multicast addresses. Probably some of the ported functions need tweaking to get right though.

    Evros

  • Hello Sai,

    I got a confirmed bug at lwip:

    savannah.nongnu.org/.../index.php

    I cannot see how ptpd could have worked with the Stellaris example with multicast addresses !!! It could not have worked with the proper PTP1588 domains or other multicast domains for that matter; since the bug exists in lwip-1.3.2 as well (shipped with stellarisware).

    Regards,
    Evros
  • Hello Evros,

    I am working on the PTP for Tivaware, too. Have you put your code on github? Would be nice if you could give me the link to it.

    Best regards
    Waldemar