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.

TMDSIDK437X: DHCP client verification

Part Number: TMDSIDK437X


Hello,

Below are the components i am using.

I am using "NIMU_ICSS_BasicExample_idkAM437x_wSoCLib_armExampleproject".

I want DHCP client service in my code.

I have enabled DHCP client service in .cfg file.

1) do i have to do anything more to get work DHCP client?

2) If DHCP client is running How can i check assigned IP address?

3) Is it possible to go back to previous static ip address while DHCP client is running?How?

4) since i am using idk 437x it has two ports ? Both the port will use DHCP client service ? IP address assigned by server for both port will be different or same?

Regards,

Vrund

  • Hello,

    I wanted to make sure you had found Section 6.4 of the NDK API guide:

    https://www.ti.com/lit/ug/spru524k/spru524k.pdf?ts=1607626119067&ref_url=https%253A%252F%252Fwww.google.com%252F

    It covers the DHCP client operation and has valuable information that should help address your questions.

    Thanks.

  • Hello Ronb,

    I have gone through the section 6.4 of

    https://www.ti.com/lit/ug/spru524k/spru524k.pdf?ts=1607626119067&ref_url=https%253A%252F%252Fwww.google.com%252F

    ti_ndk_config_Global_serviceReport is assigned & i have kept breakpoint under ti_ndk_config_Global_serviceReport function but not hitting the breakpoint.

    static char *TaskName[]  = {"Telnet","HTTP","NAT","DHCPS","DHCPC","DNS"};
    static char *ReportStr[] = {"","Running","Updated","Complete","Fault"};
    static char *StatusStr[] = {"Disabled","Waiting","IPTerm","Failed","Enabled"};
    void ti_ndk_config_Global_serviceReport(uint32_t Item, uint32_t Status,
            uint32_t Report, void *h)
    {
        DbgPrintf(DBG_INFO, "Service Status: %-9s: %-9s: %-9s: %03d\n",
                TaskName[Item-1], StatusStr[Status],
                ReportStr[Report/256], Report&0xFF);
    
    }

    i also gone through the section 2.1.4.1.2 of

    https://www.ti.com/lit/ug/spru523k/spru523k.pdf?ts=1607657232354      

    which mentions initIp() function from ndk.c but i didnt found initIp function so i added to my code under 

    function "stackInitHook" which is getting called from global hook(start thread initialization hook).

    Below is the code added under stackInitHook.kindl;ly consider dhcp related code.

    void stackInitHook(HANDLE hCfg)
    {
        CI_IPNET NA;
        CI_ROUTE RT;
    
        /* Add IP address for interface 1 */
        NA.IPAddr = inet_addr(ipAddr);
        NA.IPMask = inet_addr(ipMask);
        CfgAddEntry(hCfg, CFGTAG_IPNET, 1, 0, sizeof(CI_IPNET),
                (uint8_t *)&NA, 0 );
    
        /*
         * Add gateway for interface 1
         * --> I *think* the below should work but you may need different values ...
         */
        bzero(&RT, sizeof(RT));
        RT.IPDestAddr = 0;
        RT.IPDestMask = 0;
        RT.IPGateAddr = inet_addr(ipGateway);
    
        CfgAddEntry(hCfg, CFGTAG_ROUTE, 0, 0,
                sizeof(CI_ROUTE), (uint8_t *)&RT, 0);
    
    
        /*Add a configuration entry specifying the DHCP client service to be used*/
    #if 1 | dhcp_client
     CI_SERVICE_DHCPC dhcpc;
     unsigned char DHCP_OPTIONS[] = { DHCPOPT_SUBNET_MASK };
    
    #if 0 | already_added_ip_init
        static char *hostName = "tisoc";
        /* Add global hostname to hCfg (to be claimed in all connected domains) */
        CfgAddEntry(hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
        strlen(hostName), (unsigned char *)hostName, NULL);
    #endif
    
        /* Use DHCP to obtain IP address on interface 1 */
        /* Specify DHCP Service on IF specified by "IfIdx" */
        memset(&dhcpc, 0, sizeof(dhcpc));
        dhcpc.cisargs.Mode = CIS_FLG_IFIDXVALID;
        dhcpc.cisargs.IfIdx = 1;
        dhcpc.cisargs.pCbSrv = &ti_ndk_config_Global_serviceReport;
        dhcpc.param.pOptions = DHCP_OPTIONS;
        dhcpc.param.len = 1;
        CfgAddEntry(hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT, 0,
        sizeof(dhcpc), (unsigned char *)&dhcpc, NULL);
    #endif
    
    }

    I have also added dhcp client related files from nettool folder.(C:\ti\ndk_3_61_01_01\packages\ti\ndk\nettools\dhcp)

    below is the screenshot of workspace.

    I have also called void netOpenHook() and void netCloseHook() from global hook.

    under netOpenHook()  i have added DHCPOpen( pNTA , pNTP ) and under netCloseHook() i have added DHCPClose(hDHCP ); function.

    below is the code.

    /*
     *  ======== netHooks.c ========
     *  This file contains hook functions to start the send and recv threads
     */
     
    #include <xdc/std.h>
    #include <ti/ndk/inc/netmain.h>
    #include <ti/ndk/inc/tools/servers.h>
    #include <ti/transport/ndk/nimu_icss/example/src/osdrv_ndkdeviceconfig.h>
    
    
    static HANDLE hEcho = 0;
    static HANDLE hEchoUdp = 0;
    static HANDLE hData = 0;
    static HANDLE hNull = 0;
    static HANDLE hOob = 0;
    static HANDLE hDHCP = 0;
    
    extern void ti_ndk_config_Global_serviceReport(uint32_t Item, uint32_t Status,
            uint32_t Report, void *h);
    
    
    void netOpenHook()
    {
        // Create our local servers
        hEcho = DaemonNew( SOCK_STREAMNC, 0, 502, dtask_tcp_echo,
                           OS_TASKPRINORM, OS_TASKSTKNORM, 0, 8 );
        hEchoUdp = DaemonNew( SOCK_DGRAM, 0, 7, dtask_udp_echo,
                              OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 );
        hData = DaemonNew( SOCK_STREAM, 0, 1000, dtask_tcp_datasrv,
                           OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
        hNull = DaemonNew( SOCK_STREAMNC, 0, 1001, dtask_tcp_nullsrv,
                           OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
        hOob  = DaemonNew( SOCK_STREAMNC, 0, 999, dtask_tcp_oobsrv,
                           OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
       NTARGS *pNTA;
       NTPARAM_DHCP *pNTP;
       unsigned char DHCP_OPTIONS[] = { DHCPOPT_SUBNET_MASK };
       pNTA->CallMode =0x0001;/*CIS_FLG_IFIDXVALID*/
       pNTA->IfIdx = 1;
       pNTA->pCb = &ti_ndk_config_Global_serviceReport;
    
       pNTP->pOptions = DHCP_OPTIONS;
       pNTP->len = 1;
    
       hDHCP = DHCPOpen( pNTA , pNTP );
    }
    
    void netCloseHook()
    {
    
        DaemonFree(hOob);
        DaemonFree(hNull);
        DaemonFree(hData);
        DaemonFree(hEchoUdp);
        DaemonFree(hEcho);
        DHCPClose(hDHCP );
    
    }
    

    After this i am trying to debug but it fails below is the screenshot.

    Kindly confirm the way of implementation is right.

    Also help with debugg problem.

    Regards,

    Vrund