This demo is indeed to explain how FreeRTOS+TCP (a scalable, open source and thread safe TCP/IP stack for FreeRTOS) can be integrated in a Xilinx SDK project. There is a more detailed explanation tutorial in the FreeRTOS webpage on how use the stack , so this demo is focused on implementing the examples in the Xilinx SDK environment using the FreeRTOS release included within the SDK installation. There is also a complete demo example for ZC702 including both TCP and FAT stacks.

Files Required

The FreeRTOS TCP/IP stack can be downloaded from the FreeRTOSLabs website.

Basic Project Structure

Create a FreeRTOS empty project in the SDK using the new application wizard.

Import TCP stack to the application project (File -> Import) and select GCC compiler files and Zynq network interface files within the portable folder (Listed files bellow)
  All C Files
    All Files
       All Files
        All Files

Import memory related implementations from the Zynq Demo.


Create a main.c file and copy the example code provided

Project Configuration

Configure compiler include paths to get the stack header files.

Modify IP Stack configuration file (FreeRTOSIPConfig.h) modifying the following values
#define ipconfigUSE_LLMNR                  ( 0 )
#define ipconfigUSE_NBNS                    ( 0 )

//extern UBaseType_t uxRand();
//#define ipconfigRAND32()    uxRand()

#define ipconfigSUPPORT_OUTGOING_PINGS                0

//#include "DemoIPTrace.h"

Comment the following lines within uncached_memory.c to avoid compilation errors
//#include "UDPLoggingPrintf.h"

//lUDPLoggingPrintf( "vInitialiseUncachedMemory: Can not allocate uncached memory\n" );

In order to be able to implement this example, the default amount of memory pool have to be increased in the FreeRTOS configuration (Modify BSP Settings), and the heap stack increased in the linker script.

Example Demo

Configure the target IP address in the main.c file according to your setup
Note: Configure your host IP address and ensure that the target address is also in the same network address range
static const uint8_t ucIPAddress[ 4 ] = { 192, 168, 1, 100 };
static const uint8_t ucNetMask[ 4 ] = { 255, 255, 255, 0 };
static const uint8_t ucGatewayAddress[ 4 ] = { 192, 168, 1, 1 };

Create a debug configuration for the demo application and run in the target.
Check TCP/IP conectivity running a ping command from your host system to the target

Open a serial terminal and telnet terminal (ie. Kitty/Putty). Once the application is launched the initialization messages will be printed in the serial terminal. The demo consist in a echo server which would return the lines send from TCP client to the server.

Related Links