This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TM4C1294NCPDT: LWIP Socket Problem with FreeRTOS

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: EK-TM4C1294XL

Tool/software: Code Composer Studio

Hi,

I am trying to create a socket for communicating with a server with Tiva TM4C1294XL launchpad. I have used LWIP with FreeRTOS for TCP stack and threads.

Once after initialization of the LWIP tcp stack, link is up and 'ping' command from PC has a response.

The real issue is:

After creating a socket with lwip_socket() api, there is no ping as well as the socket doesn't find created.

The code snippets ...

int16_t sockfd;
/* create the socket */
sockfd = lwip_socket(AF_INET, SOCK_STREAM, 0);
LWIP_ASSERT("sockfd >= 0", sockfd >= 0);
return sockfd;

The socket creation is done with in a tcp_callback() function handler. The tcp_callback() is done after lwip_init() function.

This is  the code flow

lwipTaskInit(void)

{

.

,

lwIPInit(g_ui32SysClock, pui8MAC, ip_address.addr, net_mask.addr, gateway.addr, IPADDR_USE_STATIC);

//
// Setup the remaining services inside the TCP/IP thread's context.
//
tcpip_callback(SetupServices, 0);

return 0

}

SetupServices(void *pvArg)
{
uint8_t pui8MAC[6];
uint32_t ui32Loop;

//
// Setup the device locator service.
//
LocatorInit();
lwIPLocalMACGet(pui8MAC);
LocatorMACAddrSet(pui8MAC);
LocatorAppTitleSet("EK-TM4C1294XL enet_s2e");

.

.

.

//
ConfigWebInit();

HubClientISockCreate();
}

 int HubClientSockCreate(void)

{

uint16_t sockfd;
/* create the socket */
sockfd = lwip_socket(AF_INET, SOCK_STREAM, 0);
LWIP_ASSERT("sockfd >= 0", sockfd >= 0);
return sockfd;

}

Note: I have disable DHCP and using a static IP.  The LWIP options set are

//*****************************************************************************
#define HOST_TMR_INTERVAL 40 // default is 0
//#define DHCP_EXPIRE_TIMER_MSECS (10 * 1000)
#define LWIP_HTTPD_SSI 1
#define LWIP_HTTPD_CGI 1
#define LWIP_HTTPD_MAX_CGI_PARAMETERS 20 // default is 16
#define LWIP_HTTPD_DYNAMIC_HEADERS 1
//#define HTTPD_DEBUG LWIP_DBG_ON
#define EMAC_PHY_CONFIG (EMAC_PHY_TYPE_INTERNAL | EMAC_PHY_INT_MDIX_EN | \
EMAC_PHY_AN_100B_T_FULL_DUPLEX)
#define PHY_PHYS_ADDR 0
#define NUM_TX_DESCRIPTORS 24
#define NUM_RX_DESCRIPTORS 8

#define LWIP_DHCP                       0    

#define LWIP_AUTOIP 0 // default is 0
#define LWIP_DHCP_AUTOIP_COOP ((LWIP_DHCP) && (LWIP_AUTOIP))
// default is 0
#define LWIP_DHCP_AUTOIP_COOP_TRIES 5 // default is 9

#define LWIP_TCP 1
//#define TCP_TTL (IP_DEFAULT_TTL)
#define TCP_WND 4096 // default is 2048
//#define TCP_MAXRTX 12
//#define TCP_SYNMAXRTX 6
//#define TCP_QUEUE_OOSEQ 1
#define TCP_MSS 1500 // default is 536
//#define TCP_CALCULATE_EFF_SEND_MSS 1
#define TCP_SND_BUF (4 * TCP_MSS)

#define LWIP_EVENT_API 0
#define LWIP_CALLBACK_API 1

//#define LWIP_NETIF_HOSTNAME 0
//#define LWIP_NETIF_API 0
//#define LWIP_NETIF_STATUS_CALLBACK 0
//#define LWIP_NETIF_LINK_CALLBACK 0
//#define LWIP_NETIF_HWADDRHINT 0

#define LWIP_TCPIP_CORE_LOCKING 0
#define LWIP_NETCONN 1 // default is 1

#define LWIP_SOCKET 1 // default is 1
#define LWIP_COMPAT_SOCKETS 0
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
#define LWIP_TCP_KEEPALIVE 0
#define LWIP_SO_RCVTIMEO 0
#define LWIP_SO_RCVBUF 0
#define SO_REUSE 0

#define LWIP_SOCKET_OFFSET 5
#define LWIP_SO_SNDTIMEO 0
#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0
#define LWIP_SO_LINGER 0
#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
#define SO_REUSE_RXTOALL 0
#define LWIP_FIONREAD_LINUXMODE 0
#define LWIP_IPV4 1

See attached lwipopts.h file1258.lwipopts.h

Please mention what is wrong with the lwip_socket creation?

Regards

Rajesh Kumar V