How to setup a native LwIP TCP stack for STM32F7 board ?
Hi,
I'm desperate !
Can somebody help me setup a working TCP / UDP stack on an STM32F767ZI
evaluation board using LwIP native (ie not rtos/netconn) ?
This should be easy, I obviously am missing something but what ???
I Have read all available documentation on ST (about 3 or 4 pdf): they
were of no help.
I looked over the internet: I see I am not alone to suffer on this
but found no usable answer. If a good answer is made it will clearly
not only good for me, but for many other people as well: so please help !
Here are the details of what I do:
1) Selection of the board
- I use STM32CubeIDE (Version: 1.2.1 Build: 5190_20200115_1224 (UTC))
- I go to "File->New->STM32 Project
- Within MCU/MPU Selector, I search for "STM32F767ZI"
- Within the search result screen on the right side, I select "NUCLEO-F767ZI"
that appears as a link in the "Board" collumn.
- I click on "Next>" at the bottom of the screen.
2) Enabling LwIP in CubeMX
- I enter a project name (say "tcptest52")
- I hit "Finish" (not modifying anything from the proposed defaults)
- I answer yes to "Initialize all peripherals with their default Mode ?"
- I answer yes to "This kind of project is associated with the STM32CubeMx
perspective. Do you want to open this perspective now ?"
- I click on "Middleware->LWIP"
- I click on "Enabled"
- I click on "IPv4 - DHCP Options / LWIP_DHCP : Disabled"
- I enter a fixed IP: 192.168.001.200
- I enter a net mask: 255.255.255.000
- I enter a gateway : 192.168.001.001
- I go to "File->Save" which generates the code
note:
- LWIP_ICMP is enabled (I don't change this, I expect it to reply to pings)
- LWIP_UDP is enabled (I don't change this, obviously: this is what I want)
- MEMP_NUM_UDP_PCB=4 proposed by default
- LWIP_TCP is enabled (I don't change this)
- MEMP_NUM_TCP_PCB=5 proposed by default
in general I kept all the defaults proposed besides the fixed IP.
3) Adding LWIP process function
- I open the Core/Src/main.c file
- within the int main(void) function, I edit the while(1) loop
to add the LWIP event processing function:
/* USER CODE BEGIN WHILE */
while (1)
{
MX_LWIP_Process();
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
- I execute the project "Run->Debug"
- I select "STM32 Cortex-M C/C++ Application"
- I builds the project (no error/no warnings)
- In "Edit launch configuration properties" I keep the defaults
and i just click "OK"
- It proposes me to switch to the debugger view, I do agree
by clicking on "Switch"
- I click on the "Resume/F8" button (something that looks like
a yellow and green recorder "play/pause" button)
4) Test
- from the computer I try
C:\Users\frcl>ping 192.168.1.200
Pinging 192.168.1.200 with 32 bytes of data:
Reply from 192.168.1.199: Destination host unreachable.
Reply from 192.168.1.4: Destination host unreachable.
Reply from 192.168.1.4: Destination host unreachable.
Reply from 192.168.1.4: Destination host unreachable.
Ping statistics for 192.168.1.200:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
C:\Users\frcl>
It just simply doesn't work.
Note 1:
I compiled an http TCP server I wrote for the same board using mbed,
and it does work perfectly in the exact same configuration:
answers to ping (and answers to the web browser as well):
C:\Users\frcl>ping 192.168.1.200
Pinging 192.168.1.200 with 32 bytes of data:
Reply from 192.168.1.200: bytes=32 time<1ms TTL=255
Reply from 192.168.1.200: bytes=32 time<1ms TTL=255
Reply from 192.168.1.200: bytes=32 time<1ms TTL=255
Reply from 192.168.1.200: bytes=32 time<1ms TTL=255
Ping statistics for 192.168.1.200:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
So the hardware is working fine and the network is also working fine.
Note 2:
As I explained, I tried (with no luck) to find answers in the
ST documentation:
- UM1709 User manual STM32Cube Ethernet IAP example
- AN3966 Application note
LwIP TCP/IP stack demonstration for STM32F4x7 microcontrollers
- UM1713 User manual
Developing applications on STM32Cube with LwIP TCP/IP stack