cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 Series TCP Client with LWIP

mazotcu16
Associate II

Hello everyone, i am trying to configure one STM32H723 as TCP Client and another as TCP Server. I am very new to networking. I used the example project in this github link and didnt change anything except IP addresses and MAC addresses https://github.com/stm32-hotspot/STM32H7-LwIP-Examples/tree/main/STM32H723_Nucleo_ETH.

I am having problem in the client side TCP_Connect function. The function calls ip_route function and this function returns -4(Routing Problems). While debugging i saw that my device doesnt get into this loop inside ip4_route function which i believe indicates i dont have any network interfaces.

NETIF_FOREACH(netif) {

/* is the netif up, does it have a link and a valid address? */

if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany_val(*netif_ip4_addr(netif))) {

/* network mask matches? */

if (ip4_addr_netcmp(dest, netif_ip4_addr(netif), netif_ip4_netmask(netif))) {

/* return netif on which to forward IP packet */

return netif;

}

/* gateway matches on a non broadcast interface? (i.e. peer in a point to point interface) */

if (((netif->flags & NETIF_FLAG_BROADCAST) == 0) && ip4_addr_cmp(dest, netif_ip4_gw(netif))) {

/* return netif on which to forward IP packet */

return netif;

}

}

}

However i didnt change the code so in lwip.c there is a netif structure instance called gnetif. For further explanation,
this is IP address settings for my client:

IP_ADDRESS[0] = 192;

IP_ADDRESS[1] = 168;

IP_ADDRESS[2] = 1;

IP_ADDRESS[3] = 10;

NETMASK_ADDRESS[0] = 255;

NETMASK_ADDRESS[1] = 255;

NETMASK_ADDRESS[2] = 255;

NETMASK_ADDRESS[3] = 0;

GATEWAY_ADDRESS[0] = 192;

GATEWAY_ADDRESS[1] = 168;

GATEWAY_ADDRESS[2] = 1;

GATEWAY_ADDRESS[3] = 1;

 

and this is IP address settings for my server:

 
IP_ADDRESS[0] = 192;

IP_ADDRESS[1] = 168;

IP_ADDRESS[2] = 1;

IP_ADDRESS[3] = 20;

NETMASK_ADDRESS[0] = 255;

NETMASK_ADDRESS[1] = 255;

NETMASK_ADDRESS[2] = 255;

NETMASK_ADDRESS[3] = 0;

GATEWAY_ADDRESS[0] = 192;

GATEWAY_ADDRESS[1] = 168;

GATEWAY_ADDRESS[2] = 1;

GATEWAY_ADDRESS[3] = 1;



1 REPLY 1
ASEHST
ST Employee

Hello @mazotcu16 ,

Please modify the IP address in the StartDefaultTask function at line 324, specifically the line:

IP4_ADDR(&remote_addr, 192, 168, 1, 1);

 so that it matches the IP address of your server.

 

With Regards,

If your question is answered, please close this topic by clicking "Accept as Solution".