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 ?