cancel
Showing results for 
Search instead for 
Did you mean: 

LWIP Debug Messages Not Working

lavanya
Associate III

I Enabled LWIP DEBUG options in CUBEMX

in lwipopt.h 

 

/* USER CODE BEGIN 1 */

#define LWIP_DEBUG 1

/* USER CODE END 1 */

 

in main.c 

 

int __io_putchar(int ch)
{
 ITM_SendChar(ch);
 return ch;
}

 

 But I am not getting anything in SWVITM Data Console

1 ACCEPTED SOLUTION

Accepted Solutions

 

#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
//added fflush after printing Now it's working
#define LWIP_PLATFORM_DIAG(x) do {printf x;fflush(0);} while(0)

 

 

View solution in original post

3 REPLIES 3
ASEHST
ST Employee

Hello @lavanya

 

With the #define LWIP_DEBUG 1, you should also define the specific topic you want to log. For example, to debug the dhcp.c file, you can add the following define:

 

 

#define DHCP_DEBUG LWIP_DBG_ON

 

This will enable debug messages for DHCP.

 

With Regards,

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

Did you follow this: https://community.st.com/t5/stm32-mcus/using-the-itm-console-for-printf-redirects-and-lwip-debug/ta-p/723472 ?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

 

#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
//added fflush after printing Now it's working
#define LWIP_PLATFORM_DIAG(x) do {printf x;fflush(0);} while(0)