cancel
Showing results for 
Search instead for 
Did you mean: 

UDP Binding Error with New Version of CubeMX Software

KSulli
Associate II

Hello, I recently migrated from old 5.4.0 CubeMX to the STM32CubeMX version 6.0.1. I did not have this binding issue with Firmware Package STM32Cube FW_F7 V1.15.0 in CubeIDE. Now that I am using STM32Cube FW_F7 V1.16.0 the error occurs in the below block of code on the line: if (bind(socket_fd, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) == -1):

void UdpStreamTask() {

 int socket_fd;

 struct sockaddr_in sa, ra;

 int sent_data;

 struct udp_pcb *rxPcbPtr;

 app_assert(0 != m_streamPtr);

 // RX setup - create a new UDP control block

 rxPcbPtr = udp_new();

 app_assert(NULL != rxPcbPtr);

 // set a receive callback for the rxPcbPtr

 udp_recv(rxPcbPtr, udpRxCallback, this);

 // set the remote port

 rxPcbPtr->remote_port = m_remoteUdpPort;

 // bind using the rxPcbPtr to the local port port

 if (udp_bind(rxPcbPtr, IP4_ADDR_ANY, m_localUdpPort) != ERR_OK)

 {

  app_assert(false);

 }

 // TX setup - create the socket

 socket_fd = socket(PF_INET, SOCK_DGRAM, 0);

 app_assert(socket_fd >= 0);

 // set up the local endpoint 

 memset(&sa, 0, sizeof(struct sockaddr_in));

 sa.sin_family = AF_INET;

 sa.sin_addr.s_addr = m_localIP; ///> 192.168.45.180

 sa.sin_port = htons(m_localUdpPort);

 // bind the socket to the specified IP address and port --> BINDING ERROR HAPPENS HERE!! Error is from netconn_bind and error is ERR_USE = -8,

 if (bind(socket_fd, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) == -1)

 {

  app_assert(false);

 }

 // set up the remote endpoint

 memset(&ra, 0, sizeof(struct sockaddr_in));

 ra.sin_family = AF_INET;

 ra.sin_addr.s_addr = m_remoteIP; ///> 192.168.45.179

 ra.sin_port = htons(m_remoteUdpPort);

for (;;;)

{

// handle RX and send data to the remote endpoint

.....

////////////////

Specifically, this error occurs within:

 if (bind(socket_fd, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) == -1)

 {

  app_assert(false);

 }

After the call to bind(), netconn_bind() is called and results in the error ERR_USE = -8,

This only occurs in the latest firmware package, so I am thinking perhaps there is a setting I am missing?

many thanks for any help.

4 REPLIES 4
Houssem CHAABANI
Senior II

Dear @KSulli​ ,

Thank you for your feedback,

Could you please share your .ioc file.

Kind regards,

Houssem

KSulli
Associate II

Hello @Houssem CHAABANI​ 

Thank you very much for your response. Please see the attached .ioc file where the firmware package FW_F7 V1.16.0 in CubeIDE is used. This is the version where I am getting the binding error.

Best regards,

Kevin

Hello @Houssem CHAABANI​ 

Are there any updates on this issue?

Many thanks,