2025-07-09 12:28 AM
Hello,
I need the TCP Server with static IP address. I chose the Nx_TCP_Echo_Echo_Server example and NUCLEO-H723ZG board as a starting point. I use the STM32CubeIDE 1.19 with latest x-cube-azrtos-h7-v3-4-0 sample files. So I imported the Nx_TCP_Echo_Echo_Server example project and compiled it without problems. But after that I disabled DHCP and set the static IP address:
After that project can't be build and it is necessary to edit app_netxduo.c file as in it still there are some code related to DHCP. But even after successful compilation I can't connect to the server from the client. Also I can't ping it too.
It seems that this is a global problem with NetXDuo as there are plenty of posts with similar problems. E.g.:
https://community.st.com/t5/stm32-mcus-embedded-software/netxduo-not-working-with-a-static-ip-addresss/td-p/673975
https://community.st.com/t5/stm32-mcus-embedded-software/http-server-on-netx-and-azrtos-disable-dhcp-when-using-fixed-ip/td-p/94729
I've tried to implement all the recommendations from these posts, but still no result.
I attach my project and raise the question - how the TCP server with Static IP address can be realized using NetXDuo ?
- on
2025-07-10 2:35 AM
Hello @Irek,
Thank you for your report.
After an initial analysis, it appears to be an issue related to CubeIDE. I followed the same steps you described and was able to ping successfully using IAR, but not with CubeIDE.
This recurring issue has been tracked internally, and an internal ticket (213871) has already been raised for further follow-up.
With Regards,
2025-07-10 11:00 PM
@ASEHST
Thank you! I hope this problem will be solved soon.
2025-07-11 11:57 PM - edited 2025-07-12 12:00 AM
My suggestion is to use CubeMX as less as you can for those stuff. You need instead to have a better understanding on how the code (and NetX Duo) works.
From the example ST provides, you should see a launch of a thread called "App_Main_Thread_Entry".
This is where if you use DHCP, you set-up the relative callback (nx_ip_address_change_notify) , start the DHCP client and then wait for the semaphore untill you have obtained a valid IP .
I would suggest an approach like the one below (used in my code-base, without problems):
static VOID App_Main_Thread_Entry(ULONG thread_input)
{
UINT ret;
if ( cfg_get_is_dhcp(TX_WAIT_FOREVER)) //retrive config of DHCP/STATIC mode from config file.
{
/* register the IP address change callback */
ret = nx_ip_address_change_notify(&IpInstance, ip_address_change_notify_callback, NULL);
if (ret != NX_SUCCESS) {
Error_Handler();
}
/* start the DHCP client */
ret = nx_dhcp_start(&DHCPClient);
if (ret != NX_SUCCESS) {
Error_Handler();
}
/* wait until an IP address is ready */
if(tx_semaphore_get(&Semaphore, TX_WAIT_FOREVER) != TX_SUCCESS) {
Error_Handler();
}
UCHAR dns_ip_string[20];
UINT size;
if ( nx_dhcp_user_option_retrieve(&DHCPClient,NX_DHCP_OPTION_DNS_SVR,dns_ip_string,&size) == TX_SUCCESS )
{
ULONG dns_ip = 0;
if ( size == 8 )
{
dns_ip = dns_ip_string[3]<<24 | dns_ip_string[2]<<16 | dns_ip_string[1]<<8 | dns_ip_string[0];
nx_dns_server_add(&dns_ptr, dns_ip);
dns_ip = dns_ip_string[7]<<24 | dns_ip_string[6]<<16 | dns_ip_string[5]<<8 | dns_ip_string[4];
nx_dns_server_add(&dns_ptr, dns_ip);
}else if ( size == 4 )
{
dns_ip = dns_ip_string[3]<<24 | dns_ip_string[2]<<16 | dns_ip_string[1]<<8 | dns_ip_string[0];
nx_dns_server_add(&dns_ptr, dns_ip);
}
}
}
else
{
//here again i get out static ip config from my conf file..
ULONG ip = cfg_get_static_ip(TX_WAIT_FOREVER);
ULONG nmask = cfg_get_netmask(TX_WAIT_FOREVER);
ULONG gw = cfg_get_gw(TX_WAIT_FOREVER);
ULONG dns_ip = cfg_get_dns1(TX_WAIT_FOREVER);
nx_ip_address_set(&IpInstance,ip, nmask);
nx_ip_gateway_address_set(&IpInstance,gw);
nx_dns_server_add(&dns_ptr, dns_ip);
}
tx_thread_resume(ÐLINK_mon_thread);
/*start here thread that uses your network interface*/
tx_thread_relinquish();
return;
}
All the cfg_xxxx functions are related to a system that retrive configurations from a config file stored on an external SPI FLASH where i run FileX(Fault Tollerant) + LX .
If you don't need that, just place the values you need statically.
D.