cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743ZI LWIP TCP/IP EchoClient Example

KKim.19
Associate II

I am sorry that I am not good at English.

Hi. 

I use the stm32h743zi mcu. 

I ported stm32h743i-val lwip tcp echo server and client application

server application was well working but client was not working

ping test was not responed.

my firmware flow is this

lwip init -> tcp_echoclient init -> lwip process

i don't use RTOS

14 REPLIES 14
HAkei.427
Associate

Yes, I have the same issue. I am using Nucleo board with STM32H743ZI. I tried lwip netconn echo server without any problem, but I couldn't manage to get neither the tcp echo client example working that uses Raw lwip API (after I ported from STM32H743I) nor using netconn API with FreeRTOS.

I wish we can get any help from STMicro team regarding the TCP/IP client issue.

PLang.4
Associate II

I have the same problem. I cannot make LWIP TCP client work on stm32f4. Can anybody please provide full example of TCP client working on some discovery board?

Thank You.

Peter

i had solved the problem. after a while, i couldn't remember exactly

but i set up recommendded MPU memory and activated the D-cash while the lwip processing

and increased the heap memory.

i recommend debugging through wireshark.

i hope it helped you​

thank you

PLang.4
Associate II

Thx Kim for answer,

Can you please tell me where I find this recommendation? I am generating project from CubeMX and probably some settings to Ethernet driver or LWIP library is not as it should be. However I am not able to debug what to problem is, I just do not get any error message, any assert nothing, function for connection passes as the connection was successfully established. but I cannot see any message in wireshark, LWIP library did nothing...

I tried couple approaches to make TCP connection to server:

raw api:

echoclient_pcb = tcp_new();

tcp_connect(echoclient_pcb,&ipaddr,50030,tcp_echoclient_connected);

netconn api:

void tcp_client_thread(void)

{

   struct netconn * conn;

   ip_addr_t ipaddr;

   ip_addr_t local;

   unsigned int   port_no = 50070;

   err_t          err2;

   tcp_setup();

   IP4_ADDR(&local, 192, 168, 0, 70);

   IP4_ADDR(&ipaddr, 192, 168, 0, 30);                                        // Connection destination IP address

       conn = netconn_new(NETCONN_TCP);                                       // create new TCP connection handle

       if (conn!= NULL) {

          err2 = netconn_bind(conn, &local, port_no);

           if (err2 == ERR_OK) {

              err2 = netconn_connect(conn, &ipaddr, 50030);                    // Connection destination port is 4000

               if(err2 == ERR_OK) {

                  HAL_GPIO_TogglePin(LED_B_GPIO_Port, LED_B_Pin);

                   while(1) {

                       tcp_client_serve(conn);

                       if (conn->pcb.tcp->state == CLOSE_WAIT) {

                           break;

                       }

                   }

               }

               else {

                   printf("Connect server fail ! \n");

               }

           }

           else {

               printf("can not bind netconn");

           }

       }

       else {

           printf("can not create netconn");

       }

       netconn_delete(conn);                                                  // delete TCP connection handle

       if (port_no < 0xFFFF)  port_no++;                                     // port number is increment

       else                   port_no = 0xC000;

       osDelay(1000);

       HAL_GPIO_TogglePin(LED_G_GPIO_Port, LED_G_Pin);

   }

}

both approaches pass without failing, but as I said, chip do not send any ACK message. But when I create netconn server on the same board, with the same Ethernet an LWIP setup, everything works OK

 struct netconn *conn, *newconn;

 err_t err, accept_err;

netcon TCP server - works fine with the same ethernet and lwip configuration.

 conn = netconn_new(NETCONN_TCP);

 HAL_GPIO_WritePin(GPIOE, LED_P_Pin, GPIO_PIN_SET);

 if (conn!= NULL)

 {

   /* Bind to port 80 (HTTP) with default IP address */

   err = netconn_bind(conn, NULL, 50070);

   if (err == ERR_OK)

   {

     HAL_GPIO_WritePin(GPIOE, LED_W_Pin, GPIO_PIN_SET);

     /* Put the connection into LISTEN state */

     netconn_listen(conn);

     while(1)

     {

//      HAL_GPIO_TogglePin(GPIOE, LED_B_Pin);

       /* accept any icoming connection */

       accept_err = netconn_accept(conn, &newconn);

       if(accept_err == ERR_OK)

       {

          HAL_GPIO_TogglePin(GPIOE, LED_B_Pin);

         /* serve connection */

         http_server_serve(newconn);

         /* delete connection */

         netconn_delete(newconn);

       }

     }

   }

 }

thx a lot

Peter

PLang.4
Associate II

Thx Kim for answer,

Can you please tell me where I find this recommendation? I am generating project from CubeMX and probably some settings to Ethernet driver or LWIP library is not as it should be. However I am not able to debug what to problem is, I just do not get any error message, any assert nothing, function for connection passes as the connection was successfully established. but I cannot see any message in wireshark, LWIP library did nothing...

I tried couple approaches to make TCP connection to server:

raw api:

echoclient_pcb = tcp_new();

tcp_connect(echoclient_pcb,&ipaddr,50030,tcp_echoclient_connected);

netconn api:

void tcp_client_thread(void)

{

   struct netconn * conn;

   ip_addr_t ipaddr;

   ip_addr_t local;

   unsigned int   port_no = 50070;

   err_t          err2;

   tcp_setup();

   IP4_ADDR(&local, 192, 168, 0, 70);

   IP4_ADDR(&ipaddr, 192, 168, 0, 30);                                        // Connection destination IP address

       conn = netconn_new(NETCONN_TCP);                                       // create new TCP connection handle

       if (conn!= NULL) {

          err2 = netconn_bind(conn, &local, port_no);

           if (err2 == ERR_OK) {

              err2 = netconn_connect(conn, &ipaddr, 50030);                    // Connection destination port is 4000

               if(err2 == ERR_OK) {

                  HAL_GPIO_TogglePin(LED_B_GPIO_Port, LED_B_Pin);

                   while(1) {

                       tcp_client_serve(conn);

                       if (conn->pcb.tcp->state == CLOSE_WAIT) {

                           break;

                       }

                   }

               }

               else {

                   printf("Connect server fail ! \n");

               }

           }

           else {

               printf("can not bind netconn");

           }

       }

       else {

           printf("can not create netconn");

       }

       netconn_delete(conn);                                                  // delete TCP connection handle

       if (port_no < 0xFFFF)  port_no++;                                     // port number is increment

       else                   port_no = 0xC000;

       osDelay(1000);

       HAL_GPIO_TogglePin(LED_G_GPIO_Port, LED_G_Pin);

   }

}

both approaches pass without failing, but as I said, chip do not send any ACK message. But when I create netconn server on the same board, with the same Ethernet an LWIP setup, everything works OK

 struct netconn *conn, *newconn;

 err_t err, accept_err;

netcon TCP server - works fine with the same ethernet and lwip configuration.

 conn = netconn_new(NETCONN_TCP);

 HAL_GPIO_WritePin(GPIOE, LED_P_Pin, GPIO_PIN_SET);

 if (conn!= NULL)

 {

   /* Bind to port 80 (HTTP) with default IP address */

   err = netconn_bind(conn, NULL, 50070);

   if (err == ERR_OK)

   {

     HAL_GPIO_WritePin(GPIOE, LED_W_Pin, GPIO_PIN_SET);

     /* Put the connection into LISTEN state */

     netconn_listen(conn);

     while(1)

     {

//      HAL_GPIO_TogglePin(GPIOE, LED_B_Pin);

       /* accept any icoming connection */

       accept_err = netconn_accept(conn, &newconn);

       if(accept_err == ERR_OK)

       {

          HAL_GPIO_TogglePin(GPIOE, LED_B_Pin);

         /* serve connection */

         http_server_serve(newconn);

         /* delete connection */

         netconn_delete(newconn);

       }

     }

   }

 }

thx a lot

Peter

PLang.4
Associate II

only thing I see in Wireshark is

ARP Who has 192.168.0.30? Tell 192.168.0.70

LLDP MA/8c:3b:ad:2c:ed:a0 LA/g7 120

but after this no ACK message of TCP protokol

PLang.4
Associate II

only thing I see in Wireshark is

ARP Who has 192.168.0.30? Tell 192.168.0.70

LLDP MA/8c:3b:ad:2c:ed:a0 LA/g7 120

but after this no ACK message of TCP protokol

KKim.19
Associate II

I did not use RTOS.

And I have Project STM32H743I-EVAL in STM32Cube_FH_H7_V1.4.0

Refer to LWIP Application.

This is what the MPU referenced.

https://community.st.com/s/article/FAQ-Ethernet-not-working-on-STM32H7x3

I hope this helps.