FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

We have FreeRTOSPlusTCP Server application (developed using FreeRTOS Socket API) is running on NXP LPC1768 and modified FreeRTOSPlusTCPMinimalWindowsSimulator program runs as Client application on Dell Windows 10 Laptop. LAN card of LPC1768 is directly connected using cross-over cable with Laptop Live Tech USB 2.0 LAN Ethernet card. D-Link Router is used only for Internet connection purpose using WiFi mode. An static IP and Port (ip 192. 168.1.211 and port 27754) and MAC address are assigned to LPC1768 by Server application running on it. Static IP address(192.168.1.210) is assigned to LAN card of the Laptop. LPC1768 application has been developed on Eclipse MARS platform using GNU Tools ARM Embedded, 5.3 2016q1 GCC Cross-compiler. FreeRTOSPlusTCPMinimalWindowsSimulator program runs on Visual Studio 2015 environment. We have been expecting Laptop Client application to send data to the waiting Server application ready to receive data on LPC1768. But there is absolutely no data exchange between them. On using cmd NETSTAT –ano command on Laptop we never see any port of LPC1768 with status LISTENING. ARP –a command shows IP address (192.168.1.211) of LPC1768 for few seconds and as soon as FreeRTOSaccept start executing (if fact FreeRTOSaccept just hangs and does not connect with Laptop client application) the IP address disappears from Laptop ARP cache. The advance IP scanner (Free third party utility) always show LPC1768 IP (192.168.1.211) with correct MAC address. We are not able to PING LPC1768 from Laptop. We get message either Request Timed Out or Destination Host Unreachable. We think that NetworkInterface program developed by us for LPC1768 seems to be working. We have explored on many possible options during the last 3 months to solve the connection problem between LPC1768 and Laptop but not successful at all. So as a last resort we are sending this SOS note to the FreeRTOS forum. When we run Adam Dunkell’s UIP webserver application on LPC1768 we can PING LPC1768 from Laptop. Also we are able to connect with 192.168.1.211 from Laptop Chrome web-browser. This eliminates any physical network connection problem between LPC1768 and Laptop. Looks like it may be a problem related to the FreeRTOS TCP-IP Stack. Consulted network engineer to check on our networking arrangements and no problem found in any physical connection related issues. Used Wireshark to monitor ARP and TCP transactions. When we use Adam Dunkell’s UIP Webserver we see TCP & ARP & IP transactions in Wireshark. But we see only gratuitous ARP entries only from 192.168.1.211. Checked Networkinterface.c and lpc17xx_emac.c programs but not able to find problems with them. Tried 3 versions of Networkinterface.c but none of them work as expected. FreeRTOSTCPPlus are sourced from FreeRTOS+TCP Labs Build 160112. Any help and guidance from the forum members will be highly appreciated. The gist of the Server Application code on LPC1768 are as follows. int main( void ) {
UARTInit( 0, 19200 );   
NVIC_SetPriority( UART0_IRQn,29 ); // Display output text/message on COM3 port
sprintf(pBuff,"%sn","WELCOME TO RTOS  PROJECT WORLD:n"); kgprint(pBuff);
/* Create the tasks that use the TCP/IP stack if they have not already been created. */ uint8_t ucMACAddress[ 6 ] = { 0x00,0x07,0x27,0x07,0x19,0x54 };
static const uint8_t ucIPAddress[4] = { 192,168,1,211 };
static const uint8_t ucNetMask[ 4 ] = { 255, 255, 255, 0 }; static const uint8_t ucGatewayAddress[ 4 ] = { 192, 168, 1, 210 };
static const uint8_t ucDNSServerAddress[ 4 ] = { 192, 168, 1, 210 };
    /* Initialise the RTOS's TCP/IP stack.  The tasks(IP-TASK) that use the 
network are created in the vApplicationIPNetworkEventHook() hook function. The hook function is called when the network connects. */ FreeRTOS_IPInit(ucIPAddress,ucNetMask,ucGatewayAddress,ucDNSServerAddress,ucMACAddress ); /* Display the IP address, then create the uIP task. The WEB server runs in this task.*/ xTaskCreate( vuKGTCPTask, “uIP WEBSERVER”, mainBASICUIPWEBSTACKSIZE, NULL, mainUIPTASK_PRIORITY, &xUIPTaskHandle ); /* Start the scheduler so our tasks start executing. */ vTaskStartScheduler(); for( ;; ) { } return 0; } void vApplicationIPNetworkEventHook( eIPCallbackEventt eNetworkEvent ) { static BaseTypet xTasksAlreadyCreated = pdFALSE;
/* Both eNetworkUp and eNetworkDown events can be processed here. */

if( eNetworkEvent == eNetworkUp )
{
    if( xTasksAlreadyCreated == pdFALSE )
    {
    sprintf(pBuff,"%sn","Network UPn"); kgprint(pBuff);
/** For convenience, tasks that use FreeRTOS+TCP can be created here to ensure they are not created before the network is usable.*/
xTaskCreate( vuKGTCP_Send_Receive_Task, "uIP SendReceive", mainBASIC_SndRCv_WEB_STACK_SIZE, NULL, mainUIPSendReceive_TASK_PRIORITY, &xUIPSndRcvTaskHandle );

  xTasksAlreadyCreated = pdTRUE;

                            }
/* The network is up and configured. Print out the configuration */ FreeRTOS_GetAddressConfiguration(&ulIPAddress,&ulNetMask,&ulGatewayAddress,&ulDNSServerAddress );
    /* Convert the IP address to a string then print it out. */
    FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
 sprintf(pBuff, "%s  %sn", "SERVER IP.......:", cBuffer); kgprint(pBuff);

}
} void vuKGTCPSendReceiveTask(void) static struct freertossockaddr xClient, xBindAdress; Sockett xListeningSocket, xConnectedSocket; socklent xSize = sizeof(xClient); xWinProperties_t xWinProps; const BaseType_t xBacklog = 20; //static const TickTypet xReceiveTimeOut = portMAXDELAY; //static const TickTypet xSendTimeOut = portMAXDELAY; static const TickTypet xReceiveTimeOut = pdMSTOTICKS( 20 ); static const TickTypet xSendTimeOut = pdMSTOTICKS(100); BaseType_t xBytesRecceived = 0;

define Buffer_Size 30

static char RcvBuffer[BufferSize]; xListeningSocket = FreeRTOSsocket(FREERTOSAFINET, FREERTOSSOCKSTREAM, FREERTOSIPPROTOTCP); configASSERT(xListeningSocket != FREERTOSINVALIDSOCKET); if (xListeningSocket != FREERTOSINVALIDSOCKET) { sprintf(pBuff, “%sn”, “Server Socket Created Successfully…n”); kgprint(pBuff); } else { sprintf(pBuff, “%sn”, “Failed to Create Server Socket …n”); kgprint(pBuff); //goto ReviveUIPWEBSERVER; } FreeRTOSsetsockopt(xListeningSocket, 0, FREERTOSSORCVTIMEO, &xReceiveTimeOut, sizeof(xReceiveTimeOut)); FreeRTOSsetsockopt(xListeningSocket, 0, FREERTOSSOSNDTIMEO, &xSendTimeOut, sizeof(xSendTimeOut));

if( ipconfigUSETCPWIN == 1 )

/* Fill in the buffer and window sizes that will be used by  the socket. */
xWinProps.lTxBufSize = 4 * ipconfigTCP_MSS;
xWinProps.lTxWinSize = 3;
xWinProps.lRxBufSize = 4 * ipconfigTCP_MSS;
xWinProps.lRxWinSize = 3;

/* Set the window and buffer sizes. */
FreeRTOSsetsockopt( xListeningSocket,0,FREERTOSSOWINPROPERTIES,&xWinProps, sizeof( xWinProps ) );

endif /* ipconfigUSETCPWIN */

xBindAdress.sinaddr = FreeRTOSinetaddrquick( 192,168,1,211); xBindAdress.sinport = FreeRTOShtons( 27754); if (FreeRTOS_bind( xListeningSocket, &xBindAdress, sizeof(xBindAdress) ) == 0) { sprintf(pBuff,”%sn”,”Server Bind AT PORT 27754 Successful….n”);kgprint(pBuff); } else { sprintf(pBuff,”%sn”,”Server Bind Failed….n”);kgprint(pBuff); } if (FreeRTOS_listen(xListeningSocket, xBacklog) == 0) { sprintf(pBuff,”%sn”,”Listening for Client…n”); kgprint(pBuff
} sprintf(pBuff, “%sn”, “Waiting For Accepting From 192.168.1.210 n”); kgprint(pBuff); for (;;) {
xConnectedSocket = FreeRTOS_accept(xListeningSocket, &xClient, &xSize);
configASSERT(xConnectedSocket != FREERTOS_INVALID_SOCKET);


if (FreeRTOS_issocketconnected(xConnectedSocket) == pdTRUE)
{
    sprintf(pBuff, "%sn", "Connected with 192.168.1.210.....n"); kgprint(pBuff);
        sprintf(pBuff, "%sn", "Receiving Data From Client...n"); kgprint(pBuff);
}


xBytesRecceived = FreeRTOS_recv(xConnectedSocket, &RcvBuffer, Buffer_Size, 0);

if (xBytesRecceived > 0)
{
 strcpy(pBuff, RcvBuffer);
sprintf(pBuff, "%sn", "Received Data From PC Client:"); kgprint(pBuff);
}

    vTaskDelay(100);    //Delay for next receive send cycle
}
SocShutdown: /* Initiate graceful shutdown. */ FreeRTOSshutdown( xListeningSocket, FREERTOSSHUTRDWR ); FreeRTOSshutdown( xConnectedSocket, FREERTOSSHUT_RDWR ); vTaskDelay(500 ); //wait for graceful disconnect /* The socket has shut down and is safe to close. */ sprintf(pBuff,”%sn”,”Closing Sockets…..n”); kgprint(pBuff); FreeRTOS_closesocket( xListeningSocket ); FreeRTOS_closesocket( xConnectedSocket ); } void kgprint( const char *str ) { unsigned int i; for( i = 0 ; str[i] !=’’; i++ ) { putch0( str[i] );
 if( str[i] == 'n' )
     {
   putch0( 0x0a );
      putch0( 0x0d );
     }
} return; } The one of the versions of the Networkinteface.c that we use is as follows. /* Standard includes. */

include <stdint.h>

include <stdio.h>

include <stdlib.h>

/* FreeRTOS includes. */

include “FreeRTOS.h”

include “task.h”

include “queue.h”

include “semphr.h”

include “KGlpc17xxemac.h”

//#include “lpc17xx.h” /* FreeRTOS+TCP includes. */

include “FreeRTOS_IP.h”

include “FreeRTOS_Sockets.h”

include “FreeRTOSIPPrivate.h”

include “NetworkBufferManagement.h”

include “KG_NetworkInterface.h”

//#include “uart.h”

if ipconfigETHERNETDRIVERFILTERSFRAMETYPES != 1

#define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer

else

#define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) )

endif

/————————————————————————————-/ static int32t EMACPHYLinkStatus;

ifndef EMACMAXBLOCKTIMEMS

#define EMAC_MAX_BLOCK_TIME_MS  100ul

endif

/* When a packet is ready to be sent, if it cannot be sent immediately then the task performing the transmit will block for niTXBUFFERFREEWAIT milliseconds. It will do this a maximum of niMAXTX_ATTEMPTS before giving up. */

define niTXBUFFERFREEWAIT ( ( TickTypet ) 2UL / portTICKRATEMS )

define niMAXTXATTEMPTS ( 5 )

/* Default the size of the stack used by the EMAC deferred handler task to 4x the size of the stack used by the idle task – but allow this to be overridden in FreeRTOSConfig.h as configMINIMALSTACKSIZE is a user definable constant. */

ifndef configEMACTASKSTACK_SIZE

#define configEMAC_TASK_STACK_SIZE ( 4 * configMINIMAL_STACK_SIZE )

endif

define configMACINTERRUPTPRIORITY 6

/———————————————————–/ /* * A deferred interrupt handler task that processes LPC1768 EMAC interrupts.*/ static void prvEMACHandlerTask( void *pvParameters ); static int32_t KG_GetPhyLinkStatus( void); /* LLMNR multicast address. */ //static const uint8_t llmnr_mac_address[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; static int CAX = 0; static int Init_Cnt = 0; /* MAC address to use. */ extern const uint8_t ucMACAddress[ 6 ]; /* Holds the handle of the task used as a deferred interrupt processor. The handle is used so direct notifications can be sent to the task for all EMAC/DMA related interrupts. / static TaskHandle_t xEMACTaskHandle = NULL; / The queue used to communicate Ethernet events with the IP task. */ extern xQueueHandle xNetworkEventQueue; BaseTypet xNetworkInterfaceInitialise( void ) { //const TickTypet x5_Seconds = 5000UL; UNS_16 i;
if( xEMACTaskHandle == NULL )
{
    Init_Eth:
    if (EMAC_Init() == FALSE) //Try 3 times to Init
    {       
        if (Init_Cnt > 3)
        {
        configASSERT( CAX != 0 );
        return pdFAIL;
        }
        else
        {
            Init_Cnt = Init_Cnt + 1;
            goto Init_Eth;
        }
    }


        if (KG_GetPhyLinkStatus() != 1) //PHY Link - Value 1 means  Link is UP , 0 Link is Down
        {
        configASSERT( CAX != 0 );           
        return pdFAIL;
        }

    /* The handler task is created at the highest possible priority to ensure the interrupt handler can return directly to it. */
    xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle );
    configASSERT( xEMACTaskHandle );


    /* Enable the interrupt and set its priority to the minimum interrupt priority.  */

    /*-------------------------------------------------------------------------------------------------*/

    portENTER_CRITICAL();  
    {
    LPC_EMAC->IntEnable = ( INT_RX_DONE | INT_TX_DONE );
    NVIC_SetPriority( ENET_IRQn, configEMAC_INTERRUPT_PRIORITY );
    NVIC_EnableIRQ( ENET_IRQn );
    }
    portEXIT_CRITICAL();

    /*-------------------------------------------------------------------------------------------------*/
}
return pdPASS;
} /———————————————————–/ BaseTypet xNetworkInterfaceOutput( xNetworkBufferDescriptort * const pxSendNetworkBufferDescriptor, BaseTypet xReleaseAfterSend ) { BaseTypet xReturn = pdFAIL; int32t x; extern void EMACStartTransmitNextBuffer(uint32t ulLength); extern void EMACSetNextPacketToSend(uint8_t * pucBuffer);
if (KG_GetPhyLinkStatus() != 1) //PHY Link - Value 1 means  Link is UP , 0 Link is Down
{
configASSERT(CAX != 0); // Just for Debugging purpose defined this artificial ConfigAssert
return pdFAIL;
}

/* Attempt to obtain access to a Tx buffer. */
for (x = 0; x < niMAX_TX_ATTEMPTS; x++)
{
    if (EMAC_CheckTransmitIndex() == TRUE)
    {
        /* Will the data fit in the Tx buffer? */
        if (pxSendNetworkBufferDescriptor-> xDataLength < ETH_MAX_FLEN) /*_RB_ The size needs to come from FreeRTOSIPConfig.h. */
        {
            /* Assign the buffer to the Tx descriptor that is now known to be free. */
            EMAC_SetNextPacketToSend(pxSendNetworkBufferDescriptor->pucEthernetBuffer);

            /* The EMAC now owns the buffer. */
            pxSendNetworkBufferDescriptor->pucEthernetBuffer = NULL;

            /* Initiate the Tx. */
            EMAC_StartTransmitNextBuffer(pxSendNetworkBufferDescriptor->xDataLength);
            iptraceNETWORK_INTERFACE_TRANSMIT();

            /* The Tx has been initiated. */
            xReturn = pdPASS;
        }
        break;
    }
    else
    {
        vTaskDelay(niTX_BUFFER_FREE_WAIT);
    }
}

/* Finished with the network buffer. */
if (xReleaseAfterSend != pdFALSE) //if Finished with the network buffer then release it
{
    vReleaseNetworkBufferAndDescriptor(pxSendNetworkBufferDescriptor);
}

return xReturn;
} /———————————————————–/ /———————————————————–/ void ENETIRQHandler( void ) { uint32t ulStatusRegister; BaseType_t xHigherPriorityTaskWoken = pdFALSE;
ulStatusRegister    = LPC_EMAC->IntStatus;

/* Clear the interrupts. */

//LPC_EMAC->IntClear    = ulStatusRegister; 
LPC_EMAC->IntClear = 0xFFFF; //?check

/* xHigherPriorityTaskWoken must be initialised to pdFALSE.  If calling xTaskNotifyFromISR() unblocks the handling task, and the priority of
the handling task is higher than the priority of the currently running task, then xHigherPriorityTaskWoken will automatically get set to pdTRUE. */
xHigherPriorityTaskWoken = pdFALSE;

//configASSERT(CAX != 0); //This LINE OF CODE CAUSES program hang so commented out

    /* Clear fatal error conditions.  NOTE:  The driver does not clear all errors, only those actually experienced.  For future reference, range
    errors are not actually errors so can be ignored. */
if( (ulStatusRegister & INT_TX_UNDERRUN ) != 0U )
{
        LPC_EMAC->Command |= CR_TX_RES;
}


    /* Unblock the handling task so the task can perform any processing necessitated by the interrupt.  xHandlingTask is the task's handle, which was obtained
    when the task was created.  The handling task's notification value is bitwise ORed with the interrupt status - ensuring bits that are already
    set are not overwritten. */

    /* Unblock the deferred interrupt handler task if the event was an Rx. */
    if( (ulStatusRegister & INT_RX_DONE ) != 0UL )
    {
        xTaskNotifyFromISR(xEMACTaskHandle, ulStatusRegister, eSetBits, &xHigherPriorityTaskWoken);
        //configASSERT(CAX != 0);  //This line Hangs program  so commented  out
    }


//portEND_SWITCHING_ISR( ulInterruptCause );
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
//configASSERT(CAX != 0);  //this line Hangs program so commented  out
} /———————————————————–/ /———————————————————–/ static void prvEMACHandlerTask( void *pvParameters ) { unsigned char *pucUseBuffer; size_t xBytesReceived; size_t xDataLength; const uint16_t usCRCLength = 4; xNetworkBufferDescriptort *pxNextNetworkBufferDescriptor = NULL; const TickTypet xBlockTime = pdMSTOTICKS(100UL); const UBaseTypet xMinDescriptorsToLeave = 2UL; xIPStackEventt xRxEvent = { eNetworkRxEvent , NULL }; uint32_t ulInterruptStatus; int i; /* This is not included in the header file for some reason. */ //extern uint8_t *EMAC_NextPacketToRead( void );
( void ) pvParameters;

//configASSERT(CAX != 0); // This hangs the program. Do not put as first line of code here

if (KG_GetPhyLinkStatus() != 1) //PHY Link - Value 1 means  Link is UP , 0 Link is Down
{
    configASSERT(CAX != 0);
    //return pdFAIL;
    return;
}

for (;; )
{


    while ((xTaskNotifyWait(0x00, 0xffffffff, &ulInterruptStatus, xBlockTime)) == pdFALSE)


    /* Check whether if At least one packet has been received. */
    if  (EMAC_CheckReceiveIndex() == FALSE) //Not even one packet received
        goto Go_for_next_cycle;

    /* Obtain the length, minus the CRC.  The CRC is four bytes but the length is already minus 1. */
    xBytesReceived = (size_t)EMAC_GetReceiveDataSize() - (usCRCLength - 1U);

    //xBytesReceived  = EMAC_ReadPacket(pucUseBuffer);


    if (xBytesReceived == 0) // No data from the hardware
    {

        goto Go_for_next_cycle;
    }

    //Allocate NetworkBufferDescriptor 

    pxNextNetworkBufferDescriptor = pxGetNetworkBufferWithDescriptor(xBytesReceived, xBlockTime);

    if (pxNextNetworkBufferDescriptor == NULL) //No free buffer available 
    { 
        iptraceETHERNET_RX_EVENT_LOST();
        goto Go_for_next_cycle;
    }


        pxNextNetworkBufferDescriptor->pucEthernetBuffer = EMAC_NextPacketToRead();
        pxNextNetworkBufferDescriptor->xDataLength       = xBytesReceived;

        /* See if the data contained in the received Ethernet frame needs to be processed.  NOTE! It is preferable to do this in
        the interrupt service routine itself, which would remove the need to unblock this task for packets that don't need processing. */
        if (eConsiderFrameForProcessing(pxNextNetworkBufferDescriptor->pucEthernetBuffer) != eProcessBuffer)
            goto Go_for_next_cycle;

        xRxEvent.eEventType = eNetworkRxEvent; /* The event about to be sent to the TCP/IP is an Rx event. */
        xRxEvent.pvData     = (void *)pxNextNetworkBufferDescriptor;

        /* Data was received and stored.  Send a message to the IP task to let it know. */
        if (xQueueSendToBack(xNetworkEventQueue, &xRxEvent, (TickType_t)0) == pdFALSE)
        //if (xSendEventStructToIPTask(&xRxEvent, xBlockTime) == pdFALSE)
        {

            /* The buffer could not be sent to the stack so must be released again. */
            vReleaseNetworkBufferAndDescriptor(pxNextNetworkBufferDescriptor);
            iptraceETHERNET_RX_EVENT_LOST();
            //configASSERT(CAX != 0);
        }
        else
        {
            /* The message was successfully sent to the TCP/IP stack. Call the standard trace macro to log the occurrence. */
            iptraceNETWORK_INTERFACE_RECEIVE();
            //configASSERT(CAX != 0); // Program  comes here 23-Jun-2016
        }

    Go_for_next_cycle:
        /* The Ethernet frame can be dropped, but the Ethernet buffer must be released. */
        vReleaseNetworkBufferAndDescriptor(pxNextNetworkBufferDescriptor);
        pxNextNetworkBufferDescriptor = NULL;
        /* Release the frame. */
        EMAC_UpdateRxConsumeIndex();
        //configASSERT(CAX != 0); //Program  comes here 22-Jun-2016

}
} static int32t KGGetPhyLinkStatus( void) { static uint32t ulPHYState; TickTypet xStartTime = xTaskGetTickCount(); TickTypet xEndTime; const TickTypet xShortTime = pdMSTOTICKS( 100UL ); const TickType_t xMaxTime = 10000UL;
// Input Parameter ulPHYState values can be 
//  - EMC_PHY_STAT_LINK     to know MAC PHY Link Status
//  - EMC_PHY_STAT_SPEED    to know Speed Status
//  - EMC_PHY_STAT_DUP      to know Duplex Status 
//  - Above Definitions are in KG_lpc17xx_emac.h

ulPHYState = EMAC_PHY_STAT_LINK; 
EMAC_PHYLinkStatus = 0;
for( ;; )
{
        xEndTime = xTaskGetTickCount();
        if( ( xEndTime - xStartTime ) > xMaxTime )
        {
        /* Wated for xMaxTime, return. */
        configASSERT( CAX != 0 );   
        //return pdFAIL;
        break;
        }

        EMAC_PHYLinkStatus = EMAC_CheckPHYStatus(ulPHYState); // Value 1 - Link is UP , 0 Link is Down
        if (EMAC_PHYLinkStatus == 1) //PHY Link is UP
        {       
        break;
        }

        vTaskDelay( xShortTime); //Wait for PHY Link to be UP
    }


    return (EMAC_PHYLinkStatus);
} The lpc17xx_emac.c used is as follows. /* This driver was modified by Kamlesh J Gandhi on 7-May-2016 */

include <string.h>

include “KGlpc17xxemac.h”

include “uip-conf.h”

include “uipopt.h”

define 10MBIT 1

//Rx descriptor Data array – Must be 8-Byte alligned //static volatile RXDesc RxDesc[ NUMRXFRAG]; //static volatile attribute ((aligned (8))) RXStat RxStat[NUMRXFRAG]; //static volatile RXStat RxStat[ NUMRXFRAG ]; //Tx descriptor Data array //static volatile TXDesc TxDesc[ NUMTXFRAG ]; //static volatile TXStat TxStat[ NUMTXFRAG ]; static unsigned int TxDescIndex = 0; //Private Functions ———————————————————- static void rxdescrinit( void ); static void txdescrinit( void ); static void writePHY( UNS32 PhyReg, UNS32 Value ); static UNS16 readPHY( UNS8 PhyReg ); //#if 0 /* //THIS CODE WAS REMOVED BY RB AS THE BUFFERS ARE MANUALLY PLACED IN THE AHB RAM //BY THE APPLICATION CODE. // EMAC local DMA buffers // Rx buffer data static uint32t rxbuf[EMACNUMRXFRAG][ETHMAXFLEN>>2] = { { 0 }, { 0 } }; // Tx buffer data static uint32t txbuf[EMACNUMTXFRAG][ETHMAXFLEN>>2] = { { 0 }, { 0 } }; uint32t rxbuf[NUMRXFRAG][ETHMAXFLEN>>2]; uint32t txbuf[NUMTXFRAG][ETHMAXFLEN>>2];

endif // 0

*/ //static void setEmacAddr(uint8t abStationAddr[]); //static int32t emacCRCCalc(uint8t framenofcs[], int32t framelen); /————————— write_PHY ————————————-/ static void writePHY (UNS32 PhyReg, UNS_32 Value) { unsigned int tout; LPCEMAC->MADR = DP83848CDEFADR | PhyReg; LPCEMAC->MWTD = Value; /* Wait utill operation completed */ tout = 0; for( tout = 0; tout < MII_WR_TOUT; tout++ ) { if ((LPC_EMAC->MIND & MIND_BUSY) == 0) { break; } } } /————————— read_PHY ————————————-/ static UNS16 readPHY (UNS8 PhyReg) { UNS32 tout; LPCEMAC->MADR = DP83848CDEFADR | PhyReg; LPCEMAC->MCMD = MCMD_READ; /* Wait until operation completed */ tout = 0; for( tout = 0; tout < MII_RD_TOUT; tout++ ) { if ((LPC_EMAC->MIND & MIND_BUSY) == 0) { break; } } LPC_EMAC->MCMD = 0; return (LPC_EMAC->MRDD); } /————————— EMAC_ReadPacket ———————————/ UNS32 EMACReadPacket(void * pPacket) { UNS32 Index = LPCEMAC->RxConsumeIndex; UNS_32 size; if(Index == LPC_EMAC->RxProduceIndex) { return(0); } size = (RXSTATINFO(Index) & 0x7ff)+1; if (size > ETHFRAGSIZE) size = ETHFRAGSIZE; memcpy(pPacket,(unsigned int *)RX_BUF(Index),size); if(++Index > LPCEMAC->RxDescriptorNumber) { Index = 0; } LPCEMAC->RxConsumeIndex = Index; return(size); } /————————— EMAC_SendPacket ———————————/ BOOL32 EMACSendPacket(void *pPacket, UNS_32 size) { UNS_32 Index; UNS_32 IndexNext = LPC_EMAC->TxProduceIndex + 1; if(size == 0) { return(TRUE); } if(IndexNext > LPC_EMAC->TxDescriptorNumber) { IndexNext = 0; } if(IndexNext == LPCEMAC->TxConsumeIndex) { return(FALSE); } Index = LPCEMAC->TxProduceIndex; if (size > ETHFRAGSIZE) size = ETHFRAGSIZE; memcpy((unsigned int *)TX_BUF(Index),pPacket,size); TX_DESC_CTRL(Index) &= ~0x7ff; TX_DESC_CTRL(Index) |= (size – 1) & 0x7ff; LPC_EMAC->TxProduceIndex = IndexNext; return(TRUE); } /————————— rx_descr_init ———————————/ static void rxdescrinit (void) { UNS_32 i; for (i = 0; i < NUMRXFRAG; i++ ) { RXDESCPACKET(i) = RXBUF(i); RXDESCCTRL(i) = RCTRLINT | (ETHFRAGSIZE-1); RXSTATINFO(i) = 0; RXSTATHASHCRC(i) = 0; } /* Set EMAC Receive Descriptor Registers. */ LPC_EMAC->RxDescriptor = RX_DESC_BASE; LPC_EMAC->RxStatus = RX_STAT_BASE; LPC_EMAC->RxDescriptorNumber = NUM_RX_FRAG-1; /* Rx Descriptors Point to 0 */ LPC_EMAC->RxConsumeIndex = 0; } /————————— tx_descr_init ———————————/ static void txdescrinit (void) { UNS_32 i; for (i = 0; i < NUMTXFRAG; i++) { TXDESCPACKET(i) = TXBUF(i); TXDESCCTRL(i) = (1UL<<31) | (1UL<<30) | (1UL<<29) | (1UL<<28) | (1UL<<26) | (ETHFRAGSIZE-1); TXSTAT_INFO(i) = 0; } /* Set EMAC Transmit Descriptor Registers. */ LPC_EMAC->TxDescriptor = TX_DESC_BASE; LPC_EMAC->TxStatus = TX_STAT_BASE; LPC_EMAC->TxDescriptorNumber = NUM_TX_FRAG-1; /* Tx Descriptors Point to 0 / LPC_EMAC->TxProduceIndex = 0; } / The following macro definitions may be used to select the speed of the physical link: 10MBIT – connect at 10 MBit only 100MBIT – connect at 100 MBit only By default an autonegotiation of the link speed is used. This may take longer to connect, but it works for 10MBit and 100MBit physical links. */ /* Local Function Prototypes */ /————————— EMAC_Init ———————————/ BOOL32 EMACInit(void) { /* Initialize the EMAC ethernet controller. */ UNS_32 regv,tout,id1,id2; /* Power Up the EMAC controller. */ LPC_SC->PCONP |= 0x40000000; /* Enable P1 Ethernet Pins. / LPC_PINCON->PINSEL2 = 0x50150105; LPC_PINCON->PINSEL3 = (LPC_PINCON->PINSEL3 & ~0x0000000F) | 0x00000005; //LPC_PINCON->PINSEL3 = (LPC_PINCON->PINSEL3 & ~0x0000000F);// | 0x00000005; / Reset all EMAC internal modules. */ LPC_EMAC->MAC1 = MAC1_RES_TX | MAC1_RES_MCS_TX | MAC1_RES_RX | MAC1_RES_MCS_RX | MAC1_SIM_RES | MAC1_SOFT_RES; LPCEMAC->Command = CRREGRES | CRTXRES | CRRX_RES; // 0011 1000 /* A short delay after reset. */ for( tout = 100; tout; tout– ); /* Initialize MAC control registers. */ LPC_EMAC->MAC1 = MAC1_PASS_ALL; LPC_EMAC->MAC2 = MAC2_CRC_EN | MAC2_PAD_EN; LPC_EMAC->MAXF = ETH_MAX_FLEN; LPC_EMAC->CLRT = CLRT_DEF; LPC_EMAC->IPGR = IPGR_DEF; /* PCLK=18MHz, clock select=6, MDC=18/6=3MHz / / Enable Reduced MII interface. */
LPC_EMAC->MCFG = MCFG_CLK_DIV20 | MCFG_RES_MII;// 1000 0000 0001 1000:::::::::::::::
//LPCEMAC->MCFG = MCFGCLK_DIV20; for (tout = 100; tout; tout–); LPCEMAC->MCFG = MCFGCLK_DIV20; /* Enable Reduced MII interface. */ LPC_EMAC->Command = CR_RMII | CR_PASS_RUNT_FRM | CR_PASS_RX_FILT;// 0010 1100 0000 /* Reset Reduced MII Logic. */ LPC_EMAC->SUPP = SUPP_RES_RMII | SUPP_SPEED; for (tout = 100; tout; tout–); LPC_EMAC->SUPP = SUPP_SPEED; /* Put the PHY in reset mode */ write_PHY (PHY_REG_BMCR, 0x8000); for( tout = 1000; tout; tout– ); /* Wait for hardware reset to end. */ for (tout = 0; tout < 0x100000; tout++) { regv = read_PHY (PHY_REG_BMCR);

if defined (KEILBOARDMCB17XX)

if (!(regv & 0x8000))

else

#error "No board!"

endif

{
  /* Reset complete */
  break;
}
} if( tout >= 0x100000) return FALSE; /* reset failed */ /* Check if this is a DP83848C PHY. */ id1 = read_PHY (PHY_REG_IDR1); id2 = read_PHY (PHY_REG_IDR2);

if defined (KEILBOARDMCB17XX)

  if (((id1 << 16) | (id2 & 0xFFF0)) != DP83848C_ID)

else

#error "No board"

endif

return FALSE;

/* Configure the PHY device */
  /* Configure the PHY device */

if defined (10MBIT)

  /* Connect at 10MBit */
  write_PHY (PHY_REG_BMCR, PHY_FULLD_10M);

elif defined (100MBIT)

  /* Connect at 100MBit */
  write_PHY (PHY_REG_BMCR, PHY_FULLD_100M);

else

  /* Use autonegotiation about the link speed. */
  write_PHY (PHY_REG_BMCR, PHY_AUTO_NEG);
  /* Wait to complete Auto_Negotiation. */
  for (tout = 0; tout < 0x100000; tout++) {
     regv = read_PHY (PHY_REG_BMSR);
     if (regv & 0x0020) {
        /* Autonegotiation Complete. */
        break;
     }
  }

endif

if (tout >= 0x100000)
    return FALSE; // auto_neg failed
/* Check the link status. */ for (tout = 0; tout < 0x10000; tout++) {

if defined (KEILBOARDMCB17XX)

regv = read_PHY (PHY_REG_STS);
if (regv & 0x0001)

else

#error "No board"

endif

{       
  /* Link is on. */
  break;
}
}//FOR LOOP END if( tout >= 0x10000 ) return FALSE; /* Configure Full/Half Duplex mode. */

if defined (KEILBOARDMCB17XX)

if (regv & 0x0004)

else

#error "No board"

endif

{   
/* Full duplex is enabled. */
LPC_EMAC->MAC2    |= MAC2_FULL_DUP;
LPC_EMAC->Command |= CR_FULL_DUP;
LPC_EMAC->IPGT     = IPGT_FULL_DUP;
} // else { /* Half duplex mode. */ LPC_EMAC->IPGT = IPGT_HALF_DUP; } /* Configure 100MBit/10MBit mode. */

if defined (KEILBOARDMCB17XX)

if (regv & 0x0002) {

else

#error "No baord"

endif

/* 10MBit mode. */
LPC_EMAC->SUPP = 0;
} else{ /* 100MBit mode. */ LPC_EMAC->SUPP = SUPP_SPEED; } /* Set the Ethernet MAC Address registers */ // MAC_SA0 = (MYMAC_6 << 8) | MYMAC_5; // MAC_SA1 = (MYMAC_4 << 8) | MYMAC_3; // MAC_SA2 = (MYMAC_2 << 8) | MYMAC_1; LPC_EMAC->SA0 = (UIP_ETHADDR1<<8) | UIP_ETHADDR0; LPC_EMAC->SA1 = (UIP_ETHADDR3<<8) | UIP_ETHADDR2; LPC_EMAC->SA2 = (UIP_ETHADDR5<<8) | UIP_ETHADDR4; /* Initialize Tx and Rx DMA Descriptors */ rx_descr_init (); tx_descr_init (); /* Receive Broadcast and Perfect Match Packets */ LPC_EMAC->RxFilterCtrl = RFC_BCAST_EN | RFC_PERFECT_EN; /* Enable EMAC interrupts. */ //EMAC->IntEnable = INT_RX_DONE | INT_TX_DONE; /* Reset all interrupts */ //EMAC->IntClear = 0xFFFF; /* Enable receive and transmit mode of MAC Ethernet core */ LPC_EMAC->Command |= (CR_RX_EN | CR_TX_EN); LPC_EMAC->MAC1 |= MAC1_REC_EN; /* Configure VIC for EMAC interrupt. */ //VICVectAddrxx = (UNS_32)xx; return TRUE; } /*********************************************************************//** * @brief Check specified PHY status in EMAC peripheral * @param[in] ulPHYState Specified PHY Status Type, should be: * – EMACPHYSTATLINK: Link Status * – EMACPHYSTATSPEED: Speed Status * – EMACPHYSTATDUP: Duplex Status * @return Status of specified PHY status (0 or 1). * (-1) if error. * * Note: * For EMACPHYSTATLINK, return value: * – 0: Link Down * – 1: Link Up * For EMACPHYSTATSPEED, return value: * – 0: 10Mbps * – 1: 100Mbps * For EMACPHYSTATDUP, return value: * – 0: Half-Duplex * – 1: Full-Duplex **********************************************************************/ int32t EMACCheckPHYStatus (uint32t ulPHYState) { int32t regv, tmp; //#ifdef MCBLPC1768 regv = readPHY (PHYREGSTS); switch(ulPHYState) { case EMACPHYSTATLINK: tmp = (regv & EMACPHYSRLINK) ? 1 : 0; break; case EMACPHYSTATSPEED: tmp = (regv & EMACPHYSRSPEED) ? 0 : 1; break; case EMACPHYSTATDUP: tmp = (regv & EMACPHYSR_DUP) ? 1 : 0; break; /*

elif defined(IARLPC1768)

//Use IAR_LPC_1768 board:
//FSZ8721BL doesn't have Status Register
//so we read Basic Mode Status Register (0x01h) instead
//

regv = read_PHY (EMAC_PHY_REG_BMSR);
switch(ulPHYState){
case EMAC_PHY_STAT_LINK:
    tmp = (regv & EMAC_PHY_BMSR_LINK_STATUS) ? 1 : 0;
    break;
case EMAC_PHY_STAT_SPEED:
    tmp = (regv & EMAC_PHY_SR_100_SPEED) ? 1 : 0;
    break;
case EMAC_PHY_STAT_DUP:
    tmp = (regv & EMAC_PHY_SR_FULL_DUP) ? 1 : 0;
    break;

endif

*/ default: tmp = -1; break; } return (tmp); } /* Addded by Kamlesh J Gandhi on 7-May-2016———————————– */ uint8t *EMACNextPacketToSend( void ) { //return ( uint8t * ) TxDesc[ LPCEMAC->TxProduceIndex ].Packet; return ( uint8t * ) TXDESCPACKET(LPC_EMAC->TxProduceIndex ); } uint8t *EMACNextPacketToRead( void ) { //return ( uint8t * ) RxDesc[ LPCEMAC->RxConsumeIndex ].Packet; return ( uint8t * ) RXDESCPACKET (LPC_EMAC->RxConsumeIndex ); } void EMACStartTransmitNextBuffer( uint32t ulLength ) { // Get current Tx produce index uint32t idx = LPCEMAC->TxProduceIndex;
//Tx_Desc[idx].Ctrl = (ulLength - 1) | (EMAC_TCTRL_INT | EMAC_TCTRL_LAST);
//Tx_Desc[idx].Ctrl = (ulLength - 1) | (TCTRL_INT | TCTRL_LAST);      //Modified by Kamlesh J Gandhi
TX_DESC_CTRL(idx) = (ulLength - 1) | (TCTRL_INT | TCTRL_LAST);      //Modified by Kamlesh J Gandhi

//if (++idx == EMAC_NUM_TX_FRAG) idx = 0;
if (++idx == NUM_TX_FRAG) idx = 0;                                  //Modified by Kamlesh J Gandhi
LPC_EMAC->TxProduceIndex = idx;
} /*********************************************************************//** 307 * @brief EMAC_SetNextPacketToSend 308 * @param[in] pucBuffer 309 * @return None 310 ***********************************************************************/ void EMACSetNextPacketToSend( uint8t * pucBuffer ) { //The old packet is now finished with and can be freed. //vEthernetBufferRelease( ( void * ) TxDesc[ TxDescIndex ].Packet ); //vReleaseNetworkBuffer( ( void * ) TxDesc[ TxDescIndex ].Packet ); //Modified by Kamlesh J Gandhi on 11-May-2016 vReleaseNetworkBuffer( ( void * ) TXDESCPACKET (TxDescIndex )); //Modified by Kamlesh J Gandhi on 11-May-2016
//Assign the new packet to the descriptor. 
//Tx_Desc[ TxDescIndex ].Packet = ( uint32_t ) pucBuffer;
TX_DESC_PACKET (TxDescIndex ) = ( uint32_t ) pucBuffer;
} /*********************************************************************//** * @brief Check whether if the current RxConsumeIndex is not equal to the * current RxProduceIndex. * @param[in] None * @return TRUE if they’re not equal, otherwise return FALSE * * Note: In case the RxConsumeIndex is not equal to the RxProduceIndex, * it means there’re available data has been received. They should be read * out and released the Receive Data Buffer by updating the RxConsumeIndex value. **********************************************************************/ BOOL32 EMACCheckReceiveIndex(void) { if (LPCEMAC->RxConsumeIndex != LPCEMAC->RxProduceIndex) { return TRUE; } else { return FALSE; } } /*********************************************************************//** * @brief Check whether if the current TxProduceIndex is not equal to the * current RxProduceIndex – 1. * @param[in] None * @return TRUE if they’re not equal, otherwise return FALSE * * Note: In case the RxConsumeIndex is equal to the RxProduceIndex – 1, * it means the transmit buffer is available and data can be written to transmit * buffer to be sent. **********************************************************************/ BOOL32 EMACCheckTransmitIndex(void) { uint32t tmp = LPCEMAC->TxConsumeIndex; if (LPCEMAC->TxProduceIndex == ( tmp – 1 )) { return FALSE; } //else if( ( tmp == 0 ) && ( LPCEMAC->TxProduceIndex == ( EMACNUMTXFRAG – 1 ) ) ) else if( ( tmp == 0 ) && ( LPCEMAC->TxProduceIndex == ( NUMTXFRAG – 1 ) ) ) //Modified by Kamlesh J Gandhi { return FALSE; } else { return TRUE; } } /*********************************************************************//** * @brief Get size of current Received data in received buffer (due to * RxConsumeIndex) * @param[in] None * @return Size of received data **********************************************************************/ uint32t EMACGetReceiveDataSize(void) { uint32t idx; idx =LPCEMAC->RxConsumeIndex; //return ((RxStat[idx].Info) & EMACRINFOSIZE); //return ((RxStat[idx].Info) & RINFOSIZE); //Kamlesh J Gandhi modified on 7-May-2016 return ((RXSTATINFO(idx)) & RINFOSIZE); //Kamlesh J Gandhi modified on 15-May-2016 } /*********************************************************************//** * @brief Increase the RxConsumeIndex (after reading the Receive buffer * to release the Receive buffer) and wrap-around the index if * it reaches the maximum Receive Number * @param[in] None * @return None **********************************************************************/ void EMACUpdateRxConsumeIndex(void) { // Get current Rx consume index uint32t idx = LPC_EMAC->RxConsumeIndex;
//Release frame from EMAC buffer 
//if (++idx == EMAC_NUM_RX_FRAG) idx = 0;
if (++idx == NUM_RX_FRAG) idx = 0;                  //Modified by Kamlesh J Gandhi
LPC_EMAC->RxConsumeIndex = idx;
} /———————————-Kamlesh J Gandhi –End of file —————————/

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

There is way too much here to go over in one go, and I’m confused trying to understand it all, so lets start with the basics and work from there.
We have FreeRTOSPlusTCP Server application (developed using FreeRTOS Socket API) is running on NXP LPC1768
Ok – there is a +TCP server running on the LPC1768, lets start there. Are the TCP basics working on the LPC1768? For example, if you configure the most simple case as follows:
  • Use a static IP address that is compatible with the IP address used on your Windows machine. So configUSEDHCP is set to 0, and the static IP address is passed into FreeRTOSIPInit().
  • Use a point to point cable to connect directly between the LPC1768 and the Windows machine.
Are you able to establish an Ethernet link between the LPC1768 and the Windows machine – if so vApplicationNetworkEventHook() will be called with its eNetworkEvent parameter set to eNetworkUp. If an Ethernet link is established, and the network event hook is being called, are you then able to ping the LPC1768 from the Windows machine? If the basics are working as above on the LPC1768 we look at the basics on the Windows machine.

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

The output screen on com3 port terminal utility is as follows. WELCOME TO RTOS PROJECT WORLD: Network UP SERVER IP…….: 192.168.1.211 SERVER NET MASK : 255.255.255.0 GATEWAY IP……: 192.168.1.210 DNS IP…….. .: 192.168.1.210 FreeRTOSPlusTCP Server Task Created Succesfully uIP SendReceive R 9 257 4 IDLE R 0 70 2 IP-task B 14 247 1 EMAC B 15 281 3 Server Socket Created Successfully… Server Bind AT PORT 27754 Successful…. Listening for Client… SERVER IP…….: 192.168.1.211 Waiting For Accepting From 192.168.1.210 KG Assert called : ../FreeRTOSLibrary/Source/portable/MemMang/heap4.c : 316 :(null) So above ensures that the basic setup are working fine.

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

Waiting For Accepting From 192.168.1.210
What is happening here? That looks like it is accepting a connection from the gateway – is the Windows machine you are using also the gateway?
KG Assert called : ../FreeRTOSLibrary/Source/portable/MemMang/heap4.c : 316 :(null)
What is the cause of this assert()? Is it just a call to pvPortMalloc() failing? If so, is the allocation failure handled correctly? Is you assert() function continuing even after an assert() failure? If you start the LPC1768 board WITHOUT the software also running on the Windows machine (so the Windows machine does not try to connect to the LPC1768 board) do you get a reply when pinging 192.168.1.210? On the assumption the above two points are not unhandled errors, lets look at the Windows machine side now too. First, configure the +TCP stack running in the Windows simulator to also use a static IP address that is compatible with your Windows 10’s own IP address. It looks like this should be of the form 192.168.1.nnn. When you build and run the application on the Windows 10 machine you should get output generated that looks something like that below. Can you please post the output you obtain.
1. rpcap://DeviceNPF_{4CEE9D93-A575-4804-99F1-411D471D197A}
    (Network adapter 'Microsoft' on local host)

2. rpcap://DeviceNPF_{6BDB4A41-8C23-4D40-8D12-F759DFFCAE62}
    (Network adapter 'Microsoft' on local host)

3. rpcap://DeviceNPF_{588F4369-4B0B-4EDC-8F93-02DD93A16037}
    (Network adapter 'Microsoft' on local host)

4. rpcap://DeviceNPF_{5890B99C-BDBD-4F35-88E8-795FAD10ADED}
    (Network adapter 'Intel(R) 82579LM Gigabit Network Connection' on 
local host)

The interface that will be opened is set by
"configNETWORK_INTERFACE_TO_USE" which should be defined in FreeRTOSConfig.h
Attempting to open interface number 4.

36 1389 [IP-task] IP Address: 10.134.134.72
37 1389 [IP-task] Subnet Mask: 255.255.0.0
38 1389 [IP-task] Gateway Address: 10.134.134.3
39 1389 [IP-task] DNS Server Address: 10.134.134.16

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

  1. /FreeRTOSLibrary/Source/portable/MemMang/heap4.c : 316 :(null) I am trying to find out cause of this heap_4.c error
    1. My assert function given in Main.c program continue after the assert as I want to see maxium errors in one go.
    2. I always get reply ping on 192.168.1.210 on Laptop
    3. Attaching modified Simulator code for your reference. The network interface is selected propery (no.2 ). The IP address in Main.c (192.168.1.210) of simulator is compatible with LPC1768 (192.168.1.211). I can attach entire project file if required.
    4. The output on Laptop of Simulator is as follows.
    IP Address: 192.168.1.210 Subnet Mask: 255.255.255.0 Gateway IP Address: 192.168.1.210 DNS server IP Address: 192.168.1.210
  2. rpcap://DeviceNPF_{1E29AB5F-4CD3-47C6-AA91-06E1DE72600B} (Network adapter ‘Microsoft’ on local host)
  3. rpcap://DeviceNPF_{84EE29AE-1209-4134-8FEC-B27D3115B6D8} (Network adapter ‘Realtek USB NIC’ on local host)
  4. rpcap://DeviceNPF_{E0906190-76BB-4154-98AD-4F0BA643AD49} (Network adapter ‘Microsoft’ on local host)
The interface that will be opened is set by “configNETWORKINTERFACETO_USE” which should be defined in FreeRTOSConfig.h Attempting to open interface number 2. 0 90 [IP-task] IP Address: 192.168.1.210 1 90 [IP-task] Subnet Mask: 255.255.255.0 2 90 [IP-task] Gateway Address: 192.168.1.210 3 90 [IP-task] DNS Server Address: 192.168.1.210 Let me know if you require any additional information. Thanks for the prompt response.

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

Waiting For Accepting From 192.168.1.210 LPC1768 hangs here and does not get any data from Laptop Client Simulator Program. Yes. I am using Laptop Window machine as a gateway.

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

  1. /FreeRTOSLibrary/Source/portable/MemMang/heap4.c : 316 :(null) I am trying to find out cause of this heap_4.c error
Most asserts are fatal errors – you cannot ignore them. A memory allocation failure is not a fatal error if it is handled – and in the TCP/IP stack, if using bufferallocation_2.c, then it could be that you see many memory allocation failures that are handled correctly by the TCP/IP stack itself IF the assert is occurring from pvPortMalloc() being called inside the stack.
  1. I always get reply ping on 192.168.1.210 on Laptop
Do you mean you can ping the FreeRTOS+TCP code that is running on the laptop and get a reply? Where are you pinging it from (it should be possible to ping it from a DOS prompt on the same laptop)?
  1. Attaching modified Simulator code for your reference. The network interface is selected propery (no.2 ). The IP address in Main.c (192.168.1.210) of simulator is compatible with LPC1768 (192.168.1.211). I can attach entire project file if required.
No, please don’t, I’m happy to provide assistance through the forum but I’m not going to start working on your project.
  1. The output on Laptop of Simulator is as follows.
IP Address: 192.168.1.210 Subnet Mask: 255.255.255.0 Gateway IP Address: 192.168.1.210 DNS server IP Address: 192.168.1.210 1.
rpcap://DeviceNPF_{1E29AB5F-4CD3-47C6-AA91-06E1DE72600B}
(Network adapter 'Microsoft' on local host)
2.
rpcap://DeviceNPF_{84EE29AE-1209-4134-8FEC-B27D3115B6D8}
(Network adapter 'Realtek USB NIC' on local host)
3.
rpcap://DeviceNPF_{E0906190-76BB-4154-98AD-4F0BA643AD49}
(Network adapter 'Microsoft' on local host)
The interface that will be opened is set by “configNETWORKINTERFACETO_USE” which should be defined in FreeRTOSConfig.h Attempting to open interface number 2. 0 90 [IP-task] IP Address: 192.168.1.210 1 90 [IP-task] Subnet Mask: 255.255.255.0 2 90 [IP-task] Gateway Address: 192.168.1.210 3 90 [IP-task] DNS Server Address: 192.168.1.210
If FreeRTOS+TCP is assigned an IP address of 192.168.1.210 then it looks like you do not have the gateway or DNS servers configured correctly as, presumably, you have not implemented those in your FreeRTOS application (therefore they cannot have the same IP address). What is the IP address of the Windows 10 laptop itself, rather than the FreeRTOS+TCP code running on the laptop which should have a different IP address.

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

“I always get reply ping on 192.168.1.210 on Laptop Do you mean you can ping the FreeRTOS+TCP code that is running on the laptop and get a reply? Where are you pinging it from (it should be possible to ping it from a DOS prompt on the same laptop)?” No. I am not getting ping reply once simulator application runs on Laptop. I use Laptop cmd (MS-Dos) or PowerShell to ping either LPC1768 or 192.168.1.210 (Lancard of PC). The ipconfig /all response of Laptop is as follows. C:Windowssystem32>ipconfig /all Windows IP Configuration Host Name . . . . . . . . . . . . : KG-DELL-LAPTOP Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No Wireless LAN adapter Local Area Connection* 2: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter Physical Address. . . . . . . . . : 5C-E0-C5-37-2A-54 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Wireless LAN adapter KG-WIFI-1: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 7265 Physical Address. . . . . . . . . : 5C-E0-C5-37-2A-53 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IPv4 Address. . . . . . . . . . . : 192.168.1.33(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : 24 June 2016 16:01:41 Lease Expires . . . . . . . . . . : 25 June 2016 06:22:45 Default Gateway . . . . . . . . . : 192.168.1.1 DHCP Server . . . . . . . . . . . : 192.168.1.1 DNS Servers . . . . . . . . . . . : 192.168.1.1 NetBIOS over Tcpip. . . . . . . . : Enabled Ethernet adapter KG-ETHERNET: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Realtek USB FE Family Controller Physical Address. . . . . . . . . : 00-E0-4C-36-10-1C DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::c9a7:d966:7420:365c%15(Preferred) Autoconfiguration IPv4 Address. . : 169.254.54.92(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.0.0 IPv4 Address. . . . . . . . . . . : 192.168.1.210(Duplicate) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 0.0.0.0 DHCPv6 IAID . . . . . . . . . . . : 318824524 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1E-F6-6D-6E-00-E0-4C-36-10-1C DNS Servers . . . . . . . . . . . : 192.168.1.210 NetBIOS over Tcpip. . . . . . . . : Enabled Ethernet adapter Bluetooth Network Connection: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network) Physical Address. . . . . . . . . : 5C-E0-C5-37-2A-57 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes C:Windowssystem32> “If FreeRTOS+TCP is assigned an IP address of 192.168.1.210 then it looks like you do not have the gateway or DNS servers configured correctly as, presumably, you have not implemented those in your FreeRTOS application (therefore they cannot have the same IP address).” Since there is direct cross-over cable connection between Laptop and LPC1768 do the DNS, Gateway carry any importance ? I got heap_4.c error today only and will remove it by checking NetworkInterface.c code.

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

No. I am not getting ping reply once simulator application runs on Laptop. I use Laptop cmd (MS-Dos) or PowerShell to ping either LPC1768 or 192.168.1.210 (Lancard of PC).
So you can ping the +TCP code running on the LPC, but you cannot ping the +TCP code running on the Windows machine – which would make me think your first problem is on the PC, not the LPC. More comments inline below:
Ethernet adapter KG-ETHERNET: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Realtek USB FE Family Controller Physical Address. . . . . . . . . : 00-E0-4C-36-10-1C DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::c9a7:d966:7420:365c%15(Preferred) Autoconfiguration IPv4 Address. . : 169.254.54.92(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.0.0 IPv4 Address. . . . . . . . . . . : 192.168.1.210(Duplicate) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 0.0.0.0 DHCPv6 IAID . . . . . . . . . . . : 318824524 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1E-F6-6D-6E-00-E0-4C-36-10-1C DNS Servers . . . . . . . . . . . : 192.168.1.210 NetBIOS over Tcpip. . . . . . . . : Enabled
This adapter is shown as connected, so is presumably the adapter you have the cross over cable connected to. However, it seems to have the same IP address as the +TCP code running the same PC – and even seems to show this as it has “(Duplicate)” written next to the IP address. That is definitely a problem and with that configuration I would not expect it to work. You need to use a different IP address to the one already assigned to the PC – and have an understanding of the network topology you are creating. Please refer to the “Hardware Setup” section at the top of this page: http://www.freertos.org/FreeRTOS-Plus/FreeRTOSPlusTCP/examplesFreeRTOSsimulator.html – you are creating a new network interface using FreeRTOS+TCP which has its own [virtual] MAC address and its own IP address – not using the MAC and IP address assigned to the laptop.

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

Once I see 192.168.1.211 port 27754 as LISTENING status on Laptop(netstat -ano command on cmd) then rest of the thing should work. I have added LPC1768 device ip and mac address in my Norton antivirus so it is not causing problem. Even by disabling Norton Firewall and Protection the Server program on LPC1768 does not get connected to Laptop.

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

Thanks. Will try Simulator on Laptop with different ip address (other than 192.168.1.210) and change mac address to match with that of Laptop and update you shortly.

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

I did change the MAC address configMACADDR0/5 to 00-E0-4C-36-10-1C for the Simulator Laptop program and now it is the same MAC address of LAN card (KG-ETHERNET in cmd ) of Laptop (LAN card ip 192.168.1.210). The configECHOSERVERADDR0/3 is set to 192.168.1.211 (that of LPC1768) The configIPADDR0/3 is set to 192.168.1.215 (different than LAN card ip as suggested by you). Gateway IP address and DNS ip address on Laptop LAN card are set to 192.168.1.1 & 192.168.1.210 respectively. Same address are mentioned forFreeRTOS_IPInit on LPC1768 FreeRTOSPlusTCP Server Application. As mentioned earlier LPC1768 is directly connected via cross-over cable with Laptop LAN card. The output of RTOSDemo simulator is as follows. It does accept any interface number othan than 2. I tried interface number 4 for wired network [configNETWORKINTERFACETO_USE] but the program does not accept it. IP Address: 192.168.1.215 Subnet Mask: 255.255.255.0 Gateway IP Address: 192.168.1.1 DNS server IP Address: 192.168.1.210
  1. rpcap://DeviceNPF_{1E29AB5F-4CD3-47C6-AA91-06E1DE72600B} (Network adapter ‘Microsoft’ on local host)
  2. rpcap://DeviceNPF_{84EE29AE-1209-4134-8FEC-B27D3115B6D8} (Network adapter ‘Realtek USB NIC’ on local host)
  3. rpcap://DeviceNPF_{E0906190-76BB-4154-98AD-4F0BA643AD49} (Network adapter ‘Microsoft’ on local host)
The interface that will be opened is set by “configNETWORKINTERFACETO_USE” which should be defined in FreeRTOSConfig.h Attempting to open interface number 2. 0 131 [IP-task] IP Address: 192.168.1.215 1 131 [IP-task] Subnet Mask: 255.255.255.0 2 131 [IP-task] Gateway Address: 192.168.1.1 3 131 [IP-task] DNS Server Address: 192.168.1.210 The output of cmd ipconfig /all is as follows. C:Windowssystem32>ipconfig /all Windows IP Configuration Host Name . . . . . . . . . . . . : KG-DELL-LAPTOP Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No Wireless LAN adapter Local Area Connection* 2: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter Physical Address. . . . . . . . . : 5C-E0-C5-37-2A-54 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Wireless LAN adapter KG-WIFI-1: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 7265 Physical Address. . . . . . . . . : 5C-E0-C5-37-2A-53 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IPv4 Address. . . . . . . . . . . : 192.168.1.35(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : 25 June 2016 09:05:40 Lease Expires . . . . . . . . . . : 25 June 2016 21:15:55 Default Gateway . . . . . . . . . : 192.168.1.1 DHCP Server . . . . . . . . . . . : 192.168.1.1 DNS Servers . . . . . . . . . . . : 192.168.1.1 NetBIOS over Tcpip. . . . . . . . : Enabled Ethernet adapter KG-ETHERNET: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Realtek USB FE Family Controller Physical Address. . . . . . . . . : 00-E0-4C-36-10-1C DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::c9a7:d966:7420:365c%15(Preferred) IPv4 Address. . . . . . . . . . . : 192.168.1.210(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 0.0.0.0 DHCPv6 IAID . . . . . . . . . . . : 318824524 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1E-F6-6D-6E-00-E0-4C-36-10-1C DNS Servers . . . . . . . . . . . : 192.168.1.210 NetBIOS over Tcpip. . . . . . . . : Enabled Ethernet adapter Bluetooth Network Connection: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network) Physical Address. . . . . . . . . : 5C-E0-C5-37-2A-57 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes The output of arp -a cmd is as follows. C:Windowssystem32>arp -a Interface: 192.168.1.35 — 0x3 Internet Address Physical Address Type 192.168.1.1 c4-a8-1d-3e-a6-91 dynamic 192.168.1.255 ff-ff-ff-ff-ff-ff static 224.0.0.9 01-00-5e-00-00-09 static 224.0.0.22 01-00-5e-00-00-16 static 224.0.0.251 01-00-5e-00-00-fb static 224.0.0.252 01-00-5e-00-00-fc static 239.255.255.250 01-00-5e-7f-ff-fa static 255.255.255.255 ff-ff-ff-ff-ff-ff static Interface: 192.168.1.210 — 0xf Internet Address Physical Address Type 192.168.1.255 ff-ff-ff-ff-ff-ff static 224.0.0.9 01-00-5e-00-00-09 static 224.0.0.22 01-00-5e-00-00-16 static 224.0.0.251 01-00-5e-00-00-fb static 224.0.0.252 01-00-5e-00-00-fc static 239.255.255.250 01-00-5e-7f-ff-fa static C:Windowssystem32> The output of WireShark is as follows. 471 2016-06-25 09:22:51.831373 192.168.1.215 Broadcast ARP 42 Who has 192.168.1.211? Tell 192.168.1.215 473 2016-06-25 09:22:52.870232 192.168.1.215 Broadcast ARP 42 Gratuitous ARP for 192.168.1.215 (Request) 474 2016-06-25 09:22:52.989143 192.168.1.215 Broadcast ARP 42 192.168.1.215 is at 00:e0:4c:36:10:1c 475 2016-06-25 09:22:53.830770 192.168.1.215 Broadcast ARP 42 Who has 192.168.1.211? Tell 192.168.1.215 I have removed ConfigAssert error on Heap_4.c. The COM3 output of LPC1768 Server Program on Terminal Utility on laptop is as follows. WELCOME TO RTOS PROJECT WORLD: Network UP SERVER IP…….: 192.168.1.211 SERVER NET MASK : 255.255.255.0 GATEWAY IP……: 192.168.1.1 DNS IP…….. .: 192.168.1.210 FreeRTOSPlusTCP Server Task Created Succesfully uIP SendReceive R 9 257 4 IDLE R 0 70 2 IP-task B 14 247 1 EMAC B 15 281 3 Server Socket Created Successfully… Server Bind AT PORT 27754 Successful…. Listening for Client… SERVER IP…….: 192.168.1.211 Waiting For Accepting From 192.168.1.215 I am still not able to connect Laptop Client program with LPC1768 server program.

FreeRTOSPLUSTCP Server Application on NXP LPC1768 does not communicate with simulated FreeRTOSPLUSTCP Client Application on Dell Windows 10 Laptop

I did change the MAC address configMAC_ADDR0/5 to 00-E0-4C-36-10-1C for the Simulator Laptop program and now it is the same MAC address of LAN card (KG-ETHERNET in cmd ) of Laptop (LAN card ip 192.168.1.210).
The same? It needs to be different. Both the MAC address and the IP address of the +TCP stack running on the laptop MUST BE DIFFERENT to the MAC address and IP address of the laptop on which they are running. These are two different network interfaces and you cannot duplicate MAC addresses on the same network. When you set both the MAC address and the IP address used by +TCP on the laptop so they are different to the MAC address and IP address used by Windows on the same laptop, then try opening a DOS prompt on the laptop and pinging the IP address assigned to the +TCP stack (192.168.1.215 by the looks of it). You will be pinging from the IP address used by Windows to the IP address used by +TCP. The network must be ‘up’ for this to work – so keep the point to point cable plugged in even though at this point we are not talking to the LPC part. Do you get a ping reply?