FreeRTOS_IPInit returning a failure

I have written a very basic function for configuring the IP of one of my interfaces. I’am using a zynq board.

Here is my main program:

#include “FreeRTOS.h”
#include “FreeRTOS_IP.h”
#include “task.h”

/* Define the network configuration parameters */
static const uint8_t ucIPAddress[ 4 ] = { 192, 168, 1, 100 };
static const uint8_t ucNetMask[ 4 ] = { 255, 255, 255, 0 };
static const uint8_t ucGateway[ 4 ] = { 192, 168, 1, 1 };
static const uint8_t ucDNSServer[ 4 ] = { 8, 8, 8, 8 };
static const uint8_t ucMACAddress[ 6 ] = { 0x00, 0x1A, 0xB6, 0x03, 0x2B, 0x7E };

/* Callback function for network events */
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
    if( eNetworkEvent == eNetworkUp )
    {
        /* Network is up, you can start communication tasks here */
        printf( “Network is up !\ n” );
    }
}

/* Main function */
int main( void )
{
    int x;

    printf( “Free RTOS TAsk !\ n” );
    /* Initialize the FreeRTOS+TCP stack */
    x = FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGateway, ucDNSServer, ucMACAddress );

    printf( "The return Value is %d\n", x );

    /* Start the FreeRTOS scheduler */
    vTaskStartScheduler();

    /* Should never reach here */
    for( ; ; )
    {
    }

    return 0;
}

void vApplicationPingReplyHook( ePingReplyStatus_t eStatus,
                                uint16_t usIdentifier )
{
    /* Handle ping replies if needed */
}

void vApplicationMallocFailedHook( void ) /* Handle memory allocation failures */
{
    printf( “Malloc failed !\ n” );

    for( ; ; )
    {
    }
}

Here is my FreeRTOSIPConfig.h:

#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H

/* Ensure INCLUDE_xTaskGetCurrentTaskHandle is defined as required */
#undef INCLUDE_xTaskGetCurrentTaskHandle
#define INCLUDE_xTaskGetCurrentTaskHandle 1

/* Define byte order for the platform (assuming little-endian) *
/#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN

/* Increase number of network buffer descriptors for better throughput */
#undef ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS
#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 40

/* Increase event queue length to match buffer descriptors */
#undef ipconfigEVENT_QUEUE_LENGTH
#define ipconfigEVENT_QUEUE_LENGTH (ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 10)

/* Explicit IP task priority and stack size */
#define ipconfigIP_TASK_PRIORITY (configMAX_PRIORITIES - 3)
#define ipconfigIP_TASK_STACK_SIZE_WORDS 512

/* Debug macro to confirm inclusion */
#define DEBUG_IP_CONFIG_USED           1

/* Core network features */
#define ipconfigUSE_NETWORK_EVENT_HOOK 1
#define ipconfigUSE_LLMNR              0
#define ipconfigUSE_DNS                0
#define ipconfigUSE_DHCP               0
#define ipconfigDHCP_REGISTER_HOSTNAME 1
#define ipconfigUSE_CALLBACKS          1
#define ipconfigUSE_TCP                1
#define ipconfigUSE_UDP                1
#define ipconfigUSE_LINKED_RX_MESSAGES 0
#define ipconfigCHECK_IP_QUEUE_SPACE   1
#define ipconfigUSE_IP_TASK            1
#define ipconfigSUPPORT_OUTGOING_PINGS 0

/* Disable zero-copy to avoid driver conflicts */
#define ipconfigZERO_COPY_RX_DRIVER 1
#define ipconfigZERO_COPY_TX_DRIVER 1

/* IP checksum offloading configuration */
#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
#define ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 1

/* DMA descriptor configuration */
#define ipconfigNIC_N_TX_DESC 32
#define ipconfigNIC_N_RX_DESC 32
#define ipconfigIPv4_BACKWARD_COMPATIBLE 1
#define ipconfigUSE_IPv4 1
#define ipconfigUSE_DNS_CACHE 0

/* Optional debug logging */
#define ipconfigHAS_DEBUG_PRINTF 1
#define ipconfigPRINTF(…) xil_printf(VA_ARGS)

#endif /* FREERTOS_IP_CONFIG_H */

but what i get in my console is:

Free RTOS TAsk!
The return Value is 1

why is the ipinit call failing ?

Hi @Reshma , when FreeRTOS_IPInit() returns pdTRUE, it means success.

So you can continue and see for instance if ping works in two directions.

Functions like recv() and send() return one of the following:

  • negative: this is an errno value expressed as a negative number (see projdefs.h)
  • positive: number of bytes sent or received
  • zero: success or nothing received or sent.

By the way, it might be worth start using a newer release of FreeRTOS+TCP from [github](GitHub - FreeRTOS/FreeRTOS-Plus-TCP: FreeRTOS-Plus-TCP library repository. +TCP files only. Submoduled into https://github.com/FreeRTOS/FreeRTOS and various other repos.).

1 Like

Hi,

Thanks for the reply. But iam still wondering why is the print from the vApplicationIPNetworkEventHook , not coming.

iam not able to ping my Zynq Board too..

did you ensure (eg by running a blinky app) that FreeRTOS itself is running? Can you run blinky in parallel to make sure you are not stuck in a fault or something?

In general it is a good idea to build up your system in small pieces instead of everything at once.

I had started two tasks and confirmed they are sending and receiving fine.
do we need to make any other changes in any driver or zynq files ? to select the interface.