cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743 ETH Problem with RT Thread and LWIP

ketlen
Associate

Hi,I created the STM32H743 project based on RT Thread and LWIP, only open ICache, if I modify the content of a function, it will lead to the Ethernet transmission success, but there is no data on the MII interface, debugging compared the ETH register under normal communication and the ETH register under abnormal condition. The configuration is the same; Dynamically allocated memory is placed on 0x24000000, and Ethernet descriptors and received data are placed on 0x30040000.
In the above case, through multiple tests, it was found that increasing the size of the function block can restore the sending of ETH to normal, such as adding multiple __nop instructions.
Why this is the case, and what to look out for if you want to open only ICahe or DCache.

static err_t low_level_output(struct netif *netif, struct pbuf *p)
{
	uint32_t i=0;
        struct pbuf *q;
	err_t errval = ERR_OK;
	static ETH_BufferTypeDef Txbuffer[ETH_TX_DESC_CNT];
	memset(Txbuffer, 0 , ETH_TX_DESC_CNT*sizeof(ETH_BufferTypeDef));

	for(q = p; q != NULL; q = q->next)
	{
		if(i >= ETH_TX_DESC_CNT)
		  return ERR_IF;
        rt_memcpy(Tx_Buff[i],q->payload,q->len);
		Txbuffer[i].buffer = Tx_Buff[i];
		Txbuffer[i].len = q->len;

		if(i>0)
		{
		  Txbuffer[i-1].next = &Txbuffer[i];
		}

		if(q->next == NULL)
		{
		  Txbuffer[i].next = NULL;
		}

		i++;
	}

	TxConfig.Length =  p->tot_len;
	TxConfig.TxBuffer = Txbuffer;
	HAL_ETH_Transmit_IT(&heth, &TxConfig);
	return errval;
}

The above code is LWIP call ETH send.

uint16_t DW3000GetPOA(dwt_sts_mode_e sts_mode)
{
    uint16_t poa_value = 0;
    dwt_rxdiag_t poa_rx_diag;
    dwt_readdiagnostics(&poa_rx_diag);
    if(sts_mode == DWT_STS_MODE_OFF)
    {
        poa_value = poa_rx_diag.ipatovPOA;
    }
    else if((sts_mode & 0x0f) == DWT_STS_MODE_1)
    {
        poa_value = poa_rx_diag.stsPOA;
    }
    else if((sts_mode & 0x0f) == DWT_STS_MODE_2)
    {
        poa_value = poa_rx_diag.sts2POA;
    }    
    else
    {
        poa_value = poa_rx_diag.ipatovPOA;
    }   
//    if((poa_value&0x2000) != 0)    
//    {
//        poa_value |= 0xc000;
//    }  

    return poa_value;
}

The above is the function that causes an Ethernet exception.

 

1 REPLY 1
Pavel A.
Super User

What is dwt_readdiagnostics() ? Does it tinker with the Cortex-M DWT?