Skip to main content
Visitor II
July 14, 2025
Question

STM32H7 + LAN8742: No DHCP Request Observed

  • July 14, 2025
  • 1 reply
  • 552 views

Hi,
I'm using an STM32H7 board with a LAN8742 PHY, configured via STM32CubeMX.
LwIP is initialized without RTOS, and Ethernet is in RMII mode.

The main goal of this project is to receive data over UART and forward it via Ethernet.
I want the STM32 board to connect to a standard router using a physical Ethernet cable, obtain a dynamic IP address via DHCP, and then transmit the received UART data over the network.
Currently, the board does not seem to request or receive any IP address — while the PC connected to the same router receives an IP successfully, the STM32 does not.

So far I've verified:

  • MX_LWIP_Init() is called from main.c

  • MX_LWIP_Process() is called inside the main while (1) loop

  • MAC address is manually set in ethernetif.c:

MACAddr[0] = 0x02;
MACAddr[1] = 0x12;
MACAddr[2] = 0x34;
MACAddr[3] = 0x56;
MACAddr[4] = 0x78;
MACAddr[5] = 0x9A;
  • DHCP is enabled in .ioc under LwIP configuration

  • netif_add(), netif_set_default(), netif_set_up() and dhcp_start() are called

  • ETH is initialized and started (HAL_ETH_Init() and HAL_ETH_Start() succeed)

  • netif_set_link_up() is called after starting ETH

  • I verified with Wireshark: no DHCP Discover is sent from the STM32

Any idea what might be missing or preventing DHCP packets from being sent?

Thanks in advance.

 

Hardware setup:
The board is connected via Ethernet to a local router that acts as a DHCP server. I verified that the same cable and port work with other devices.

WhatsApp Image 2025-07-14 at 16.08.30_914e31a7.jpg

WhatsApp Image 2025-07-14 at 16.08.30_c81398da.jpg

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    July 18, 2025

    Hello @Matan ,

    Do you have such issue with the working LwIP project: https://github.com/stm32-hotspot/STM32H7-LwIP-Examples.?

    I recommend you follow this article : How to create a project for STM32H7 with Ethernet and LwIP stack working