[Distributed temperature and humidity acquisition system] + STM32H745I-LWIP debugging process
[Copy link]
This post was last edited by lansebuluo on 2022-7-15 22:45
To transplant the LWIP program with the operating system, I found some other posts on the Internet for transplantation. After the code was compiled, downloaded and run, the result was abnormal, so I had to debug the code.
I have no experience in debugging networks. After days of searching, I finally found a way. Although it is not working yet, I would like to share it with you in the hope of getting more discussions.
There are a lot of debugging codes in the LWIP protocol stack. How to enable it? Taking the STM32H745I-DISCO development board as an example, the process is explained.
The first method is to use USART to print
First, redefine the printf function and then output the debugging print information. The development board comes with a virtual serial port, which is connected to the main control chip USART3.
Define the pins corresponding to the hardware peripheral USART3
Hardware initialization code
USART3 initialization code
Redefine the function fputc
After completing these, you can use the printf function, but where to output it? You can use the HyperTerminal tool to receive data through the serial port.
The second method uses the signal function of the development board and directly uses IAR's Terminal I/O to view and print information, which is very convenient.
Set the project option as shown below
At this point, in IAR debugging mode, select VIEW>>Terminal I/O from the menu bar to open the corresponding window. You must be in DEBUG mode to select this.
With these, only the printf function has output function, and the debugging switch of LWIP needs to be defined.
In the lwipopts.h file, define the DEBUG switch. If you want to debug a part, define the corresponding part as LWIP_DBG_ON
Through the above, you can see which part of your program has a problem. Once the problem is located, you still need to solve the problem yourself.
Here is part of the debugging code. This program locates the application to create a binary semaphore in api_msg.c and fails. I don't know why it fails. It should be related to some definitions of FreeRTOS and has not been resolved yet.
Problem location
|