-
Notifications
You must be signed in to change notification settings - Fork 318
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
Bug in ETH_DMARxDescListInit - reported in the forum #7
Comments
- Reported in official repo: STMicroelectronics#7
Hi Pavel, Thank you for having reported this point. It will be transmitted to our development teams. We will be back to you as soon as they provide us with a feedback. Thank you once more. With regards, |
Thank you Ali. Kudos for finding this issue go to ashchepkov581 (on the forum). |
Hi Pavel, Our development teams confirmed this issue. A fix will be implemented and published in the frame of a future release. Thank you again for your contribution. With regards, |
ST Internal Reference: 76913 |
Still not fixed in v. 1.6.0
|
- Reported in official repo: STMicroelectronics#7 (cherry picked from my H7_1.5.0
Hi Pavel, This bug is intended to be fixed in the frame of package v1.7.0 release (or a later one). With regards, |
Hi Pavel, The fix of this issue will not be part of the v1.7.0 pacakge which will be published soon but part of a later one. In the meanwhile, here is how the erroneous line will be updated: -WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc + (((uint32_t)(ETH_RX_DESC_CNT - 1))*sizeof(ETH_DMADescTypeDef)))));
+WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc) + ((uint32_t)(ETH_RX_DESC_CNT - 1)))); We hope this helps and we thank you once more for your contribution. With regards, |
Ali, could they review it again, please? Per the docum (RM0433 page 2889) ETH_DMACRXDTPR indicated location of the last RX descriptor. I understand this as it contains address of the last descriptor, that is (base addr) + sizeof (one descr) * (number of desc. -1) |
Hi Pavel, I had a look to the ETH_DMADescTypeDef structure type and I think I understand better your point. Would you confirm please before I loop back with our development teams? Thanks. Below is the definition of the ETH_DMADescTypeDef structre type: STM32CubeH7/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth.h Lines 57 to 65 in 79196b0
Now, And here is the point:
Rules of pointer arithmetic require rather the following:
Correct implementation would then be: -WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc + (((uint32_t)(ETH_RX_DESC_CNT - 1))*sizeof(ETH_DMADescTypeDef)))));
+WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc) + (((uint32_t)(ETH_RX_DESC_CNT - 1)) * (uint32_t)(sizeof(ETH_DMADescTypeDef) / sizeof(uint32_t))))); With regards, |
Ali, sorry for delay. So now there are two "correct" variants. (I assume that red line with - is wrong and green line with + is proposed correction). I'm confused.... where is pointer arithmetic in Regards, |
I think @ALABSTM is right. The correct calculation should be (uint32_t)(heth->Init.RxDesc) + offset_bytes I meet this issue and debug for half of day. I can't believe this bug is not fixed for this long time. |
Hi Pavel, Pointer arithmetic arrives on the scene because structure member
Hence, as RxDesc points on a ETH_DMADescTypeDef structure, expression (uint32_t)(heth->Init.RxDesc + (uint32_t)1) , for instance, will be automatically reevaluated @firstRxDesc + sizeof(ETH_DMADescTypeDef) .
To conclude, first fix suggestion is the correct one as confirmed by @kele14x. -WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc + (((uint32_t)(ETH_RX_DESC_CNT - 1))*sizeof(ETH_DMADescTypeDef)))));
+WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc) + ((uint32_t)(ETH_RX_DESC_CNT - 1)))); The above expression (in green) will be automatically reevaluated I hope this makes things clearer. Please do not hesitate if you still have questions about the suggested fix. With regards, |
Ali, @kele14x, with all respect it seems there's some misunderstanding. However, as @alister commented on the forum, it looks like there are multiple variants of setting this register, depending on the overall design of the driver. If the person who proposed the correction will provide also a thorough fix of the ETH driver, he/she likely knows better. If such fix won't be provided, this issue alone is not important. Regards, |
Hi Pavel, I confirm there is a misunderstanding and a typo (from my side) too. In the expression I reported of the suggested fix, parenthesis are not correctly placed. With such an expression, pointer arithmetic applies no more. You are absolutely right about it. The fix would rather be: -WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc + (((uint32_t)(ETH_RX_DESC_CNT - 1))*sizeof(ETH_DMADescTypeDef)))));
+WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc + (uint32_t)(ETH_RX_DESC_CNT - 1)))); I hope you agree on what is written here. I do apologize for the confusion caused. With regards, |
Ali, no problem, thanks for checking. The bigger question now is, how about a deeper revision of the eth driver? When this could be expected?
|
Hello Guys /* Set Transmit Descriptor Tail pointer / Please let me know if there is any difference in TX and RX descriptors. I am not expert on this Ethernet HAL handling on stm32h7. Thanks |
To make the code's intention clearer, I would suggest WRITE_REG(heth->Instance->DMACRDTPR, (uint32_t)(&heth->Init.RxDesc[ETH_RX_DESC_CNT - 1])); Much clearer, and doesn't require knowledge of pointer arithmetic rules. |
1. May be it is wrong ethernet DMA tail calculation? https://community.st.com/s/question/0D50X0000Bea7dNSQQ/hellomay-be-it-is-wrong-ethernet-dma-tail-calculation 2. Bug in ETH_DMARxDescListInit - reported in the forum zephyrproject-rtos#7 STMicroelectronics/STM32CubeH7#7
This driver is being tested to use Ethernet on H7. F7 and H7 have a slightly different register configuration. The first goal was the occurrence of the receive interrupt function HAL_ETH_RxCpltCallback(). However, it is not currently working properly. The register of the PHY chip is read normally. Because it is a test source, the source is dirty. There may be a bug when using H7 Ethernet. 1. Bug in ETH_DMARxDescListInit - reported in the forum :STMicroelectronics/STM32CubeH7#7 2. [bug fixes] STM32H7 Ethernet :https://community.st.com/s/question/0D50X0000C6eNNSSQ2/bug-fixes-stm32h7-ethernet?t=1581554010199&searchQuery= 3. FAQ: Ethernet not working on STM32H7x3 :https://community.st.com/s/article/FAQ-Ethernet-not-working-on-STM32H7x3
Please see description and fix here:
https://community.st.com/s/question/0D50X0000Bea7dNSQQ/hellomay-be-it-is-wrong-ethernet-dma-tail-calculation
In STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_eth.c, line 2704
The text was updated successfully, but these errors were encountered: