UDP packet drop on STM32H7, HAL_ETH_Transmit problem!!
Hi
I have a customized stm32h750 board, my work is to read data from SD memory of board and send through UDP to a client PC.I use stm32cubeMX v5.6.1,STM32H7 MCU package v1.7 and LWIP cubeMX supported v2.0.3. when I send small size files everything is OK and I get the same data and file on PC,but for bigger size files(in MByte size and over) the data I get on PC is less than sent and clearly some packets are dropped.for example in sending of 26Mbyte data I receive 21Mbyte .
I tried to debug the code,first thing I checked was reading from SD by fatfs function f_read,it was OK. The second thing I checked was udp_send function that seems to be the reason.it returns no error,but When I add time delay(in few miliseconds range) before udp_send in my for loop, the problem goes away.but if I send a bigger size data I need to increase delay time. For example it must be 30 ms for a 26Mbyte data file.I read many posts in community about bug fix (specially from Alister and Piranha)in STM32H7 ethernet,I think I have correct MPU config and it seems other bugs are fixed in v.1.7 package. But I think also there is a problem with HAL_ETH_Transmit function that use a polling mode to send Ethernet data.
Has anyone similar experience? Would anyone give me a hint or solution to fix this problem.
Below is a piece of my code related to UDP send, also necessary files for review of set parameters in cube are attached.
Dcache and Icache,are enabled, but I also tested the code by disabling them,and again failed.
Phy = DP83848.
BYTE SD_read_buffer[8192]; /* File copy buffer */
Chunk of server_rec function:
if(data_read[0]=='9')
{
HAL_Delay(2000);
f_open(&SDFile, "REC_26MB.DAT", FA_READ); //640kb file
for (;;)
{
f_read(&SDFile, SD_read_buffer, sizeof SD_read_buffer, &br); // Read a chunk of data from the source file
if (br == 0) break; // error or eof
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_8,GPIO_PIN_SET);
server_send(upcb);
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_8,GPIO_PIN_RESET);
HAL_Delay(10);
}
f_close(&SDFile);
Server_send function:
void server_send(struct udp_pcb *upcb)
{
struct pbuf *sb;
err_t err;
/* allocate pbuf from RAM*/
sb = pbuf_alloc(PBUF_TRANSPORT,sizeof SD_read_buffer, PBUF_RAM);
memcpy(sb->payload,SD_read_buffer,sizeof SD_read_buffer);
err=udp_send(upcb, sb);
pbuf_free(sb);
}
this got me crazy and i can't debug it, please help me.
