Giter Site home page Giter Site logo

epagris / flexptp-tmc41294 Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 2.0 63 KB

Flexible, lightweight slave-only, measurement profile IEEE 1588 PTP clock synchronization implementation for network enabled MCUs.

License: MIT License

C 96.93% Batchfile 3.07%
ptp ieee1588 launchpad mcu tm4c1294 ethernet tiva-c

flexptp-tmc41294's Introduction

flexPTP

Flexible, low-resource IEEE1588 PTP slave-only implementation designed for MCU-based systems [implemented on TI TM4C1294 Connected LaunchPad]

Prerequests

In order to compile the CCS project found in this repository the following tools are required:

  • TI Code Composer Studio 9.3.0.00012 or higher,
  • TI TivaWare peripheral library (this package can be aquired through CCS),
  • Some modification of vendor provided drivers and files (see below).

To run the project you will need:

  • a TI Connected LaunchPad,
  • a network featuring a master clock.

Binary image

If you don't want to compile the project for yourself, a precompiled binary can be downloaded from Releases.

Serial console

The project is equipped with a moderately interactive command line interface accessible through the virtual serial port (e.g. /dev/ttyACMx on Linux) emulated by the development board. Serial port configuration: 115200-8-N-1.

After the device and software has come up, type ? to print help, a list of terminal commands. Some commands will only be available if the Ethernet network is connected.

Sample command list:

? 	 Print this help
ptp servo params [Kp Kd] 			Set or query K_p and K_d servo parameters
ptp reset 			Reset PTP subsystem
ptp servo offset [offset_ns] 			Set or query clock offset
ptp log {def|corr} {on|off} 			Turn on or off logging

Usage

To try it out, just connect the Connected LaunchPad to a live Ethernet network being connected to a master clock. After the node has established connection to the network logs and servo settings are acessible through CLI. 1PPS output is accessible on pin PG0.

Project modules

The project is buit up from multiple modules, the following are designed to be easy to replace or modify:

  • servo: implementing the clock servo
  • hw_port: containing setup functions for specific timestamp hardware

Instructions on how to replace the current modules can be found in ptp.h.

Network driver modifications

Original netif driver (located in third_party/lwip-1.4.1/ports/netif/tiva-tm4c129.c) has been modified so that trasmitted packets being timestamped and timestamps being written back into pbufs.

Enabling TX timestamping in tivaif_transmit(...)

...

pDesc->Desc.ui32CtrlStatus |= (DES0_TX_CTRL_IP_ALL_CKHSUMS | DES0_TX_CTRL_CHAINED);
#if LWIP_PTPD
  pDesc->Desc.ui32CtrlStatus |= (1 << 25); // set TTSS flag
#endif
/* Decrement our descriptor counter, move on to the next buffer in the
* pbuf chain. */
ui32NumChained--;
pBuf = pBuf->next;

...

Enabling timestamp writeback in tivaif_process_transmit(...)

...

tDescriptorList *pDescList;
uint32_t ui32NumDescs;
#if LWIP_PTPD
    struct pbuf * pPBuf;
    struct tEMACDMADescriptor * pDesc;
#endif
...
/* Yes - free it if it's not marked as an intermediate pbuf */
        if(!((uint32_t)(pDescList->pDescriptors[pDescList->ui32Read].pBuf) & 1))
        {
            pbuf_free(pDescList->pDescriptors[pDescList->ui32Read].pBuf);
            DRIVER_STATS_INC(TXBufFreedCount);
        }
#if LWIP_PTPD
        pPBuf = pDescList->pDescriptors[pDescList->ui32Read].pBuf;
        pDesc = &pDescList->pDescriptors[pDescList->ui32Read].Desc;
        
        // Write timestamp back
        pPBuf->time_s = pDesc->ui32IEEE1588TimeHi;
        pPBuf->time_ns = pDesc->ui32IEEE1588TimeLo;
#endif
        pDescList->pDescriptors[pDescList->ui32Read].pBuf = NULL;

        ...

Another modification has been made to enbale multicast message transmission and reception:

(line 328:)

psNetif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP <b>| NETIF_FLAG_IGMP</b>;

UARTprintf modification

To enable task switching while waiting for new data to arrive on serial port, insert some (OS managed) delay into UARTgets(...) in uartstdio.c

...

//
// Process characters until a newline is received.
//
while(1)
{
    //
    // Read the next character from the receive buffer.
    //
    vTaskDelay(pdMS_TO_TICKS(10));
    if(!RX_BUFFER_EMPTY)
    {

...

flexptp-tmc41294's People

Contributors

epagris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flexptp-tmc41294's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.