How to define the frame size in FreeRTOS+TCP?

I am running FreeRTOS+TCP and I would like to decrease the MTU. Inside the stm32f4x7_eth_conf.h i find this: ~~~

define ETHRXBUFSIZE ETHMAXPACKETSIZE /* buffer size for receive */

~~~ ETH_MAX_PACKET_SIZE is defined in stm32f4x7_eth.h to 1536. Further more in FreeRTOSIPConfig.h i found this: ~~~

define ipconfigNETWORK_MTU 1500

~~~ What is the difference between ETH_RX_BUF_SIZE and ipconfigNETWORK_MTU? Where should I reduce the frame size?

How to define the frame size in FreeRTOS+TCP?

I am running FreeRTOS+TCP and I would like to decrease the MTU.
When you are running low on RAM, it is indeed a good idea to decrease MTU. But please make sure that the peripheral knows that you can not handle packets longer than a certain MTU. The MTU does not include the size of the Ethernet header, which is 14 bytes long. So an MTU 0f 1000 bytes will need 1000+14 = 1014 bytes. Sometimes the peripheral will also write a 4-byte Frame Check Sequence into the DMA buffer, so that would make it 1018 bytes. Here is a very clear picture of a complete Ethernet packet.
ETHMAXPACKETSIZE is defined in stm32f4x7eth.h to 1536.
The size of ‘1536’ is favourite because it is super well aligned: it is divisible by 32. Which is important when the DMA buffers are cached. A cache line is often 32 bytes long.
Further more in FreeRTOSIPConfig.h i found this: #define ipconfigNETWORK_MTU 1500
Normally 1500 is the maximum MTU on a LAN. There is a possibility to send Jumbo packets, which may become much longer. Generally, on the Internet, the supported MTU is only 1400 bytes. FreeRTOS+TCP will decrease the MSS (Maximum Segment Size) when the peer is located on the Internet.
What is the difference between ETHRXBUFSIZE and ipconfigNETWORKMTU?
That should be clear by now: MTU is the nett packet size, without the Ethernet header and FCS. ETH_RX_BUF_SIZE is used to define the size of the DMA buffers.
Where should I reduce the frame size?
So in 3 places:
  • Adapt ipconfigNETWORK_MTU
  • Adapt ETH_MAX_PACKET_SIZE
  • Inform the peripheral about the maximum Maximum transmission unit

How to define the frame size in FreeRTOS+TCP?

Hello Hein! Great to hear from you and thank you for your advices and explanations! I going to test this out, soon!