Skip to main content
YiKai
Associate II
October 13, 2020
Solved

STM32 & CubeMX LWIP change IP

  • October 13, 2020
  • 2 replies
  • 1514 views

Hi, I use LWIP to establish a connection, We want to change the IP address, how can I update IP?

 tcpip_init( NULL, NULL );
 
 /* IP addresses initialization without DHCP (IPv4) */
 IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
 IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
 IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]);
 
 /* add the network interface (IPv4/IPv6) with RTOS */
 netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input);
 
 /* Registers the default network interface */
 netif_set_default(&gnetif);
 
 if (netif_is_link_up(&gnetif))
 {
 /* When the netif is fully configured this function must be called */
 netif_set_up(&gnetif);
 }
 else
 {
 /* When the netif link is down this function must be called */
 netif_set_down(&gnetif);
}

I used to remove the link and reconnect, it doesn't work. is there any ideas?

This topic has been closed for replies.
Best answer by Khouloud ZEMMELI

Hello @YiKai​ 

You need to Disable the LWIP_DHCP then under IP Address settings you can update it.

Please use the latest CubeMX release (6.0.1) because there's an issue related to LWIP in the previous version (5.6.1).

0693W000004Jc0DQAS.png 

Best Regards,

Khouloud

2 replies

Khouloud ZEMMELI
Khouloud ZEMMELIBest answer
ST Employee
October 13, 2020

Hello @YiKai​ 

You need to Disable the LWIP_DHCP then under IP Address settings you can update it.

Please use the latest CubeMX release (6.0.1) because there's an issue related to LWIP in the previous version (5.6.1).

0693W000004Jc0DQAS.png 

Best Regards,

Khouloud

YiKai
YiKaiAuthor
Associate II
October 14, 2020

Thanks, I use the latest CubeMX release, it's work.