stm32f4discovery + lwip
Hi,
The System Workbench support of lwIP is still partial and you will have to make several adjustments to the generated project.
Correct the include path
You should add (in project >> Properties >> C/C++ General >> Paths and Symbols and for all languages and configurations) a workspace include path to the directory, in the library project, that includes the lwip directory header files are located, that is something like /stm32f4discovery_hal_lib/Middlewares/Third_Party/LwIP/src/include.
You must also include LwIP/src/systemand either LwIP/src/core/ipv4 or LwIP/src/core/ipv6 (but not both__, this is currently not supported by LwIP).
You must do that both in the library project itself and in the application project.
Exclude unneeded source code
You must exclude the LwIP/test and LwIP/system/OS directories (or noOS if you use FreeRTOS too) from the build of the library, by directory >> Properties >> C/C++ Build then check Exclude resource from build; also exclude LwIP/src/netif/ethernetif_template.c as this file could not compile correctly without being completed...
You must also exclude either LwIP/src/core/ipv4 or LwIP/src/core/ipv6 from the build, depending on the protocol you want to use (remember you can’t use both...)
You should also exclude either system/OS or system/noOS from the include search path
Provide the LwIP configuration file
You have to provide an lwipopts.h file, in LwIP/include, to configure which options you need in LwIP; you can get samples either from the LwIP/test/unit directory or some samples provided by ST (however these usually also include FreeRTOS, so you will have to simplyfy them if you don’t).
Provide a network interface
You can either create an ethernet interface from scratch (starting from LwIP/src/netif/ethernetif_template.c or copy an ethernetif.c file from one of the ST-provided demos for your board.
- For example you have a FreeRTOS-based version in Projects/STM324xG_EVAL/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS and a noOS version in Projects/STM324xG_EVAL/Applications/LwIP/LwIP_HTTP_Server_Raw; these are supporting an STM324xG-EVAL board, so you may have to correct a few interface setups (like pin multiplexing).
- This file should be placed in your application project, as you may have to configure the interface specially for your needs.
If you want to use a PPP interface (there is no ETH port on the stm32f’discovery) you will probably have to twiddle the lwipopts.h file, look at the code in src/netif/ppp and LwIP documentation as I don’t think there is any ST-provided example of using LwIP with PPP...
Compile and debug
The result should compile cleanly but, as usual, YMMV...