Commit 89ef0a33 authored by Marc Desvaux's avatar Marc Desvaux Committed by Erwan Gouriou
Browse files

stm32cube: stm32h5: ethernet: PTP clock doesn’t works

fix to the HAL_API_V2 to get PTP to work
In the HAL_ETH_ReadData function where it checks for the
last descriptor, I added a checked if the TSA bit was set
in DESC1
If the TSA bit is set then have a peak at the context
descriptor which should be the one after the last
descriptor
If the CTXT bit is set in the context descriptor then
extract the timestamps

update README to fix to the V2 HAL API to get PTP to work

Signed-off-by: default avatarblackhelicopters <mm@blackhelicopters.net>
Signed-off-by: default avatarMarc Desvaux <marc.desvaux-ext@st.com>
parent d466dc84
Loading
Loading
Loading
Loading
+9 −0
Changes for stm32cube/stm32h5xx/README: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -54,4 +54,13 @@ Patch List:
       drivers/include/stm32h5xx_ll_spi.h
      ST internal bug : 147754

 *fix to the V2 HAL API to get PTP to work
     impacted file : stm32h5xx_hal_eth.c
     In the HAL_ETH_ReadData function where it checks for the last descriptor, 
     we added a checked if the TSA bit was set in DESC1
     If the TSA bit is set then have a peak at the context descriptor which should be the one 
     after the last descriptor
     If the CTXT bit is set in the context descriptor then extract the timestamps
     ST internal bug : 161504

   See release_note.html from STM32Cube
+18 −9
Changes for stm32cube/stm32h5xx/drivers/src/stm32h5xx_hal_eth.c: 18 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -1036,8 +1036,8 @@ HAL_StatusTypeDef HAL_ETH_Transmit_IT(ETH_HandleTypeDef *heth, ETH_TxPacketConfi
  */
HAL_StatusTypeDef HAL_ETH_ReadData(ETH_HandleTypeDef *heth, void **pAppBuff)
{
  uint32_t descidx;
  ETH_DMADescTypeDef *dmarxdesc;
  uint32_t descidx, descidx_temp;
  ETH_DMADescTypeDef *dmarxdesc, *dmarxdesc_temp;
  uint32_t desccnt = 0U;
  uint32_t desccntmax;
  uint32_t bufflength;
@@ -1063,13 +1063,6 @@ HAL_StatusTypeDef HAL_ETH_ReadData(ETH_HandleTypeDef *heth, void **pAppBuff)
  while ((READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_OWN) == (uint32_t)RESET) && (desccnt < desccntmax)
         && (rxdataready == 0U))
  {
    if (READ_BIT(dmarxdesc->DESC3,  ETH_DMARXNDESCWBF_CTXT)  != (uint32_t)RESET)
    {
      /* Get timestamp high */
      heth->RxDescList.TimeStamp.TimeStampHigh = dmarxdesc->DESC1;
      /* Get timestamp low */
      heth->RxDescList.TimeStamp.TimeStampLow  = dmarxdesc->DESC0;
    }
    if ((READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_FD) != (uint32_t)RESET) || (heth->RxDescList.pRxStart != NULL))
    {
      /* Check if first descriptor */
@@ -1090,6 +1083,22 @@ HAL_StatusTypeDef HAL_ETH_ReadData(ETH_HandleTypeDef *heth, void **pAppBuff)

        /* Packet ready */
        rxdataready = 1;

        if (READ_BIT(dmarxdesc->DESC1, ETH_DMARXNDESCWBF_TSA) != (uint32_t)RESET)
        {
          descidx_temp = descidx;
          INCR_RX_DESC_INDEX(descidx_temp, 1U);

          dmarxdesc_temp = (ETH_DMADescTypeDef *)heth->RxDescList.RxDesc[descidx_temp];

          if (READ_BIT(dmarxdesc_temp->DESC3, ETH_DMARXNDESCWBF_CTXT) != (uint32_t)RESET)
          {
            /* Get timestamp high */
            heth->RxDescList.TimeStamp.TimeStampHigh = dmarxdesc_temp->DESC1;
            /* Get timestamp low */
            heth->RxDescList.TimeStamp.TimeStampLow  = dmarxdesc_temp->DESC0;
          }
        }
      }

      /* Link data */