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.

TM4C1294NCPDT: Problems (yet) with manual configuration of DHCP or Static IP

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: SYSBIOS

Hello All, 

  This problem I am facing is related to https://e2e.ti.com/support/microcontrollers/other/f/908/t/766896, 

Using MAC address in flash
ti.sysbios.family.arm.m3.Hwi: line 143: E_alreadyDefined: Hwi already defined: intr# 56
00000.000 ExecStart: Already Open
00000.000 DHCPOpen: NIMUIOCTL (NIMU_GET_DEVICE_MAC) Failed with error code: -22

void netStart() {
	//debug("NetStart Callback\r\n");
}

void netStop() {
	//debug("NetStop Callback\r\n");
}

void serviceReport(uint a, uint b, uint c, HANDLE cfg) {
	//debug("ServiceReport\r\n");
}


void openConnections(IPN IPAddr, uint IfIdx, uint fAdd);

char *hostname = "myhost";
Void configIpInitDHCP(HANDLE hCfg)
{
	debug("CONFIGURANDO DHCP\r\n");

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

    /* Use DHCP to obtain IP address on interface 1 */
    {
        CI_SERVICE_DHCPC dhcpc;
        UINT8 DHCP_OPTIONS[] =
                {
                DHCPOPT_SUBNET_MASK,
                };

        /* Specify DHCP Service on IF specified by "IfIdx" */
        bzero(&dhcpc, sizeof(dhcpc));
        dhcpc.cisargs.Mode   = 1;
        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), (UINT8 *)&dhcpc, 0);
    }
}

Void configIpInitStatic(HANDLE hCfg)
{
	RemottaConfig *rc = getRemottaConfig();
	char *DomainName = "scientt.scom";
	char ipAddress[20], netmask[20], gateway[20];

	debug("CONFIGURANDO STATIC IP\r\n");


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

    /* Configure IP address manually on interface 1 */
    {
        CI_IPNET NA;
        CI_ROUTE RT;
        /* Setup manual IP address */
        bzero(&NA, sizeof(NA));
        getStringAddressFromInt(rc->configData.ethParam.ipAddress, ipAddress);
        getStringAddressFromInt(rc->configData.ethParam.networkMask, netmask);
        NA.IPAddr  = inet_addr(ipAddress);
        NA.IPMask  = inet_addr(netmask);
        strcpy(NA.Domain, DomainName);
        NA.NetType = 0;

        CfgAddEntry(hCfg, CFGTAG_IPNET, 1, 0,
                sizeof(CI_IPNET), (UINT8 *)&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;
        getStringAddressFromInt(rc->configData.ethParam.gateway, gateway);
        RT.IPGateAddr = inet_addr(gateway);

        CfgAddEntry(hCfg, CFGTAG_ROUTE, 0, 0,
                sizeof(CI_ROUTE), (UINT8 *)&RT, 0);
    }
}

Void configUdpInit(HANDLE hCfg)
{
    {
        Int receiveBufSize = 2048;
        CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKUDPRXLIMIT,
            CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&receiveBufSize, 0);
    }
}


Void configTcpInit(HANDLE hCfg)
{
    {
        Int transmitBufSize = 2048;
        CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPTXBUF,
                CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&transmitBufSize, 0);
    }
    {
        Int receiveBufSize = 2048;
        CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXBUF,
                CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&receiveBufSize, 0);
    }
    {
        Int receiveBufLimit = 2048;
        CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXLIMIT,
                CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&receiveBufLimit, 0);
    }

}

extern void llTimerTick();
int NetworkConfig(void)
{
	int ret;
	HANDLE hCfg;
	RemottaConfig *rc = getRemottaConfig();
	Clock_Params clockParams;


	debug("\r\nNetworkConfig Configuracion - Initialization\r\nNC_SystemOpen\r\n");

	/* Create the NDK heart beat */
	Clock_Params_init(&clockParams);
	clockParams.startFlag = TRUE;
	clockParams.period = 100;
	Clock_create(&llTimerTick, clockParams.period, &clockParams, NULL);

	ret = NC_SystemOpen( NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT );
	if( ret )
	{
		sprintf(_message, "NC_SystemOpen Failed (%d)\n",ret);
		debug(_message);
		return -1;
	}

	hCfg = CfgNew();
	if( !hCfg )
	{
		debug("Unable to create configuration\n");
		goto main_exit;
	}


	NC_NetStop(0);

	if (rc->configData.ethParam.dhcpOrStatic == DHCP) {
		configIpInitDHCP(hCfg);
	}
	else {
		configIpInitStatic(hCfg);
	}

	configTcpInit(hCfg);

	configUdpInit(hCfg);

    /* add the configuration settings for NDK low priority tasks stack size. */
    int stackSize = 1024;
    CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKLOW,
                 CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&stackSize, 0 );

    /* add the configuration settings for NDK norm priority tasks stack size. */
    stackSize = 1024;
    CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKNORM,
                 CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&stackSize, 0 );

    /* add the configuration settings for NDK high priority tasks stack size. */
    stackSize = 1024;
    CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKHIGH,
                 CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&stackSize, 0 );


	//
	// Boot the system using this configuration
	//
	// We keep booting until the function returns less than 1. This allows
	// us to have a "reboot" command.
	//
	debug("NC_NetStart\r\n");
	do
	{
		ret = NC_NetStart( hCfg, netStart, netStop, openConnections );
	} while( ret > 0 );

	sprintf(_message, "NC_NetStart retCode = %d\r\n", ret);
	debug(_message);

	// Delete Configuration
	CfgFree( hCfg );

	debug("NetworkConfig Configuracion - Finishing\r\n");

	// Close the OS
	main_exit:
		NC_SystemClose();

	return(0);
}


Void startupTask(UArg arg0, UArg arg1) {

// Code before

	NetworkConfig();

// Code after
}

Tks in advance

Leandro

  • Sorry, something happen with my comment before the error and code.
    I need to configure manually the NDK to use NDK or STATIC. So, I am copying the generated code when using CGCONF (as suggested by Todd) but it continues not working.

    NetworkConfig is called from a startupTask (Started from RTOS).
    In the XGCONF I just left selected the checkbox "Add NDK/Global to my configuration". Should I unselect this option?

    The NC_Netstop(0) was a desesperated attempt to solve this problem, but without success.

    Tks in advance.
    Leandro

  • Hi Leandro,

    Did you include the memory management portion of the generated file? It might be easier if you just do a project clean and then export the CCS project. Then attach it.

    Todd
  • 4544.tcpecho.zipHi Todd,

     I just did the changes I want in a fresh tcpecho demo program and now I am having the following error:

    ss in flash

    Starting the TCP Echo example

    System provider is set to SysMin. Halt the target to view any SysMin contents in ROV.

    Inicialization Task - Starting

    NetworkConfig

    000 DHCPOpen: NIMUIOCTL (NIMU_GET_DEVICE_MAC) Failed with error code: -22

    Service Status: DHCPC    : Failed   :          : 000

    FSR = 0x0000

    HFSR = 0x40000000

    DFSR = 0x0000000b

    MMAR = 0xd50000d2

    BFAR = 0xd50000d2

    AFSR = 0x00000000

    Terminating execution...

    There is a startpTask that just call my NetworkConfiguration.

    The error occurs in NC_NetStart call.

    I will attach the project here.

    Tks for any help

    Best regards,

    Leandro

  • Hi,

    Using MAC address in flash

    Perhaps program the USER0/1 register (USER_REGn) for the MAC with LM Flash tool. MAC address to exist in flash may not be expected by source code.

  • Hi,

     I am no sure if I understood the process. With LM Flash Programmer I can get the MAC Address. Take a look at the attached image.

     Should I configure a different MAC address?

  • Leandro,

    The problem you are having is that the networking code is still being generated. So the network is trying to be opened by you and the generated code.

    Do the following

    1. Build the big generated .c file with this in the .cfg: Global.enableCodeGeneration = true;

    2. Save the generated file some where other than in the project and add "true" to make it obvious (e.g. C:\temp\tcpEcho_pem4f_true.c

    3. Change to Global.enableCodeGeneration = false; in the .cfg.

    4. Now compare the generated file with tcpEcho_pem4f_true.c. You'll see the stuff you need to supply.

    Note: there is still the ti_ndk_config_Global_stackThread task. It just creates the clock for you (sorry, I misled you on this one...I forgot it did this).

  • If the MAC matches what you entered in LM Flash it should be ok. You must commit the MAC or it will return to 0x0 on next POR. Also check MAC address mode to see if it looks like you expect it should.
  • Leandro,

    Did this get resolved?

    Todd

    [2/6 Update: I'm closing this thread due to no response from the original poster]

  • Hi Todd, sorry for late response.
    I am able now to set static IP and DHCP programatically. Tks for help.