cancel
Showing results for 
Search instead for 
Did you mean: 

simple LWIP UDP project not working with latest Cubmx 9.6.2

Mz.1
Associate III

Hi,

I'm using STM32H743ZI with STM32CubeMX 6.9.2 and STM32CubeIDE 1.13.1.

I added new STM32 project using the CubeIDE GUI - selected the STM32H743ZI device and automatically the project was generated, I opend the IOC file and enabled the ETH + LWIP options and that's it.

I added to my main function the below code from google:

int main(void)
{
/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();

/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_LWIP_Init();
/* USER CODE BEGIN 2 */
const char* message = "Hello UDP message!\n\r";

ip_addr_t PC_IPADDR;
IP_ADDR4(&PC_IPADDR, 192, 168, 2, 10);

struct udp_pcb* my_udp = udp_new();
udp_connect(my_udp, &PC_IPADDR, 55151);
struct pbuf* udp_buffer = NULL;

/* Infinite loop */
for (;;) {
/* !! PBUF_RAM is critical for correct operation !! */
udp_buffer = pbuf_alloc(PBUF_TRANSPORT, strlen(message), PBUF_RAM);

if (udp_buffer != NULL) {
memcpy(udp_buffer->payload, message, strlen(message));
udp_send(my_udp, udp_buffer);
pbuf_free(udp_buffer);
}
}
/* USER CODE END 2 */

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}

 

opened Wireshark to see the messages - and nothing:

Mz1_0-1700046225542.png

 

IOC file is here - https://fastupload.io/o9rIZHW6XnOZWzQ/file   (failed to attach the file here from some reason)

this simple code worked in earlier versions of CubeMX...

 

pls help! thank you :)

 

10 REPLIES 10
Pavel A.
Evangelist III