cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745 ETH DP83848 & LwIP

Chandra_sekhar
Associate

Moved from MPUs forum: STM32H7 is an MCU - not an MPU.


I configured a new project for STM32H745XIH3 with ETH & Lwip 

Chandra_sekhar_0-1744180155511.png

Chandra_sekhar_1-1744180168286.png

Chandra_sekhar_2-1744180183737.png

Chandra_sekhar_3-1744180199037.pngChandra_sekhar_4-1744180207373.png

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.

9 REPLIES 9

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.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Pavel A.
Evangelist III

Before attempting to generate a new project, please start from one of ready pre-configured examples.

This has chances for success.

 

Ok, Could you share if there is any example for STM32H745 Ethernet Project

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:

Chandra_sekhar_0-1744204962080.png

Before this, I tried what they said in the article also.

------------------------------------------------

 

I am always observing either "request timed out" or "host unreachable."


@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?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

I am observing in command prompt. From there I am pinging. At the same time I am monitoring wireshark ICMP pkts

So do the ICMP packets reach your STM32 ?

Does it do anything with them?

Can you ping anything from your STM32?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

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?