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.

omapl137 ethernet code

Other Parts Discussed in Thread: OMAPL138, OMAP-L137, SYSBIOS

Dear sir,

I am working with OMAPL137 with ccs v6 in windows 7,i want to work on ethernet....as we know from texas there is no standard example...where should i get the code for it.....can i get by downloading NDK ,if so which version i need to download can you please share the download link....along with that is it necessary to download NSP...

thank you

  • HI Mohammad,

    You may have to refer to the ethernet example of OMAPL138 Starterware code or NSP package and port it to OMAPL137.

  • Hi,

    Thanks for your post.

    NDK2_0_0 release includes some sample platform specific code and example projects for C6747 / OMAP-L137 devices. NDK 2.00 release include TCP/IP stack source and binary and associated NSPs (drivers).

    Please check the device web page for NSP (Ethernet driver package) updates or download the driver from the NDK 2.00 full package. Find the NDK and NSP download link available at this wiki: http://processors.wiki.ti.com/index.php/Before_asking_for NDK_support

    http://processors.wiki.ti.com/index.php/Network_Developers_Kit_FAQ#Q:_It_seems_that_the_NSP_for_OMAPL137_EVM_is_incompatible_with_the_EDMA3_LLD._How_can_I_fix_it.3F

    You can refer more details at the release notes of NDK and NSP.

    http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/ndk/2_21_01_38/exports/ndk_2_21_01_38/ndk_2_21_01_38_ReleaseNotes.html

    http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/ndk/nsp_1_10_01_06/exports/nsp_1_10_01_06/nsp_1_10_01_06_release_notes.html

    Thanks & regards,

    Sivaraj K

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    -------------------------------------------------------------------------------------------------------

  • Hi Sivaraj,

    I downloaded the NDK 2.00 and installed.But i dont find any ".out file" for client(omapl137) program...what should i do....shall i import the code....if so,there is no main.c inthat...then what to do...

    If i see the "common " folder,it is having client ".c" file...if i use that,i need the header files written in the program....

    which one i need to import or copy....
    i am following the link
    www.ti.com/.../spraax4.pdf
    downloads.ti.com/.../spru523h.pdf
    software-dl.ti.com/.../nsp_1_10_01_06_release_notes.html

    but i am cleared because no where it is given import and code for it.....

    thank you
  • 1) Try to download the NDK version as Sivaraj mentioned and check for the client & helloworld example for OMAPL137.
    software-dl.ti.com/.../

    2) As Shankari mentioned that you could try the NSP package which has client and helloworld NDK examples and port into OMAPL137.
    C:\ti\nsp_1_10_00_03\packages\ti\ndk\examples\ndk_evmOMAPL138_arm9_helloWorld
    C:\ti\nsp_1_10_00_03\packages\ti\ndk\examples\ndk_evmOMAPL138_arm9_client
  • Hi Titu,

    As shankari sir ,told i imported the client project by installing NDK.....but it was showing DSP/BIOS not installed....what to do with this...see the attachment...

    thank you

  • HI,
    I am doing with dsp part of omapl137(not arm)...can i do it ..?
    thank you
  • waiting for your reply....
  • Hi,

    Yes, you could do with DSP part of OMAPL137.

    Thanks & regards,

    Sivaraj K

  • then why am getting error like that(shown in attachment above)...?
    any suggestions..?
    thank you
  • hello sir,please give suggestions.
    thank you
  • As shankari sir ,told i imported the client project by installing NDK.....but it was showing DSP/BIOS not installed....what to do with this...see the attachment...

    Seems to be you have to install the DSB/BIOS package (older version of SYSBIOS).

    Have you installed the packages like below.
    C:\ti\bios_5_41_13_42
    C:\ti\bios_5_42_01_09

    That NDK examples is old and it built with older BIOS version called DSP/BIOS.

    Install the DSP/BIOO and add it into the client project, try to rebuild.

    Please let me know if any.
  • yes i have "bios_5_42_00_07"....i am trying in windows 7 with ccs version 6.....is it ok for ethernet example....? is it mandatory to work with linux only..?i have installed NDK things....but i got error as shown in earlier attachments...please overcome with this...
    thank you
  • Can you please attach the code ?
  • /*
     *  Copyright 2007 by Texas Instruments Incorporated.
     *  All rights reserved. Property of Texas Instruments Incorporated.
     *  Restricted rights to use, duplicate or disclose this code are
     *  granted through contract.
     *
     *  @(#) TCP/IP_Network_Developers_Kit 1.93.00.09 08-16-2007 (ndk-c09)
     */
    /*^M
     *  ======== client.c ========^M
     *^M
     *
     */
    
    //--------------------------------------------------------------------------
    // IP Stack Client Demo
    //--------------------------------------------------------------------------
    // Client.c
    //
    // Stack initialization functions
    //
    // Author: Michael A. Denio
    // Copyright 2000, 2001 by Texas Instruments Inc.
    //--------------------------------------------------------------------------
    #include <stdio.h>
    #include <netmain.h>
    #include <_stack.h>
    #include <common/console/console.h>
    #include <common/servers/servers.h>
    
    #include "client.h"
    
    #include <mem.h>
    #include <sys.h>
    #include <tsk.h>
    #include <log.h>
    
    // When USE_OLD_SERVERS set to zero, server daemon is used
    #define USE_OLD_SERVERS 0
    
    //---------------------------------------------------------------------------
    // Title String
    //
    char *VerStr = "\nTCP/IP Stack Example Client\n";
    
    // Our NETCTRL callback functions
    static void   NetworkOpen();
    static void   NetworkClose();
    static void   NetworkIPAddr( IPN IPAddr, uint IfIdx, uint fAdd );
    
    // Fun reporting function
    static void   ServiceReport( uint Item, uint Status, uint Report, HANDLE hCfgEntry );
    
    //---------------------------------------------------------------------------
    // External references
    //
    extern TSK_Obj TSK_idle;
    extern LOG_Obj logTrace;
    
    //---------------------------------------------------------------------------
    // Configuration
    //
    char *HostName    = "tidsp";
    char *LocalIPAddr = "0.0.0.0";                  // Set to "0.0.0.0" for DHCP
    char *LocalIPMask = "255.255.254.0";    // Not used when using DHCP
    char *GatewayIP   = "0.0.0.0";                  // 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
    
    UINT8 DHCP_OPTIONS[] = { DHCPOPT_SERVER_IDENTIFIER, DHCPOPT_ROUTER };
    
    static void SendRawEth();
    static void RecvRawEth();
    
    #define    	TEST_RAW_NC
    #define    	TEST_RAW_SEND
    #undef    	TEST_RAW_RECV
    
    #define     PACKET_SIZE     1000
    #define     PACKET_COUNT    1
    
    //---------------------------------------------------------------------
    // Main Entry Point
    //---------------------------------------------------------------------
    int main()
    {
    
    }
    
    // This callback function is called by the evaluation stack 5 min before the
    // evaluation period times out.
    void evalCallBack()
    {
        printf("The Stack is going to shutdown in 5 min\n");
    }
    
    //
    // Main Thread
    //
    //
    int StackTest()
    {
        int               rc;
        HANDLE            hCfg;
        CI_SERVICE_TELNET telnet;
        CI_SERVICE_HTTP   http;
    
        //
        // THIS MUST BE THE ABSOLUTE FIRST THING DONE IN AN APPLICATION!!
        //
        rc = NC_SystemOpen( NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT );
        if( rc )
        {
            printf("NC_SystemOpen Failed (%d)\n",rc);
            for(;;);
        }
    
        // Print out our banner
        printf(VerStr);
    
        //
        // Create and build the system configuration from scratch.
        //
    
        // Create a new configuration
        hCfg = CfgNew();
        if( !hCfg )
        {
            printf("Unable to create configuration\n");
            goto main_exit;
        }
    
        // The evaluation version of TCP/IP Stack restricts usage of stack
        // to maximum of 24 Hours. If application wants to be notified 5 min
        // before the timeout, it can register a callback function by using
        // the following configuration code section.
        {
            void (*pFxn)() = &evalCallBack;
            CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_SYSINFO_EVALCALLBACK, 0,
                        sizeof(void(*)()), (UINT8*) &pFxn, 0 );
        }
    
    
        // We better validate the length of the supplied names
        if( strlen( DomainName ) >= CFG_DOMAIN_MAX ||
            strlen( HostName ) >= CFG_HOSTNAME_MAX )
        {
            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 *)HostName, 0 );
    
        // If the IP address is specified, manually configure IP and Gateway
        if( inet_addr(LocalIPAddr) )
        {
            CI_IPNET NA;
            CI_ROUTE RT;
            IPN      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 *)&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 *)&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 *)&IPTmp, 0 );
        }
        // Else we specify DHCP
        else
        {
            CI_SERVICE_DHCPC dhcpc;
    
            // Specify DHCP Service on IF-1
            bzero( &dhcpc, sizeof(dhcpc) );
            dhcpc.cisargs.Mode   = CIS_FLG_IFIDXVALID;
            dhcpc.cisargs.IfIdx  = 1;
            dhcpc.cisargs.pCbSrv = &ServiceReport;
            dhcpc.param.pOptions = DHCP_OPTIONS;
            dhcpc.param.len = 2;
            CfgAddEntry( hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT, 0,
                         sizeof(dhcpc), (UINT8 *)&dhcpc, 0 );
        }
    
        // Specify TELNET service for our Console example
        bzero( &telnet, sizeof(telnet) );
        telnet.cisargs.IPAddr = INADDR_ANY;
        telnet.cisargs.pCbSrv = &ServiceReport;
        telnet.param.MaxCon   = 2;
        telnet.param.Callback = &ConsoleOpen;
        CfgAddEntry( hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_TELNET, 0,
                     sizeof(telnet), (UINT8 *)&telnet, 0 );
    
        // Create RAM based WEB files for HTTP
        AddWebFiles();
    
        // HTTP Authentication
        {
            CI_ACCT CA;
    
            // Name our authentication group for HTTP (Max size = 31)
            // This is the authentication "realm" name returned by the HTTP
            // server when authentication is required on group 1.
            CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_SYSINFO_REALM1,
                         0, 30, (UINT8 *)"DSP_CLIENT_DEMO_AUTHENTICATE1", 0 );
    
            // Create a sample user account who is a member of realm 1.
            // The username and password are just "username" and "password"
            strcpy( CA.Username, "username" );
            strcpy( CA.Password, "password" );
            CA.Flags = CFG_ACCTFLG_CH1;  // Make a member of realm 1
            rc = CfgAddEntry( hCfg, CFGTAG_ACCT, CFGITEM_ACCT_REALM,
                              0, sizeof(CI_ACCT), (UINT8 *)&CA, 0 );
        }
    
        // Specify HTTP service
        bzero( &http, sizeof(http) );
        http.cisargs.IPAddr = INADDR_ANY;
        http.cisargs.pCbSrv = &ServiceReport;
        CfgAddEntry( hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_HTTP, 0,
                     sizeof(http), (UINT8 *)&http, 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(uint), (UINT8 *)&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.)
        //
    
        // TCP Transmit buffer size
        rc = 8192;
        CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPTXBUF,
                     CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 );
    
        // TCP Receive buffer size (copy mode)
        rc = 8192;
        CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXBUF,
                     CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 );
    
        // TCP Receive limit (non-copy mode)
        rc = 8192;
        CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXLIMIT,
                     CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 );
    
        // UDP Receive limit
        rc = 8192;
        CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKUDPRXLIMIT,
                     CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 );
    
    #if 0
        // TCP Keep Idle (10 seconds)
        rc = 100;
        //   This is the time a connection is idle before TCP will probe
        CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_TCPKEEPIDLE,
                     CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 );
    
        // TCP Keep Interval (1 second)
        //   This is the time between TCP KEEP probes
        rc = 10;
        CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_TCPKEEPINTVL,
                     CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 );
    
        // TCP Max Keep Idle (5 seconds)
        //   This is the TCP KEEP will probe before dropping the connection
        rc = 50;
        CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_TCPKEEPMAXIDLE,
                     CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 );
    #endif
    
        //
        // 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 );
    
        // Free the WEB files
        RemoveWebFiles();
    
        // Delete Configuration
        CfgFree( hCfg );
    
        // Close the OS
    main_exit:
        NC_SystemClose();
        return(0);
    }
    
    
    
    #if USE_OLD_SERVERS
    
    //
    // System Task Code [ Traditional Servers ]
    //
    static HANDLE hEcho=0,hData=0,hNull=0,hOob=0;
    
    #ifdef _INCLUDE_IPv6_CODE
    static HANDLE hEcho6=0;
    #endif
    
    //
    // NetworkOpen
    //
    // This function is called after the configuration has booted
    //
    static void NetworkOpen()
    {
        // Create our local servers
        hEcho = TaskCreate( echosrv, "EchoSrv", OS_TASKPRINORM, 0x1400, 0, 0, 0 );
        hData = TaskCreate( datasrv, "DataSrv", OS_TASKPRINORM, 0x1400, 0, 0, 0 );
        hNull = TaskCreate( nullsrv, "NullSrv", OS_TASKPRINORM, 0x1400, 0, 0, 0 );
        hOob  = TaskCreate( oobsrv,   "OobSrv", OS_TASKPRINORM, 0x1000, 0, 0, 0 );
    
    #ifdef _INCLUDE_IPv6_CODE
        hEcho6 = TaskCreate( v6echosrv, "V6EchoSrv", OS_TASKPRINORM, 0x1400, 0, 0, 0 );
    #endif
    }
    
    //
    // 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()
    {
        fdCloseSession( hOob );
        fdCloseSession( hNull );
        fdCloseSession( hData );
        fdCloseSession( hEcho );
    
    #ifdef _INCLUDE_IPv6_CODE
        fdCloseSession (hEcho6);
    #endif
    
        // Kill any active console
        ConsoleClose();
    
        // If we opened NETCTRL as NC_PRIORITY_HIGH, we can't
        // kill our task threads until we've given them the
        // opportunity to shutdown. We do this by manually
        // setting our task priority to NC_PRIORITY_LOW.
        TaskSetPri( TaskSelf(), NC_PRIORITY_LOW );
    
        TaskDestroy( hOob );
        TaskDestroy( hNull );
        TaskDestroy( hData );
        TaskDestroy( hEcho );
    }
    
    #else
    
    //
    // System Task Code [ Server Daemon Servers ]
    //
    static HANDLE hEcho=0,hEchoUdp=0,hData=0,hNull=0,hOob=0;
    
    #ifdef _INCLUDE_IPv6_CODE
    static HANDLE hEcho6=0, hEchoUdp6=0, hTelnet6=0, hOob6=0, hWeb6=0;
    #endif
    
    //
    // NetworkOpen
    //
    // This function is called after the configuration has booted
    //
    static void NetworkOpen()
    {
        // Create our local servers
        hEcho = DaemonNew( SOCK_STREAMNC, 0, 7, dtask_tcp_echo,
                           OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
        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 );
    
        // Create the IPv6 Local Servers.
    #ifdef _INCLUDE_IPv6_CODE
        hEcho6    = Daemon6New (SOCK_STREAM, IPV6_UNSPECIFIED_ADDRESS, 7, dtask_tcp_echo6,
                                OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
        hEchoUdp6 = Daemon6New (SOCK_DGRAM, IPV6_UNSPECIFIED_ADDRESS, 7, dtask_udp_echo6,
                                OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 );
        hTelnet6  = Daemon6New (SOCK_STREAM, IPV6_UNSPECIFIED_ADDRESS, 23, 
                                (int(*)(SOCKET,UINT32))telnetClientProcess, OS_TASKPRINORM, OS_TASKSTKLOW,
                                (UINT32)ConsoleOpen, 2 );
        hOob6     = Daemon6New (SOCK_STREAM, IPV6_UNSPECIFIED_ADDRESS, 999, dtask_tcp_oobsrv,
                                OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
        hWeb6     = Daemon6New (SOCK_STREAM, IPV6_UNSPECIFIED_ADDRESS, HTTPPORT, httpClientProcess,
                                OS_TASKPRINORM, OS_TASKSTKHIGH, 0, 4);
    #endif
    }
    
    //
    // 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( hOob );
        DaemonFree( hNull );
        DaemonFree( hData );
        DaemonFree( hEchoUdp );
        DaemonFree( hEcho );
    
    #ifdef _INCLUDE_IPv6_CODE
        Daemon6Free (hEcho6);
        Daemon6Free (hEchoUdp6);
        Daemon6Free (hTelnet6);
        DaemonFree  (hOob6);
        DaemonFree  (hWeb6);
    #endif
    
        // Kill any active console
        ConsoleClose();
    }
    
    #endif
    
    
    //
    // NetworkIPAddr
    //
    // This function is called whenever an IP address binding is
    // added or removed from the system.
    //
    static void NetworkIPAddr( IPN IPAddr, uint IfIdx, uint fAdd )
    {
        static uint fAddGroups = 0;
        IPN IPTmp;
    
        if( fAdd )
            printf("Network Added: ");
        else
            printf("Network Removed: ");
    
        // Print a message
        IPTmp = ntohl( IPAddr );
        printf("If-%d:%d.%d.%d.%d\n", IfIdx,
                (UINT8)(IPTmp>>24)&0xFF, (UINT8)(IPTmp>>16)&0xFF,
                (UINT8)(IPTmp>>8)&0xFF, (UINT8)IPTmp&0xFF );
    
        // This is a good time to join any multicast group we require
        if( fAdd && !fAddGroups )
        {
            fAddGroups = 1;
    //              IGMPJoinHostGroup( inet_addr("224.1.2.3"), IfIdx );
        }
    
        /* Create a Task to send/receive Raw ethernet traffic */
    #ifdef  TEST_RAW_SEND
        TaskCreate( SendRawEth, "TxRawEthTsk", OS_TASKPRINORM, 0x1400, 0, 0, 0 );
    #endif
    #ifdef  TEST_RAW_RECV
        TaskCreate( RecvRawEth, "PerformRawRX", OS_TASKPRIHIGH, 0x1400, 0, 0, 0 );
    #endif    
    }
    
    //
    // DHCP_reset()
    //
    // Code to reset DHCP client by removing it from the active config,
    // and then reinstalling it.
    //
    // Called with:
    // IfIdx    set to the interface (1-n) that is using DHCP.
    // fOwnTask set when called on a new task thread (via TaskCreate()).
    //
    void DHCP_reset( uint IfIdx, uint fOwnTask )
    {
        CI_SERVICE_DHCPC dhcpc;
        HANDLE h;
        int    rc,tmp;
        uint   idx;
    
        // If we were called from a newly created task thread, allow
        // the entity that created us to complete
        if( fOwnTask )
            TaskSleep(500);
    
        // Find DHCP on the supplied interface
        for(idx=1; ; idx++)
        {
            // Find a DHCP entry
            rc = CfgGetEntry( 0, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT,
                              idx, &h );
            if( rc != 1 )
                goto RESET_EXIT;
    
            // Get DHCP entry data
            tmp = sizeof(dhcpc);
            rc = CfgEntryGetData( h, &tmp, (UINT8 *)&dhcpc );
    
            // If not the right entry, continue
            if( (rc<=0) || dhcpc.cisargs.IfIdx != IfIdx )
            {
                CfgEntryDeRef(h);
                h = 0;
                continue;
            }
    
            // This is the entry we want!
    
            // Remove the current DHCP service
            CfgRemoveEntry( 0, h );
    
            // Specify DHCP Service on specified IF
            bzero( &dhcpc, sizeof(dhcpc) );
            dhcpc.cisargs.Mode   = CIS_FLG_IFIDXVALID;
            dhcpc.cisargs.IfIdx  = IfIdx;
            dhcpc.cisargs.pCbSrv = &ServiceReport;
            CfgAddEntry( 0, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT, 0,
                         sizeof(dhcpc), (UINT8 *)&dhcpc, 0 );
            break;
        }
    
    RESET_EXIT:
        // If we are a function, return, otherwise, call TaskExit()
        if( fOwnTask )
            TaskExit();
    }
    
    
    void CheckDHCPOptions();
    
    //
    // Service Status Reports
    //
    // Here's a quick example of using 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( uint Item, uint Status, uint Report, HANDLE h )
    {
        printf( "Service Status: %-9s: %-9s: %-9s: %03d\n",
                TaskName[Item-1], StatusStr[Status],
                ReportStr[Report/256], Report&0xFF );
    
        //
        // Example of adding to the DHCP configuration space
        //
        // When using the DHCP client, the client has full control over access
        // to the first 256 entries in the CFGTAG_SYSINFO space.
        //
        // Note that the DHCP client will erase all CFGTAG_SYSINFO tags except
        // CFGITEM_DHCP_HOSTNAME. If the application needs to keep manual
        // entries in the DHCP tag range, then the code to maintain them should
        // be placed here.
        //
        // Here, we want to manually add a DNS server to the configuration, but
        // we can only do it once DHCP has finished its programming.
        //
        if( Item == CFGITEM_SERVICE_DHCPCLIENT &&
            Status == CIS_SRV_STATUS_ENABLED &&
            (Report == (NETTOOLS_STAT_RUNNING|DHCPCODE_IPADD) ||
             Report == (NETTOOLS_STAT_RUNNING|DHCPCODE_IPRENEW)) )
        {
            IPN IPTmp;
    
            // Manually add the DNS server when specified
            IPTmp = inet_addr(DNSServer);
            if( IPTmp )
                CfgAddEntry( 0, CFGTAG_SYSINFO, CFGITEM_DHCP_DOMAINNAMESERVER,
                             0, sizeof(IPTmp), (UINT8 *)&IPTmp, 0 );
    #if 0        
            // We can now check on what the DHCP server supplied in 
            // response to our DHCP option tags.
            CheckDHCPOptions();   
    #endif
                         
        }
    
        // Reset DHCP client service on failure
        if( Item==CFGITEM_SERVICE_DHCPCLIENT && (Report&~0xFF)==NETTOOLS_STAT_FAULT )
        {
            CI_SERVICE_DHCPC dhcpc;
            int tmp;
    
            // Get DHCP entry data (for index to pass to DHCP_reset).
            tmp = sizeof(dhcpc);
            CfgEntryGetData( h, &tmp, (UINT8 *)&dhcpc );
    
            // Create the task to reset DHCP on its designated IF
            // We must use TaskCreate instead of just calling the function as
            // we are in a callback function.
            TaskCreate( DHCP_reset, "DHCPreset", OS_TASKPRINORM, 0x1000,
                        dhcpc.cisargs.IfIdx, 1, 0 );
        }
    }
    
    void CheckDHCPOptions()
    {
        char IPString[16];
        IPN  IPAddr;
        int  i, rc;
    
        // Now scan for DHCPOPT_SERVER_IDENTIFIER via configuration
        printf("\nDHCP Server ID:\n");
        for(i=1;;i++)
        {
            // Try and get a DNS server
            rc = CfgGetImmediate( 0, CFGTAG_SYSINFO, DHCPOPT_SERVER_IDENTIFIER,
                                  i, 4, (UINT8 *)&IPAddr );
            if( rc != 4 )
                break;
    
            // We got something
    
            // Convert IP to a string:
            NtIPN2Str( IPAddr, IPString );
            printf("DHCP Server %d = '%s'\n", i, IPString);
        }
        if( i==1 )
            printf("None\n\n");
        else
            printf("\n");
    
        // Now scan for DHCPOPT_ROUTER via the configuration
        printf("Router Information:\n");
        for(i=1;;i++)
        {
            // Try and get a DNS server
            rc = CfgGetImmediate( 0, CFGTAG_SYSINFO, DHCPOPT_ROUTER,
                                  i, 4, (UINT8 *)&IPAddr );
            if( rc != 4 )
                break;
    
            // We got something
    
            // Convert IP to a string:
            NtIPN2Str( IPAddr, IPString );
            printf("Router %d = '%s'\n", i, IPString);
        }
        if( i==1 )
            printf("None\n\n");
        else
            printf("\n");
    }
    
    #ifdef TEST_RAW_SEND
    /* Routine to demonstrate sending raw ethernet packets using
     * send() / sendnc() APIs and AF_RAWETH family socket.
     */
    static void SendRawEth()
    {
        char*       pBuffer = NULL;
        ETHHDR*     ptr_eth_header;
        Uint32      rawether_type = 0x300, rawchannel_num = 0;
        UINT8       src_mac[6], dst_mac[6], bData[20];
        int         i, j, val, bytes, retVal;
        SOCKET      sraw = INVALID_SOCKET;
    #ifdef TEST_RAW_NC
        PBM_Handle  hPkt = NULL;
    #endif
    
        /* Allocate the file environment for this task */
        fdOpenSession( TaskSelf() );
    
        /* Demonstrating use of SO_PRIORITY to configure
         * custom properties for all packets travelling
         * using this socket.
         *
         * Here, in this example we will use it for 
         * configuring a distinct EMAC channel number for each
         * of the raw ethernet sockets.
         *
         * For example, Channel Assignment:
         *      Chan 0 - IP
         *      Chan 3 - Raw
         */
        rawchannel_num = 3;
    
        /* Create the raw ethernet socket */
        sraw = socket(AF_RAWETH, SOCK_RAWETH, rawether_type);
        if( sraw == INVALID_SOCKET ) 
        {
            printf("Fail socket, %d\n", fdError());
            fdCloseSession (TaskSelf());
            return;
        }    
    
        /* Configure the transmit device */
        val = 1;
        retVal = setsockopt(sraw, SOL_SOCKET, SO_IFDEVICE, &val, sizeof(val));
    	if(retVal)
    		printf("error in setsockopt \n");
    
        /* Configure the EMAC channel number */
        val = rawchannel_num;
        retVal = setsockopt(sraw, SOL_SOCKET, SO_PRIORITY, &val, sizeof(val));
    	if(retVal)
    		printf("error in setsockopt \n");
    
    
        /* wait for the ethernet link to come up. */
    	TaskSleep(20000);
    
        printf("Raw Eth Task Started ... \n");
    
    
        /* Send the RAW eth packets out */
    	for(j = 0; j < PACKET_COUNT; j++)
        {
    #ifndef  TEST_RAW_NC
    
            if ((pBuffer = mmAlloc (sizeof(char) * PACKET_SIZE)) == NULL)
            {
                printf("OOM ?? \n");
                TaskExit();
            }
    #else
        	if(getsendncbuff(sraw, PACKET_SIZE, (void **) &pBuffer, &hPkt))
            {
                printf("Error: Raw Eth getsendncbuff failed Error:%d\n", fdError());
    		    fdCloseSession( TaskSelf() );
                fdClose(sraw);
    		    TaskExit();
    		}
    #endif
    
    	    /* Configure the Source MAC, Destination MAC, Protocol and Payload */
    	    for (i = 0; i < 6; i++)
    		{
    	    	src_mac[i] = 0x10 + i;
    		}
    
    	    for (i = 0; i < 6; i++)
    	        dst_mac[i] = 0x20 + i + 2;
    
    	    for (i = 0; i < 20; i++)
    	        bData[i] = 0x60 + i;
    
    	    ptr_eth_header = (ETHHDR*)pBuffer;
    
    	    /* Copy the source MAC address as is. */
    	    mmCopy (ptr_eth_header->SrcMac, src_mac, 6);
    
    	    /* Copy the destination MAC address as is. */
    	    mmCopy (ptr_eth_header->DstMac, dst_mac, 6);
    
    	    /* Configure the type in network order. */
    	    ptr_eth_header->Type = HNC16(rawether_type);
    
    	    /* Copy over the payload to the buffer */
    	    mmCopy(pBuffer + ETHHDR_SIZE, bData, 20);
    
    
    #ifndef TEST_RAW_NC
            /* Send the packet using the copy version of send() API. */
            bytes = send(sraw, (char *)pBuffer, PACKET_SIZE, 0);
    #else
            /* Use the no-copy version of send, sendnc() to send out the data */
            bytes = sendnc(sraw, (char *)pBuffer, PACKET_SIZE, hPkt, 0);
    #endif
    
    #ifndef TEST_RAW_NC
            /* If we allocated the buffer, free it up. If we used up the sendnc()
             * API, the buffer will be freed up by the stack.
             */
    	    mmFree(pBuffer);
    #endif
    
    		if( bytes < 0 ) 
            {
                printf("Error: Raw Eth Send failed Error:%d\n", fdError());
    
    #ifdef TEST_RAW_NC
                sendncfree(hPkt);
    #endif
                
    		    fdCloseSession( TaskSelf() );
                fdClose(sraw);
    		    TaskExit();
            }                 
        }
    
        printf("Raw Eth Task Ended ... \n");
    
        fdClose(sraw);
    
    	/* Close the session & kill the task */
        fdCloseSession( TaskSelf() );
        TaskExit();
    }
    #endif
    
    #ifdef TEST_RAW_RECV
    
    /* Routine to demonstrate packet receive using recvnc() API 
     * and AF_RAWETH family sockets.
     */
    static void RecvRawEth()
    {
    	SOCKET      sraw;
    	INT32       val,retVal, count = 0, bytes;
        char*    	pBuf;
        HANDLE   	hBuffer;
    	Uint32      rawchannel_num;
    	ETHHDR*     ptr_eth_header;
    
    	printf ("Raw Eth Rx Task has been started\n");
    
        /* Allocate the file environment for this task */
        fdOpenSession( TaskSelf() );
    
        /* Demonstrating use of SO_PRIORITY to configure
         * custom properties for all packets travelling
         * using this socket.
         *
         * Here, in this example we will use it for 
         * configuring a distinct EMAC channel number for each
         * of the raw ethernet sockets.
         *
         * For example, Channel Assignment:
         *      Chan 0 - IP
         *      Chan 3 - Raw
         */
        rawchannel_num = 3;
    
        /* Create the main UDP listen socket */
        sraw = socket(AF_RAWETH, SOCK_RAWETH, 0x300);
        if( sraw == INVALID_SOCKET )
            return;      
    
        /* Configure the transmit device */
        val = 1;
        retVal = setsockopt(sraw, SOL_SOCKET, SO_IFDEVICE, &val, sizeof(val));
    	if(retVal)
    		printf("error in setsockopt \n");
    
        /* Configure the EMAC channel number as the priority tag for packets */
        val = rawchannel_num;
        retVal = setsockopt(sraw, SOL_SOCKET, SO_PRIORITY, &val, sizeof(val));
    	if(retVal)
    		printf("error in setsockopt \n");
    
        /* Configure the Receive buffer size */
        val = 1000;
        retVal = setsockopt(sraw, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val));
    	if(retVal)
    		printf("error in setsockopt \n");
    
    
        while (count < PACKET_COUNT) 
        {
    		bytes = (int)recvnc( sraw, (void **)&pBuf, 0, &hBuffer );
    
            if (bytes < 0)
            {
    			/* Receive failed: Close the session & kill the task */
    			printf("Receive failed after packets Error:%d\n",fdError());			
    		    fdCloseSession( TaskSelf() );
    		    TaskExit();
            }
    		else
    		{
        		ptr_eth_header = (ETHHDR*)pBuf;
    
    		    printf("Received RAW ETH packet, len: %d \n", PBM_getValidLen((PBM_Handle)hBuffer));
    			printf("Dst MAC Address = %02x-%02x-%02x-%02x-%02x-%02x Src MAC Address = %02x-%02x-%02x-%02x-%02x-%02x Eth Type = %d Data = %s \n",
               			ptr_eth_header->DstMac[0],ptr_eth_header->DstMac[1],ptr_eth_header->DstMac[2],
               			ptr_eth_header->DstMac[3],ptr_eth_header->DstMac[4],ptr_eth_header->DstMac[5],
               			ptr_eth_header->SrcMac[0],ptr_eth_header->SrcMac[1],ptr_eth_header->SrcMac[2],
               			ptr_eth_header->SrcMac[3],ptr_eth_header->SrcMac[4],ptr_eth_header->SrcMac[5],
               			ntohs(ptr_eth_header->Type), (pBuf + ETHHDR_SIZE));
    		}
    
    
    		count++;
    
    		/* Clean out the buffer */
    		recvncfree( hBuffer );
        }
             
    	/* Close the session & kill the task */
        fdCloseSession( TaskSelf() );
        TaskExit();
    
        return;
    }
    
    #endif
    

  • Sorry, I've requested complete project, so that I can build it and attach it for you.

    I think, already you have asked this NDK question for OMAPL137, I request you to go through those links which I shared to you already.
    I hope, you can get the example from that legacy download link.
    We have ready made NDK example for OMAPL138 and port it to OMAPL137. ( I have seen some of the customers ported to OMAPL137 and using it)
  • Hi Titus,

    My complete project,client for omapl137 is attached...i tried what u said last in last conversation but i am not getting it properly.

    please go through it.

    thank youclients.rar 

  • Please follow the suggestion in the below post and port into C6747.
    e2e.ti.com/.../1832623

    C6747 and C6748 is almost same, refer to both data sheets for the difference.
  • Hi Titus,

    How can we modify....where should we modify....?

    when i load .out file of client ,it shows "EMAC OPEN RETURNED ERROR"

    HOW TO OVER COME WITH THIS...

    thank you
  • Please don't reply or follow up on this post as its different problem and also you opened new post for this problem.
    Thanks for your understanding.
  • Mohammad,

    I just came across your post. If you're still stuck on this, the answer is you need to download/install DSP/BIOS. You can get that from here:

    software-dl.ti.com/.../index_FDS.html

    Steve