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.

TMDSLCDK6748: NDK NC_NetStart does not call NetworkIPAddr i.e (*NetIP) and not call user provided callback function

Part Number: TMDSLCDK6748
Other Parts Discussed in Thread: OMAPL138, SYSBIOS

I'm using BIOS ver 6.73.00.12, NDK 3.40.01, cgt-C600 8.2.2, xdctools_3_50_08_24_core, CCS Version 8.2.x

I was able to compile the sample NIMU_emacExample_lcdkOMAPL138C674xBiosExampleProject in C:\ti\pdk_omapl138_1_0_6\packages\MyExampleProjects

I can run the sample project and it connected through UDP to another Utility App fine.

The code line in sample project   is   rc = NC_NetStart( hCfg, NetworkOpen, NetworkClose, NetworkIPAddr );

When I run the sample project I did called the function NetworkIPAddr (this function just indicated the it added the IP address).

It also called NetworkOpen define as below. However it does not spawn a thread for dtask_udp_hello until the App sends some data as explained in  the NDK user guide and API Ref Guide.

static void NetworkOpen()
{
// Create our local server
hHello = DaemonNew( SOCK_DGRAM, 0, 7, dtask_udp_hello,
OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 );
}

Next , I try to create a new fresh CCS project and do the Board Init and NDK Configuration exactly the way the sample project did. When I run it, it only called NetworkOpen but did not call the NetworkIPAddr function and does not create a thread and call the function dtask_udp_hello when I use the Utility App to send data. 

Do I missed something that the Sample project did?  I could not found where in the sample code it setups the interrupt vector ID for Ethernet Port. Is it automatically done in the Configuration. How do I know what Interrupt number they used.

Below is my initialization/configuration setup.

char *HostName = "tidsp";

char *LocalIPAddr = "192.168.1.4";
char *LocalIPMask = "255.255.255.0"; // Not used when using DHCP
char *GatewayIP = "192.168.1.1"; // Not used when using DHCP
char *DomainName = "demo.net"; // Not used when using DHCP
char *DNSServer = "0.0.0.0"; // Used when set to anything but zero

int StackTest()
{
int rc;
//int i;
void* hCfg;
Board_STATUS boardInitStatus =0;

Board_initCfg cfg = Board_init(BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_MODULE_CLOCK | BOARD_INIT_UNLOCK_MMR | BOARD_INIT_UART_STDIO);

boardInitStatus = Board_init(cfg);
if (boardInitStatus !=0)
{
UART_printf("Board_init failure\n");
return(0);
}
UART_printf("Board_init success\n");

//
// THIS MUST BE THE ABSOLUTE FIRST THING DONE IN AN APPLICATION before
// using the stack!!
//
rc = NC_SystemOpen( NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT);
if( rc )
{
UART_printf("NC_SystemOpen Failed (%d)\n",rc);
for(;;);
}

// Print out our banner
//UART_printf(VerStr);

//
// Create and build the system configuration from scratch.
//

// Create a new configuration
hCfg = CfgNew();
if( !hCfg )
{
UART_printf("Unable to create configuration\n");
goto main_exit;
}

// We better validate the length of the supplied names
if( strlen( DomainName ) >= CFG_DOMAIN_MAX ||
strlen( HostName ) >= CFG_HOSTNAME_MAX )
{
UART_printf("Names too long\n");
goto main_exit;
}

// Add our global hostname to hCfg (to be claimed in all connected domains)
CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
strlen(HostName), (uint8_t *)HostName, 0 );

// If the IP address is specified, manually configure IP and Gateway
//if (!platform_get_switch_state(1))
if (1)
{
CI_IPNET NA;
CI_ROUTE RT;
uint32_t IPTmp;

// Setup manual IP address
bzero(&NA, sizeof(NA));
NA.IPAddr = inet_addr(LocalIPAddr);
NA.IPMask = inet_addr(LocalIPMask);
strcpy( NA.Domain, DomainName );
NA.NetType = 0;

// Add the address to interface 1
CfgAddEntry( hCfg, CFGTAG_IPNET, 1, 0,
sizeof(CI_IPNET), (uint8_t *)&NA, 0 );

// Add the default gateway. Since it is the default, the
// destination address and mask are both zero (we go ahead
// and show the assignment for clarity).
bzero(&RT, sizeof(RT));
RT.IPDestAddr = 0;
RT.IPDestMask = 0;
RT.IPGateAddr = inet_addr(GatewayIP);

// Add the route
CfgAddEntry( hCfg, CFGTAG_ROUTE, 0, 0,
sizeof(CI_ROUTE), (uint8_t *)&RT, 0 );

// Manually add the DNS server when specified
IPTmp = inet_addr(DNSServer);
if( IPTmp )
CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_DOMAINNAMESERVER,
0, sizeof(IPTmp), (uint8_t *)&IPTmp, 0 );
}

//
// Configure IPStack/OS Options
//

// We don't want to see debug messages less than WARNINGS
rc = DBG_WARN;
CfgAddEntry( hCfg, CFGTAG_OS, CFGITEM_OS_DBGPRINTLEVEL,
CFG_ADDMODE_UNIQUE, sizeof(uint32_t), (uint8_t *)&rc, 0 );

//
// This code sets up the TCP and UDP buffer sizes
// (Note 8192 is actually the default. This code is here to
// illustrate how the buffer and limit sizes are configured.)
//

// UDP Receive limit
rc = 8192;
CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKUDPRXLIMIT,
CFG_ADDMODE_UNIQUE, sizeof(uint32_t), (uint8_t *)&rc, 0 );

//
// Boot the system using this configuration
//
// We keep booting until the function returns 0. This allows
// us to have a "reboot" command.
//
do
{
rc = NC_NetStart( hCfg, NetworkOpen, NetworkClose, NetworkIPAddr );
} while( rc > 0 );

// Delete Configuration
CfgFree( hCfg );

// Close the OS
main_exit:
NC_SystemClose();
return(0);
}

static void* hHello = 0;

//
// NetworkOpen
//
// This function is called after the configuration has booted
//
static void NetworkOpen()
{
// Create our local server
hHello = DaemonNew( SOCK_DGRAM, 0, 7, dtask_udp_hello,
OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 );
}

//
// NetworkClose
//
// This function is called when the network is shutting down,
// or when it no longer has any IP addresses assigned to it.
//
static void NetworkClose()
{
DaemonFree( hHello );
}


//
// NetworkIPAddr
//
// This function is called whenever an IP address binding is
// added or removed from the system.
//
static void NetworkIPAddr(uint32_t IPAddr, uint32_t IfIdx, uint32_t fAdd)
{
uint32_t IPTmp;

if( fAdd )
UART_printf("Network Added: ");
else
UART_printf("Network Removed: ");

// Print a message
IPTmp = NDK_ntohl( IPAddr );
UART_printf("If-%d:%d.%d.%d.%d\n", IfIdx,
(uint8_t)(IPTmp>>24)&0xFF, (uint8_t)(IPTmp>>16)&0xFF,
(uint8_t)(IPTmp>>8)&0xFF, (uint8_t)IPTmp&0xFF );
}

Any help is very appreciated.

Sincerely,

-Tom