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

Hi @Pavel A.​ , Yes it is advised to use IT mode rather than polling mode for performance sake.

Some changes on the memory allocation have been done on projects in order to optimize footprint and grant bet possible performance. You can see these updates on GitHub projects.

Thanks a lot for your feedbacks.

Don't hesitate if you have more points or if my answers are not clear enough.

Hi @dradoicic​ , I removed from the document the information regarding NetXDuo because we are preparing a dedicated release soon with some modifications needed on the interface wrapper.

We'll try to provide the changes asap on GitHub, otherwise I will post the document containing NetXDuo changes guidelines.

Hi @Community member​ ,

STM32CubeH7 content is already available on GitHub (in what concerns ETH HAL updates) so you can get updates relative to HAL and to projects on these repos:

Otherwise, STM32CubeH7 will be available on st.com beginning of March 2022.

Thank you @MWB_CHa​!

Hi,

it would be really nice if you could provide some more information about the memory stuff (Rx/TxDescriptor placement, lwip heap and the corresponding MPU configuration).It would be very helpful if there are some hints on necessary adjustments if you change something of the examples, e.g. the lwip heap size.

Also there are compiler errors in the memory setup part of ethernetif.c if you change the compiler to the new Keil v6 Compiler (lwip mem pool setup region). For now i could not solve those problems without breaking the functionality. I get lwip assertions and hard fault during allocation.

Also why the memory is placed in SRAM1, the reference manual states SRAM3 as the place to use.

All this stuff is pretty unclear and i can't find any documentation about setting this up correctly. It's really hard to get started with ethernet on the H7 (broken driver, no documentation, no comments on configuration parts, keil projects only for old compiler, ...).

I really can't believe im the only one struggling with porting the ethernet functionality to a custom board. This is a nightmare!

I'm thankful for any help!

KHeig.1
Associate II

Hello,

I have ported the ETH driver as described.

short overview of my project and what i am using:

  • FreeRTOS
  • LwIP (raw API)
  • httpd
  • a webserver is running on STM32H7(httpd)
  • i want to transfer approx. 50MByte over POST

With the legacy ethernet driver the H7 was running into a RBU-Interrupt.

The rework seems to work better. I followed the migration guidline.

The low_level_input() seems to work.

But the low_level_output() is not working.

With a GET (http) everything works fine but when i try to POST something i stuck in the low_level_output() -> osSemaphoreAcquire(TxPktSemaphore,....). So the HAL_ETH_IRQHandler is not triggered. When i use the HAL_ETH_Transmit function it works better. But after a while a FIN ACK is sended.

I would be very grateful for any suggestions for solutions or ideas.

Thanks Korbi

I wanted very much to help reviewing and testing the new driver - but unfortunately swamped in other chores :(

One thing that certainly bugs me - new callbacks for descriptors and buffers allocation. This means more nested calls between user code and the driver, increased stack usage and potential of stack corruption (not to mention performance) - a big concern for embedded software.

Callback pointers in the ETH "handle" structure are in writable RAM - same concern.

Separation of the driver and higher/app/middleware level code could be more elegant and robust.

@MWB_CHa​ @alister​ @Piranha​ @ALABB​ 

When will this NetXDuo fix be available for the NUCLEO-H743ZI2 ?

Asantos
Senior

Hi Chekib Hammami,

The STM32CubeMX 6.5.0 with Ethernet HAL Driver reworked by ST was just released, but the X-CUBE-AZRTOS-H7 V2.0.0 is not compatible with it. When the compatible AZRTOS-H7 will be released?

MWB_CHa
ST Employee

Hello @Community member​ 

Actually, besides to STM32CubeMX 6.5.0, there is an important change done on H7 CubeFW which is the update of the ETH driver.

This update has impacts on both HAL and also the way STM32CubeMX generate the code relative to ETH.

This means of course that X-CUBE-AZRTOS-H7 NetXDuo loses compatibility with both on the release STM32CubeMX 6.5.0.

An update is planned in April for X-CUBE-AZRTOS-H7 to (among other things) align NetXDuo with

this major ETH update.

I'm updating this post soon with more details about how to update NetXDuo vs. new ETH HAL driver using GitHub code to provide clear explanation.

I hope this helps.