cancel
Showing results for 
Search instead for 
Did you mean: 

Ethernet HAL Driver reworked by ST and available in 22Q1 (preview now available on GitHub)

MWB_CHa
ST Employee

Multiple feedbacks reported around Ethernet HAL driver and applications on STM32Cube FW have been acknowledged and analyzed. Many of them were related to RX packets management, to DMA management, or to overall performance. A summary list of tickets on GitHub and forum is provided below for reference.

We apologize for the time it took to provide an adapted solution. We are changing support model to provide more dynamic updates in the future (mainly leveraging GitHub mechanisms).

Today, based on the received feedbacks, the Ethernet HAL driver has been reworked to fix most known issues, enhance performance, and add some missing features.

The reworked Ethernet HAL driver (along with updated applications) is being deployed on STM32CubeH7, STM32CubeF4 and STM32CubeF7 FW packages.

Official publication dates are aligned with maintenance dates: 22Q1 for STM32H7 and STM32F4, and 22Q2 for STM32F7.

Before the official publication: the reworked Ethernet HAL driver and applications are shared on GitHub (https://github.com/STMicroelectronics/stm32h7xx_hal_driver/pull/16) in the form of a pull request, available for everyone for use and review. Feedbacks, comments, enhancements, and proposals are more than welcome.

After the official publication: more frequent updates are planned and will be anticipated on GitHub.

The reworked Ethernet HAL driver brings multiple changes and a compatibility break vs. legacy Ethernet HAL driver. Main changes are listed here:

  • Add support for PTP and ARP.
  • Rework packets reception and buffers allocation for a better integration and performance.
  • Rework packets transmission and buffers allocation (using Interrupts instead of polling and prevent packets lock during transmission).
  • Enhance DMA management.
  • Decouple Ethernet HAL driver from PHY driver.
  • Enhance maximum throughput in RX (94Mbs) and TX (92Mbs).
  • Enhance footprint (new driver size is 6% less than legacy driver).
  • Full integration with LwIP (with and without FreeRTOS) and NetXDuo with ThreadX.
  • Rework applications for STM32CubeH7 FW, STM32CubeF4 FW and STM32CubeF7 FW to align with new Ethernet HAL driver.
  • MISRA-C 2012, code coverage analysis, static code analysis and robustness validation added.

The new Ethernet HAL driver is supported by STM32CubeMX release of 22Q1 on STM32H7 and STM32F4. Support on STM32F7 follow in 22Q2.

Since the new Ethernet HAL driver brings a compatibility break, existing projects using it shall be updated accordingly. A step-by-step guide for how to update existing projects is shared in this forum and soon in a dedicated Wiki page. A pull request on STM32H7 CubeFW LwIP projects is also provided here to show how modifications are done.

Also, users with existing projects, who don’t want or need to move to the new Ethernet HAL driver can keep their projects running by pointing to legacy driver that will be available in a dedicated folder in future STM32Cube FW packages.

We warmly thank community contributors, and especially @alister​ and @Piranha​ who did a great job synthesizing encountered issues and feedbacks. We keep looking for your feedbacks to continue enhancing and adapting for your needs.

General FAQ :

  • Is new Ethernet HAL driver compatible with legacy driver?
    • New driver is not compatible with the legacy driver.
  • Is it mandatory to switch to new Ethernet HAL driver?
    • In order to benefit from better performance and reliability, it is preferred to switch to the new driver. But it is also possible to keep legacy driver that will still be available in STM32Cube FW packages.
  • Are all existing projects in STM32Cube FW package updated to use the new Ethernet HAL driver ?
    • All LwIP projects on STM32H7, STM32F4 and STM32F7 STM32Cube FW packages are updated.
    • Other projects using Ethernet HAL driver like demos or mbedTLS are kept using legacy driver.
  • Shall I expect issues with STM32CubeMX when generating code for ETH HAL ?
    • Yes, STM32CubeMX 6.5.0 and newer support the new architecture of the ETH HAL and so do not generate the legacy structures. It means a project generated with that version will not be compatible with legacy ETH HAL.
    • Specifically on X-CUBE-AZRTOS-H7, X-CUBE-AZRTOS-F7 and X-CUBE-AZRTOS-F4, it is not possible to use STM32CubeMX 6.5.0 for ETH without a compatibility break. An updated version for each package is being released to align them with new ETH HAL driver.

Detailed List of tickets:

Here below a list of main ticket that have been taken into consideration and fixed in the new Ethernet HAL driver and applications. Some of them come from community (very well summarized in a single post), some others are logged on GitHub, and others were logged on internal bug tracking system (the items without hyperlink):

81088 [ETH] RM0433 v6 faults and missing details on ETHERNET related sections 

100608 [ETH]: Need to add new fields in the ETH_TxDescListTypeDef

79181 [STM32H7] ETH Ingress correction register

75481 Ticket 75481 - Ethernet PPS functionality clarification

62100 ARPEN support in Ethernet Driver

79615 Ethernet: Enable and handle the DMA

67970 Read Buffer Underflow interrupt

91624 SCB_InvalidateDCache_by_Addr alignment in ethernetif.c

97885 Question about CMSIS EMAC driver

100109 [HAL_ETH] By default MMC interrupt is not handled

83608 LWiP Interrupt and Through Put is Low

81685 [MW_LwIP] Can't ping device with mDNS feature

81312 Length value issue in HAL_ETH_GetReceivedFrame_IT

41452 MBED / Ethernet: inconsistent transmission issue

74243 Add LWIP examples for DISCO-H747I

48259 [ETH] Support of PTP feature in the driver

101731 [LwIP/ETH/MSP][ExamplesMX] Missing initialization to 0 for most local variables of

67276 Several bugs in ethernetif.c: giving back Rx descriptor to DMA before packet was processing by LWIP

91976 LWIP HAL project race condition

91624 SCB_InvalidateDCache_by_Addr alignment in ethernetif.c

108075 Ethernet not working with high AHB/APB2 divider

62100 ARPEN support in Ethernet Driver

67970 Ethernet: Enable and handle the DMA Read Buffer Underflow interrupt

104729 [GitHub] Wrong HSE_VALUE in NUCLEO-H743ZI LwIP_HTTP_Server_Netconn_RTOS application

101385 [ETH] Same issue as ticket 40298 but in STM32CubeH7 v1.8.0

101620 Support of MW_AzureRTOS and associated applications

63844 [LwIP License update] Update the Licenses (in readme and source files)

106013 [ETH] Ping max buffer size

108010 Ethernet HAL workaround against Ping Flood issue

108675 Ethernet erroneous data received in RMII configuration

108674 Ethernet erroneous data received in RMII configuration

108670 Ethernet erroneous data received in RMII configuration

Forum https://community.st.com/s/question/0D50X0000C6eNNSSQ2/bug-fixes-stm32h7-ethernetNetIPAnalysis.docx (including multiple forum tickets)

GitHub https://github.com/STMicroelectronics/cmsis_device_f7/pull/1

GitHub https://github.com/ARMmbed/mbed-os/issues/12459

GitHub https://github.com/STMicroelectronics/stm32h7xx_hal_driver/issues/8

GitHub https://github.com/STMicroelectronics/STM32CubeF4/issues/60

49 REPLIES 49
ASade.2
Associate

Hi,

I wonder if there is any reworked version for stm32f7 out yet?

I came across a problem with the ethernet in which during a large data output some packets don't get sent completely and when I analyze the network with Wireshark I see that it shows the following error.

[Expert Info (Error/Protocol): IPv4 total length exceeds packet length (xxxx bytes)]

The problem changes when I turn on the debug. I believe it's related to cache and memory but I wasn't able to fix this by changing the characteristics of MPU or placing buffers in different memory area.

Thanks

MHama.3
Associate II

Hello @MWB_CHa​ 

I am using Lwip without Rtos, and i am facing the same problem that @Piranha​ had. The fix you applied is just for Lwip with RTOS but this bug is still not fixed for Lwip without rtos.

My Problem is when I ping to the stm32, only 50% or 25% ping succeeds.

I am working with a team and we are all connected over a switch and if some one sends every 0.01 sec a packet of 32 Byte, then my board will be busy receiving this packts and then ignore it, but my Ping will be lost and i cant communicate with my board, Can you tell me if you will investigating this problem??

PHolt.1
Senior III

Is there anything in this new ETH driver which is applicable to a polled interface in ethernetif.c ?

The key functions are low_level_output() low_level_input() and then in the HAL stuff one has HAL_ETH_TransmitFrame() and HAL_ETH_GetReceivedFrame(). There is also low_level_init().

Maybe I am not familiar with the structure of Github but I found loads of examples of the above HAL_ETH_ functions online (github and elsewhere) from the 2020+ timeframe and all of them are identical to what I have.

debugging
Senior III

Many thanks for continous improvements, some questions:

  1. Any impact for the model. or type of PHY used?
  2. How about the ethernet driver for other platform such as the STM32F2(07) ? Any changes expected ?
Pavel A.
Evangelist III

https://github.com/stm32-hotspot/STM32H7-LwIP-Examples

Another spin of STM32H7 ETH examples. For STM32CubeH7 package version 1.10.0 and newer.

fancyrat
Associate III

Hi,

The function HAL_ETH_DescAssignMemory() doesn't exist anymore, what to do in its case?

Thanks!

Hi,

In the new dynamic implementation, the descriptor's update is done in the driver through the callback HAL_ETH_RxAllocateCallback called in the ETH_UpdateDescriptor function.

So there's some changes to do in the applicative code (ethernetif.c) :

  • Delete Rx_Buff variable
  • Define the callback : void HAL_ETH_RxAllocateCallback(uint8_t **buff)

Regards

Mahdy

ALisk.1
Associate II

Shoddy code and shoddy instructions on how to use it.

Thanks.

PHolt.1
Senior III

"Shoddy code and shoddy instructions on how to use it."

Been struggling with this for 2 years now. Nearly finished, thank god. And I agree with you 100%. A $14BN company should do so much better. They should support their silicon; they charge plenty of money for it. Instead, we get these "customer forums" where 1 or 2 people post some bits and pieces, sometimes nicely and sometimes rudely, answers are mostly never done and when they are done they are done after weeks...

In the meantime, Espressif deliver a ready to eat package which is all integrated and works out of the box. You just have the "chinese political risk" .

Indeed. You would think that if they can't ship any hardware these days, they would at least ship some code. Even one person working on these issues would make more progress than what they are providing now.

Why is it that folks can be so rude on this form? I've noticed that too.

Pent up anger with ST?