FreeRTOS+TCP with STM32F429 and LAN8720

mgolebiowski wrote on Thursday, October 06, 2016:

Hello,
I’m doing a project on STM32F429ii and LAN8720( http://ww1.microchip.com/downloads/en/DeviceDoc/00002165B.pdf ) PHY with FreeRTOS. It’ll serve a Webserver with continuous data fetch over AJAX and Modbus TCP.

I have a working version based on LwIP and Demo from ST but there are problems with long working continuous data fetch propably because of LwIP or ST’s ETH driver.

I’m now trying to set up the FreeRTOS+TCP stack instead of LwIP. I used this demo http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP-IP_FAT_Examples_ST_STM32F407.html as a starting point but I have problems with make the TCP stack working with my hardware.

And here is the question: what should I change in NetworkInterface.c and HAL driver in this demo to make it working with my PHY? Unfortunately changing the defines (like PHY_BCR etc.) and GPIOs HAL_ETH_MspInit is not enough and it’s still not responding for pings.

Thanks for help,
Michal

rtel wrote on Thursday, October 06, 2016:

As you have a working driver for your existing lwIP example I presume you already have a working initialise and transmit function - albeit with the lwIP function names rather than the function names FreeRTOS+TCP expects.

As a starting point I would suggest using the lwIP initialisation function, but call it xNetworkInterfaceOutput(), so it links with FreeRTOS+TCP. That way you don’t need to change any of the PHY code as you have it working already.

You will probably also be able to use the lwIP transmit function, which can be renamed xNetworkInterfaceOutput() so it links with FreeRTOS+TCP, but that will require some updates as the packets passed into the function for transmission will be in FreeRTOS+TCP network buffers rather than lwIP network buffers.

That should be enough to see data going out onto the network - once that is working you can then create the receive function from the lwIP receive function too, but again you will have to adapt it to package the received data in FreeRTOS+TCP network buffers rather than lwIP network buffers. In this case there is no specific function name that is needed, but you do need to send the network buffers on a queue. You will see how that is done in the FreeRTOS+TCP STM32 driver that you are already using as a reference.

Once things are just ‘working’ you can look at how you could optimise them for FreeRTOS+TCP, if optimisation is a concern.

http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Ethernet_Porting.html