cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX Ethernet Rx Buffer Over Allocation

ADunc.1
Senior

Using STM32CubeMX 6.14.0 with H7 package 1.12.1.

When Ethernet is set up with number of RX descriptors set to 16, the default LWIP ethernet driver rx buffer pool overflows.

 

ADunc1_1-1744241328464.pngADunc1_2-1744241358572.png

This is caused by during startup, HAL_ETH_Start_IT calls ETH_UpdateDescriptor.  This allocates all 16 rx descriptors to a slot in the rx pool.  Entirely consuming the pool.

Upon first packet receive, via ethernet_input, low_level_input, EHAL_ETH_ReadData, ETH_UpdateDescriptor is called to allocate 1 more descriptor.  This allocation fails.

Some time later a descriptor is freed, next received packet, a descriptor can be allocated.  Every second received packet fails allocation.

This behavior should either be prevented by the driver code, or a warning generated in STM32CubeMX that it wont work.

It appears setting ETH_RX_BUFFER_CNT to 17, is enough to alleviate the issue.  My buffers are all 1568 bytes so can fit a full ethernet packet, so each receive fits in a packet.  But for smaller sizes, a receive spanning multiple descriptors could require more additional buffers.

 

2 REPLIES 2
Ghofrane GSOURI
ST Employee

Hello @ADunc.1 

I would appreciate it if you could provide your IOC.

THX

Ghofrane 

ADunc.1
Senior

IOC file attached...

Having one additional RX Buffer is not enough.  After more testing, I still get the occasional allocation failure.  Two seems to be OK, but is not ideal being so borderline.