Skip to main content
Graduate II
July 15, 2024
Question

Application compiler error in STM32Cube_FW_F4

  • July 15, 2024
  • 1 reply
  • 503 views

Hi there,

I am using cubeMx to config the LwIP project which is based on STM32F429BI;

I connect the MCU to the route and ping the MCU by PC successfully in DHCP or static IP mode.

I can normally get the MCU IPv4 address in static IP mode but fail in DHCP mode.

my code for getting the IP address is below:

#if LWIP_DHCP
if(ip4_addr_isany_val(*netif_ip4_addr(&gnetif))) {
  LOG_DBG("DHCP enabled, check the IP in route\n");    // in DHCP mode, always print this line
} else {
  LOG_DBG(" IP : %s\n", ip4addr_ntoa(netif_ip4_addr(&gnetif)));
  LOG_DBG("Mask: %s\n", ip4addr_ntoa(netif_ip4_netmask(&gnetif)));
  LOG_DBG(" GW : %s\n", ip4addr_ntoa(netif_ip4_gw(&gnetif)));
}
#else
  LOG_DBG(" IP : %s\n", ip4addr_ntoa(netif_ip4_addr(&gnetif)));
  LOG_DBG("Mask: %s\n", ip4addr_ntoa(netif_ip4_netmask(&gnetif)));
  LOG_DBG(" GW : %s\n", ip4addr_ntoa(netif_ip4_gw(&gnetif)));
#endif

I don't know why this code always gets the DHCP IP address 0.

Any information is welcome, thank you!

    This topic has been closed for replies.

    1 reply

    JundeAuthor
    Graduate II
    July 15, 2024

    more info:

    Junde_0-1721015413107.png