2025-04-08 11:36 PM - last edited on 2025-04-09 1:19 AM by Andrew Neil
Moved from MPUs forum: STM32H7 is an MCU - not an MPU.
I configured a new project for STM32H745XIH3 with ETH & Lwip
Linker file section related to lwip
.lwip_sec (NOLOAD) : {
. = ABSOLUTE(0x30000000);
*(.RxDecripSection)
. = ABSOLUTE(0x30000080);
*(.TxDecripSection)
. = ABSOLUTE(0x30000100);
*(.Rx_PoolSection)
} >RAM_D2
main file
/* USER CODE BEGIN WHILE */
while (1) {
ethernetif_input(&gnetif2);
sys_check_timeouts();
// MX_LWIP_Process();
HAL_Delay(100);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
I replaced LAN8742 with DP83848 wherever it is required,
DP83848_RegisterBusIO(&DP83848, &DP83848_IOCtx);
/* Initialize the DP83848 ETH PHY */
DP83848_Init(&DP83848);
if (hal_eth_init_status == HAL_OK)
{
/* Get link state */
ethernet_link_check_state(netif);
}
else
{
Error_Handler();
}
#if 0
/* USER CODE END PHY_PRE_CONFIG */
/* Set PHY IO functions */
LAN8742_RegisterBusIO(&LAN8742, &LAN8742_IOCtx);
/* Initialize the LAN8742 ETH PHY */
if(LAN8742_Init(&LAN8742) != LAN8742_STATUS_OK)
{
netif_set_link_down(netif);
netif_set_down(netif);
return;
}
if (hal_eth_init_status == HAL_OK)
{
/* Get link state */
ethernet_link_check_state(netif);
}
else
{
Error_Handler();
}
#endif /* LWIP_ARP || LWIP_ETHERNET */
void ethernet_link_check_state(struct netif *netif)
{
ETH_MACConfigTypeDef MACConf = {0};
int32_t PHYLinkState = 0;
uint32_t linkchanged = 0U, speed = 0U, duplex = 0U;
PHYLinkState = DP83848_GetLinkState(&DP83848);
if(netif_is_link_up(netif) && (PHYLinkState <= DP83848_STATUS_LINK_DOWN))
{
HAL_ETH_Stop(&heth);
netif_set_down(netif);
netif_set_link_down(netif);
}
else if(!netif_is_link_up(netif) && (PHYLinkState > DP83848_STATUS_LINK_DOWN))
{
switch (PHYLinkState)
{
case DP83848_STATUS_100MBITS_FULLDUPLEX:
duplex = ETH_FULLDUPLEX_MODE;
speed = ETH_SPEED_100M;
linkchanged = 1;
break;
case DP83848_STATUS_100MBITS_HALFDUPLEX:
duplex = ETH_HALFDUPLEX_MODE;
speed = ETH_SPEED_100M;
linkchanged = 1;
break;
case DP83848_STATUS_10MBITS_FULLDUPLEX:
duplex = ETH_FULLDUPLEX_MODE;
speed = ETH_SPEED_10M;
linkchanged = 1;
break;
case DP83848_STATUS_10MBITS_HALFDUPLEX:
duplex = ETH_HALFDUPLEX_MODE;
speed = ETH_SPEED_10M;
linkchanged = 1;
break;
default:
break;
}
if(linkchanged)
{
/* Get MAC Config MAC */
HAL_ETH_GetMACConfig(&heth, &MACConf);
MACConf.DuplexMode = duplex;
MACConf.Speed = speed;
HAL_ETH_SetMACConfig(&heth, &MACConf);
HAL_ETH_Start(&heth);
netif_set_up(netif);
netif_set_link_up(netif);
}
}
}
I am unable to ping my board; the code is error-free. And I am clueless where to monitor.
2025-04-09 1:20 AM
Welcome to the forum.
For best results, please see How to write your question to maximize your chances to find a solution.
In particular: How to insert source code.
2025-04-09 3:41 AM
Before attempting to generate a new project, please start from one of ready pre-configured examples.
This has chances for success.
2025-04-09 5:31 AM
Ok, Could you share if there is any example for STM32H745 Ethernet Project
2025-04-09 6:10 AM
Did you look ?
eg,
https://community.st.com/t5/stm32-mcus/stm32h7-configuration-tips-and-tricks/ta-p/49352
https://community.st.com/t5/stm32-mcus/ethernet-not-working-on-stm32h7x3/ta-p/49479
etc, etc, ...
2025-04-09 6:24 AM
Thanks for the articles. I tried the first one; it seems not to be working for me.
I will explain in detail what I have done till now:
1. I'm using STM32H745 without RTOS
2. Initially I tried a custom board in which I have a DP83848 interface. Later I switched to STM32H745-DISCO development board for basic ETH configuration to get started.
3. I configured as they said in articles and tutorials
RxDesc: 0x30000000
TXDesc: 0x30000080
RxBuffer: 0x30000100
LWIP Heap: 0x30002000
MPU Config:
Before this, I tried what they said in the article also.
------------------------------------------------
I am always observing either "request timed out" or "host unreachable."
2025-04-09 6:29 AM
@Chandra_sekhar wrote:I am always observing either "request timed out" or "host unreachable."
How & where are you observing them?
Hav eyou used Wireshark (or similar) to see what's actually happening on the wire?
2025-04-09 6:32 AM
I am observing in command prompt. From there I am pinging. At the same time I am monitoring wireshark ICMP pkts
2025-04-09 6:38 AM - edited 2025-04-09 6:39 AM
So do the ICMP packets reach your STM32 ?
Does it do anything with them?
Can you ping anything from your STM32?
2025-04-09 6:48 AM
I don't know whether the pkt which was sent from PC is received by stm32 or not.
Could you tell where to monitor the reception of eth pkts in stm32?