Skip to main content
ST Employee
April 18, 2023
Question

How to properly initialize LwIP for static IP or DHCP?

  • April 18, 2023
  • 1 reply
  • 2697 views

For example, my EEPROM has setting for static IP or DHCP.

The problems is MX_LWIP_Init() does not have proper user code sections. It always call dhcp_start(), but I do not need it in case of static IP. The other problem is no any static IP config and all my changes lost each time I regenerate code. Maybe i'm missing something?

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    April 18, 2023

    Hello @ARaid.1​ ,

    You can start with LwIP application under STM32CubeXX MCU package with a similar type of your project to deduce what is going wrong in your case. 

    Check the post How to make Ethernet and lwIP working on STM32, and the example in this article "How to create project for STM32H7 with Ethernet and LwIP stack working" it may help you.

    > all my changes lost each time I regenerate code. 

    In CubeMx, make sure to enable the option: Keep user code when regenerating the C code. 

    Imen