Part Number: TM4C1294NCPDT
Tool/software: Code Composer Studio
I'm trying to manually configuring and initiate the NDK stack using C code (as described in spru523k, section 2.1), but when I run my project I get this error in console:
00010.002 TaskGetEnv: FATAL: NDK_hookInit() must be set in DSP/BIOS Task module config (hookId == 0xffffffff)
00010.002 TaskSetEnv: FATAL: NDK_hookInit() must be set in BIOS Task module config (hookId == 0xffffffff)
00010.002 TaskGetEnv: FATAL: NDK_hookInit() must be set in DSP/BIOS Task module config (hookId == 0xffffffff)
Network Removed: d01a8c0
Network close hook!
ndkStackThread: exiting ...
Can anyone help me to solve this problem? I searched about it, but I couldn't solve it by myself.
Here is my stack initialization code:
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/ndk/inc/netmain.h>
#include <ti/ndk/inc/os/oskern.h>
#include <ti/sysbios/knl/Clock.h>
#include <signal.h>
#include <time.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/utils/Load.h>
/* Socket file descriptor table */
#define MAXSOCKETS 10
uint32_t ti_ndk_socket_max_fd = MAXSOCKETS;
void *ti_ndk_socket_fdtable[MAXSOCKETS];
/* NDK memory manager page size and number of pages [used by mmAlloc()] */
#define RAW_PAGE_SIZE 3072
#define RAW_PAGE_COUNT 6
const int ti_ndk_config_Global_rawPageSize = RAW_PAGE_SIZE;
const int ti_ndk_config_Global_rawPageCount = RAW_PAGE_COUNT;
/* P.I.T. (page information table) */
#ifdef __ti__
#pragma DATA_SECTION(ti_ndk_config_Global_pit, ".bss:NDK_MMBUFFER");
#pragma DATA_SECTION(ti_ndk_config_Global_pitBuffer, ".bss:NDK_MMBUFFER");
PITENTRY ti_ndk_config_Global_pit[RAW_PAGE_COUNT];
unsigned char ti_ndk_config_Global_pitBuffer[RAW_PAGE_SIZE * RAW_PAGE_COUNT];
#elif defined (__IAR_SYSTEMS_ICC__)
PITENTRY ti_ndk_config_Global_pit[RAW_PAGE_COUNT];
unsigned char ti_ndk_config_Global_pitBuffer[RAW_PAGE_SIZE * RAW_PAGE_COUNT];
#else
PITENTRY ti_ndk_config_Global_pit[RAW_PAGE_COUNT]
__attribute__ ((section(".bss:NDK_MMBUFFER")));
unsigned char ti_ndk_config_Global_pitBuffer[RAW_PAGE_SIZE * RAW_PAGE_COUNT]
__attribute__ ((section(".bss:NDK_MMBUFFER")));
#endif
/* --> ti_sysbios_knl_Task_hooks__A */
const __T1_ti_sysbios_knl_Task_hooks ti_sysbios_knl_Task_hooks__A[2];
/* --> NDK_hookInit */
extern xdc_Void NDK_hookInit(xdc_Int);
/* --> NDK_hookCreate */
extern xdc_Void NDK_hookCreate(ti_sysbios_knl_Task_Handle,xdc_runtime_Error_Block*);
/* --> NDK_hookExit */
extern xdc_Void NDK_hookExit(ti_sysbios_knl_Task_Handle);
/* --> ti_sysbios_knl_Task_hooks__A */
#pragma DATA_SECTION(ti_sysbios_knl_Task_hooks__A, ".const:ti_sysbios_knl_Task_hooks__A");
const __T1_ti_sysbios_knl_Task_hooks ti_sysbios_knl_Task_hooks__A[2] = {
{
((xdc_Void(*)(xdc_Int))((xdc_Fxn)NDK_hookInit)), /* registerFxn */
((xdc_Void(*)(ti_sysbios_knl_Task_Handle,xdc_runtime_Error_Block*))((xdc_Fxn)NDK_hookCreate)), /* createFxn */
((xdc_Void(*)(ti_sysbios_knl_Task_Handle))0), /* readyFxn */
((xdc_Void(*)(ti_sysbios_knl_Task_Handle,ti_sysbios_knl_Task_Handle))0), /* switchFxn */
((xdc_Void(*)(ti_sysbios_knl_Task_Handle))((xdc_Fxn)NDK_hookExit)), /* exitFxn */
((xdc_Void(*)(ti_sysbios_knl_Task_Handle))0), /* deleteFxn */
}, /* [0] */
{
((xdc_Void(*)(xdc_Int))((xdc_Fxn)ti_sysbios_utils_Load_taskRegHook__E)), /* registerFxn */
((xdc_Void(*)(ti_sysbios_knl_Task_Handle,xdc_runtime_Error_Block*))((xdc_Fxn)ti_sysbios_utils_Load_taskCreateHook__E)), /* createFxn */
((xdc_Void(*)(ti_sysbios_knl_Task_Handle))0), /* readyFxn */
((xdc_Void(*)(ti_sysbios_knl_Task_Handle,ti_sysbios_knl_Task_Handle))((xdc_Fxn)ti_sysbios_utils_Load_taskSwitchHook__E)), /* switchFxn */
((xdc_Void(*)(ti_sysbios_knl_Task_Handle))0), /* exitFxn */
((xdc_Void(*)(ti_sysbios_knl_Task_Handle))((xdc_Fxn)ti_sysbios_utils_Load_taskDeleteHook__E)), /* deleteFxn */
}, /* [1] */
};
/* Memory bucket sizes */
#define SMALLEST 48
#define LARGEST (RAW_PAGE_SIZE)
const int ti_ndk_config_Global_smallest = SMALLEST;
const int ti_ndk_config_Global_largest = LARGEST;
/* Memory Slot Tracking */
uint32_t ti_ndk_config_Global_Id2Size[] =
{SMALLEST, 96, 128, 256, 512, 1536, LARGEST};
/*
* Local Packet Buffer Pool Definitions
*
* The below variables/defines are used to override the defaults that are set
* in the Packet Buffer Manager (PBM) file src/stack/pbm/pbm_data.c
*/
/*
* Number of buffers in PBM packet buffer free pool
*
* The number of buffers in the free pool can have a significant effect
* on performance, especially in UDP packet loss. Increasing this number
* will increase the size of the static packet pool use for both sending
* and receiving packets.
*/
#define PKT_NUM_FRAMEBUF 10
/* Size of Ethernet frame buffer */
#define PKT_SIZE_FRAMEBUF 1536
const int ti_ndk_config_Global_numFrameBuf = PKT_NUM_FRAMEBUF;
const int ti_ndk_config_Global_sizeFrameBuf = PKT_SIZE_FRAMEBUF;
/*
* Data space for packet buffers
*
* Buffers are aligned on 4 byte boundaries to satisfy the EMAC's DMA
*/
unsigned char ti_ndk_config_Global_pBufMem[PKT_NUM_FRAMEBUF * PKT_SIZE_FRAMEBUF]
__attribute__ ((aligned(4)));
unsigned char ti_ndk_config_Global_pHdrMem[PKT_NUM_FRAMEBUF * sizeof(PBM_Pkt)]
__attribute__ ((aligned(4)));
/* Our NETCTRL callback functions */
static void networkOpen();
static void networkClose();
static void networkIPAddr(uint32_t IPAddr, uint32_t IfIdx, uint32_t fAdd);
static char *hostName = "tisoc";
extern void llTimerTick();
const char *LocalIPAddr = "192.168.1.13";
const char *LocalIPMask = "255.255.255.0";
const char *GatewayIP = "192.168.1.1";
const char *DomainName = "demo.net";
/*
* ======== networkOpen ========
* This function is called after the configuration has booted
*/
static void networkOpen()
{
System_printf("Network open hook!\n");
System_flush();
}
/*
* ======== 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()
{
System_printf("Network close hook!\n");
System_flush();
// call user defined network close hook
}
/*
* ======== 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) {
//Display_printf(display, 0, 0, "Network Added: ");
System_printf("Network Added: ");
}
else {
//Display_printf(display, 0, 0, "Network Removed: ");
System_printf("Network Removed: ");
}
System_printf("%x\n", IPAddr);
System_flush();
}
/*
* ======== serviceReport ========
* Function for reporting service status updates.
*/
static char *taskName[] = {"Telnet", "HTTP", "NAT", "DHCPS", "DHCPC", "DNS"};
static char *reportStr[] = {"", "Running", "Updated", "Complete", "Fault"};
static char *statusStr[] = {"Disabled", "Waiting", "IPTerm", "Failed","Enabled"};
static void serviceReport(uint32_t item, uint32_t status, uint32_t report,
void *h)
{
System_printf("Service Status: %-9s: %-9s: %-9s: %03d\n",
taskName[item - 1], statusStr[status], reportStr[report / 256],
report & 0xFF);
System_flush();
}
/*
* ======== initTcp ========
* Configure the stack's TCP settings
*/
static void initTcp(void *hCfg)
{
int transmitBufSize = 1024;
int receiveBufSize = 1024;
int receiveBufLimit = 2048;
CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPTXBUF, CFG_ADDMODE_UNIQUE,
sizeof(uint32_t), (unsigned char *)&transmitBufSize, NULL);
CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXBUF, CFG_ADDMODE_UNIQUE,
sizeof(uint32_t), (unsigned char *)&receiveBufSize, NULL);
CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXLIMIT, CFG_ADDMODE_UNIQUE,
sizeof(uint32_t), (unsigned char *)&receiveBufLimit, NULL);
}
/*
* ======== initIp ========
* Configure the stack's IP settings
*/
static void initIp(void *hCfg)
{
CI_SERVICE_DHCPC dhcpc;
unsigned char DHCP_OPTIONS[] = { DHCPOPT_SUBNET_MASK };
// hostname
CfgAddEntry(hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
strlen(hostName), (unsigned char *)hostName, NULL);
// Usa DHCP para obter IP na interface 1
memset(&dhcpc, 0, sizeof(dhcpc));
dhcpc.cisargs.Mode = CIS_FLG_IFIDXVALID;
dhcpc.cisargs.IfIdx = 1;
dhcpc.cisargs.pCbSrv = &serviceReport;
dhcpc.param.pOptions = DHCP_OPTIONS;
dhcpc.param.len = 1;
CfgAddEntry(hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT, 0,
sizeof(dhcpc), (unsigned char *)&dhcpc, NULL);
}
/*
* ======== initUdp ========
* Configure the stack's UDP settings
*/
void initUdp(void *hCfg)
{
int receiveBufSize = 2048;
CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKUDPRXLIMIT, CFG_ADDMODE_UNIQUE,
sizeof(uint32_t), (unsigned char *)&receiveBufSize, NULL);
}
/*
* ======== ndkStackThread ========
* NDK stack's main thread function
*/
void NDKManagerTaskFxn()
{
void *hCfg;
int rc;
Clock_Params clockParams;
Clock_Handle ndkClockHandle;
// Create the NDK heart beat
Clock_Params_init(&clockParams);
clockParams.startFlag = TRUE;
clockParams.period = 100;
ndkClockHandle = Clock_create((Clock_FuncPtr)llTimerTick, clockParams.period,
&clockParams, NULL);
if (ndkClockHandle == NULL) {
return;
}
rc = NC_SystemOpen(NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT);
if (rc) {
return;
}
// create and build the system configuration from scratch.
hCfg = CfgNew();
if (!hCfg) {
goto main_exit;
}
/* IP, TCP, and UDP config */
initIp(hCfg);
initTcp(hCfg);
initUdp(hCfg);
/* config low priority tasks stack size */
rc = 2048;
CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKLOW, CFG_ADDMODE_UNIQUE,
sizeof(uint32_t), (unsigned char *)&rc, NULL);
/* config norm priority tasks stack size */
rc = 2048;
CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKNORM, CFG_ADDMODE_UNIQUE,
sizeof(uint32_t), (unsigned char *)&rc, NULL);
/* config high priority tasks stack size */
rc = 2048;
CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKHIGH, CFG_ADDMODE_UNIQUE,
sizeof(uint32_t), (unsigned char *)&rc, NULL);
do
{
rc = NC_NetStart(hCfg, networkOpen, networkClose, networkIPAddr);
} while(rc > 0);
CfgFree(hCfg);
main_exit:
NC_SystemClose();
System_printf("ndkStackThread: exiting ...\n");
System_flush();
}
Thanks in advance,
Ronan