cancel
Showing results for 
Search instead for 
Did you mean: 

netconn_connect() for TCP/IP connection is blocking at osSemaphoreAcquire(TxPktSemaphore,...) on my STM32F746ZG-Nucleo

Zuffouille
Associate II

I try to implement a TCP/IP client on my STM32F746ZG-Nucleo.

Before the last update it was working. But no more now.

The first pass I always get a ERR_RTE because the ethernet link is not up. So I tried to connect each 5 secondes 5 times.

But the second pass, the link is up and everything seems good except one thing.

The program stay blocked on trying to acquire the semaphore :

 HAL_ETH_Transmit_IT(&heth, &TxConfig);
  while(osSemaphoreAcquire(TxPktSemaphore, TIME_WAITING_FOR_INPUT)!=osOK)
 
  {
  }
 
  HAL_ETH_ReleaseTxPacket(&heth);

Even if I wait 5 sec before trying to connect at the start, it will stay blocked at the exact same line.

I tried to add "netconn_set_nonblocking(conn, true);" but doesn't change anything.

Here is my configuration :

void StartDefaultTask(void *argument)
{
  /* init code for LWIP */
  MX_LWIP_Init();
  /* USER CODE BEGIN 5 */
  allInitCompleted = true;
 
	/* Infinite loop */
	for(;;)
	{
		osDelay(100);
	}
  /* USER CODE END 5 */
}

And the function called my client thread to start the connection :

void ComChanEth::openConnection() {
	err_t err;
	setState(COMCHAN_CONNECTING);
 
	// Create a new connection identifier
	conn = netconn_new(NETCONN_TCP);
 
	netconn_set_nonblocking(conn, true);
 
	if (conn)
	{
		// Bind connection to the port number 7 (port of the Client)
		err = netconn_bind(conn, IP_ADDR_ANY, MY_ETH_PORT);
 
		if (err == ERR_OK)
		{
			for(uint8_t nbTry = 0; nbTry < MAX_TRY_ETH_CONNECT; nbTry++)
			{
				// Start TCP/IP connection
				err = netconn_connect(conn, getServerAddress(), getServerPort());
 
				// If the connection is established, exit the loop
				if (err == ERR_OK)
				{
					setState(COMCHAN_CONNECTED);
					break;
				}
				else
					osDelay(5000); // Retry in 5 seconds
			}
			// If the connection has been established after 5 try, delete the connection
			if (err != ERR_OK)
				closeConnection();
		}
		else
		{
			// If the binding wasn't successful, delete the netconn connection
			closeConnection();
		}
	}
}

Does anyone have an idea ? or need more information to help me ?

1 ACCEPTED SOLUTION

Accepted Solutions
4 REPLIES 4
Pavel A.
Evangelist III

> Before the last update it was working

What are versions of the "HAL" library or ethernet driver before and after the 'last update'?

Zuffouille
Associate II

I'm not sure were to look for version number.

So I searched "version" in my entire project.

Before update :

File.Version=6

LWIP.Version=v2.1.2_Cube

MxCube.Version=6.5.0

MxDb.Version=DB.6.0.50

After update :

File.Version=6

LWIP.Version=v2.1.2_Cube

MxCube.Version=6.6.1

MxDb.Version=DB.6.0.60

Zuffouille
Associate II