cancel
Showing results for 
Search instead for 
Did you mean: 

LwIP sendto() is not sending the data in the buffer passed to it

ttatakis
Associate III

I have a H745 Nucleo board running LwIP. I have implemented a simple udp echo server. I receive all of the data for the udp messages being sent to the board but the data I am sending back never makes it out on the wire (verified with Wireshark). I have stepped all the way down to HAL_ETH_Transmit() and everything looks fine at that point. The correct number of bytes get transmitted, just the wrong data (mostly zeros).

I'm assuming this is a memory/cache/dma configuration issue but I can not seem to locate the problem. I've tried doubling the task stack size but that did not help. I've also been through numerous HowTo's including this one: https://community.st.com/s/article/How-to-create-project-for-STM32H7-with-Ethernet-and-LwIP-stack-working

Any help is appreciated. My entire project is attached, including the ioc for CubeMX. All the relevant code is in main.c: functions myudpInit() and mydupEcho().

2 REPLIES 2
TDK
Guru

Disable data cache and try it. If that solves it, you are likely not handling cache appropriately. Clean before sending, invalidate before reading. Buffers must be cache aligned.

If you feel a post has answered your question, please click "Accept as Solution".

> invalidate before reading

Invalidating before reading is too late. It has to be invalidated before starting the reception - therefore before passing it to DMA. The reason is cache eviction, which can happen at any time.

https://community.st.com/s/question/0D53W00000oXSzySAG/different-cache-behavior-between-stm32h7-and-stm32f7

https://community.st.com/s/question/0D50X0000C9hGoz/weird-cache-writeback-behavior-for-stm32f7508