This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PTP (IEEE 1588) on STM32F7: looks like ethernet MAC driver's code has never been tested yet?

Hi!
I'm trying to use the PTP time synchronization protocol on MCU STM32F746G. Ethernet MAC driver's source code (file "EMAC_STM32F7xxx.c", revision V1.2, 15. October 2015) has the ability of using PTP. When I enable PTP support like this

/* IEEE 1588 time stamping enable (PTP) */
#ifndef EMAC_TIME_STAMP
#define EMAC_TIME_STAMP         1
#endif

and try to compile the project, I see a couple of errors due to incorrect descriptor names (rx_desc, tx_desc):

static int32_t GetRxFrameTime (ARM_ETH_MAC_TIME *time) {
#if (EMAC_TIME_STAMP)
//  RX_Desc *rxd = &rx_desc[Emac.rx_index];
  RX_Desc *rxd = &Desc.rx[Emac.rx_index];

  if ((Emac.flags & EMAC_FLAG_POWER) == 0U) {
    return ARM_DRIVER_ERROR;
  }

  if (rxd->Stat & DMA_RX_OWN) {
    /* Owned by DMA */
    return ARM_DRIVER_ERROR_BUSY;
  }
  time->ns  = rxd->TimeLo;
  time->sec = rxd->TimeHi;

  return ARM_DRIVER_OK;
#else
  return ARM_DRIVER_ERROR;
#endif
}
static int32_t GetTxFrameTime (ARM_ETH_MAC_TIME *time) {
#if (EMAC_TIME_STAMP)
//  TX_Desc *txd = &tx_desc[Emac.tx_ts_index];
  TX_Desc *txd = &Desc.tx[Emac.tx_ts_index];

  if ((Emac.flags & EMAC_FLAG_POWER) == 0U) {
    return ARM_DRIVER_ERROR;
  }

  if (txd->CtrlStat & DMA_RX_OWN) {
    /* Owned by DMA */
    return ARM_DRIVER_ERROR_BUSY;
  }
  if ((txd->CtrlStat & DMA_TX_TTSS) == 0) {
    /* No transmit time stamp available */
    return ARM_DRIVER_ERROR;
  }
  time->ns  = txd->TimeLo;
  time->sec = txd->TimeHi;
  return ARM_DRIVER_OK;
#else
  return ARM_DRIVER_ERROR;
#endif
}

Looks like after some changes to the code the PTP part hasn't been corrected and tested. Ok, I correct the descriptor names. But if such an error exists, I cannot be sure that the driver's code works OK!

Has anyone tried to run PTP synchronization protocol? Does anyone have examples of how to use it?

Thanks in advance.