cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 LWIP cache bug + fix

Sven Almgren
Associate
Posted on March 26, 2018 at 12:54

I have a Nucleo-H743ZI board that I'm running some ethernet code on, that I based on the LWIP example applications. The problem was that I could only ping it once on every reset. The problem went away when I disabled the cache, which lead me to an issue withlow_level_output.

As the memory is configured as cachable and the TX buffers now live in regular user memory the dcache must be flushed before calling

HAL_ETH_Transmit

, so my solution is to call

SCB_CleanDCache_by_Addr

for every entry put into the Txbuffer:

static err_t low_level_output(struct netif *netif, struct pbuf *p)
{
 uint32_t i=0, framelen = 0;
 struct pbuf *q;
 err_t errval = ERR_OK;
 ETH_BufferTypeDef Txbuffer[ETH_TX_DESC_CNT];
 
 memset(Txbuffer, 0 , 4*sizeof(ETH_BufferTypeDef));
 for(q = p; q != NULL; q = q->next)
 {
 if(i >= ETH_TX_DESC_CNT)
 return ERR_IF;
 
 Txbuffer[i].buffer = q->payload;
 Txbuffer[i].len = q->len;
 framelen += q->len;
 
 SCB_CleanDCache_by_Addr((uint32_t *)q->payload, q->len);
 if(i>0)
 {
 Txbuffer[i-1].next = &Txbuffer[i];
 }
 
 i++;
 }
 TxConfig.Length = framelen;
 TxConfig.TxBuffer = Txbuffer;
 HAL_ETH_Transmit(&EthHandle, &TxConfig, 0);
 
 return errval;
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

#dcache #lwip #dma #stm32h7 #bug-report
3 REPLIES 3
Sven Almgren
Associate
Posted on April 04, 2018 at 09:24

This only fixed part of the problem =/

Asantos
Senior
Posted on April 05, 2018 at 14:51

Hi Sven.

I didn't know that the STM32H7 has a cache bug. I thought I just had to worry about putting the LwIP application running on the AXI-SRAM.

Ari.

Jeremi Wójcicki
Associate II
Posted on April 17, 2018 at 16:22

Great job on spotting it! I'm tired working with Ethernet drivers provided by ST, there are always some bugs, even in sample code. Please fix it ST. I am trying to port my code from F7 to H7 which uses ethernet and I face difficulties. I started to work with the LWIP_HTTP_Server_Netconn_RTOS to check if ethernet works at all at this thing and applying your patch make the DHCP operational. After choosing static IP in the example I can't connect to the board anymore nor ping it. Anybody had the same problem? Or even better, a solution?