Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions stm32cube/stm32h5xx/README
Original file line number Diff line number Diff line change
Expand Up @@ -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,
erwango marked this conversation as resolved.
Show resolved Hide resolved
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
erwango marked this conversation as resolved.
Show resolved Hide resolved

See release_note.html from STM32Cube
27 changes: 18 additions & 9 deletions stm32cube/stm32h5xx/drivers/src/stm32h5xx_hal_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand All @@ -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 */
Expand Down
Loading