cancel
Showing results for 
Search instead for 
Did you mean: 

Hello! May be it is wrong ethernet DMA tail calculation?

AAshc
Associate

In ethernet HAL driver stm32h7xx_hal_eth.c function void ETH_DMARxDescListInit include row: " WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc + (((uint32_t)(ETH_RX_DESC_CNT - 1))*sizeof(ETH_DMADescTypeDef)))));"

This code adding value to heth->Init.RxDesc. But, RxDesc is pointer to 32bit and added shift is multiplicated for 4.

Correct row must be:

" WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc) + ((uint32_t)(ETH_RX_DESC_CNT - 1))*sizeof(ETH_DMADescTypeDef)));"

14 REPLIES 14

Where is the place to report bugs in CubeMX ​and CubeIDE?

No Github repository for STM32CubeMX & STM32CubeIDE.

Use following Community spaces to report bugs:

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

@AAshc​  Thank you for finding this bug.

Piranha
Chief II

By the way, here is the respective code line from H7 HAL v1.3.0:

WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)heth->Init.RxDesc + ((ETH_RX_DESC_CNT - 1)*sizeof(ETH_DMADescTypeDef))));

It's essentially the same as the OP's version. It relied on C operator precedence, but it was correct! Until some brainless code monkey "fixed" it by adding braces in wrong places...

LCE
Principal

I'm just changing my non-HAL ethernet driver from F7 to H7 - oh my, it is so different.

At start, why not set the tail pointer directly to the last descriptor's address?

ETH->DMACRDTPR = (uint32_t)&DMARxDscrTab[ETH_RX_DESC_CNT - 1];

But maybe I have not yet fully understood the tail pointer.

Thankfully I found this thread with @alister​ 's explanation.

https://community.st.com/s/question/0D53W00000EGsnUSAT/how-does-ethernet-rx-descriptor-wrapping-work-on-stm32h7