4.7.6.1.3.1. Enet lwIP Example

4.7.6.1.3.1.1. Building LWIP example

  • Enabling specific features in the test

    To configure what gets built in the example, navigate to the example directory pdk/packages/ti/drv/enet/examples/enet_lwip_example and find the lwipcfg.h file. Inside, change the macros corresponding to the program that you wish to build to 1.

    For example, if udpecho is required, set:

    #define LWIP_UDPECHO_APP        1
    

    Note

    The heap memory may need to be increased in the FreeRTOSConfig.h file to accomodate multiple apps.

  • To build the lwip example, issue the following command:

    make -s enet_lwip_example_freertos
    

4.7.6.1.3.1.2. Running LWIP example

  • Load and run the enet_lwip_example image from the corresponding binaries folder.

  • The setup requires a LAN cable to be connected between the device and a multiport-router for the link status to be UP and aquire an IP address.

  • Connect the LAN cable between the same router and Laptop/PC from where the ping/echo tests are run.

  • Wait until the local interface IP is assigned and printed on the console like below.

    Starting lwIP, local interface IP is dhcp-enabled
    CPSW_2G Test on MCU NAVSS
    EnetPhy_bindDriver: PHY 0: OUI:080028 Model:23 Ver:01 <-> 'dp83867' : OK
    PHY 0 is alive
    Host MAC address: 70:ff:76:01:02:03
    [LWIPIF_LWIP] CPSW has been started successfully
    [LWIPIF_LWIP] NETIF INIT SUCCESS
    status_callback==UP, local interface IP is 0.0.0.0
    Cpsw_handleLinkUp: Port 1: Link up: 100-Mbps Full-Duplex
    MAC Port 1: link up
    link_callback==UP
    status_callback==UP, local interface IP is 192.168.0.9
    Initializing apps
    UDP server listening on port 5001
    

4.7.6.1.3.1.3. Testing LWIP example

Prerequisites: LAN cable setup and device link is UP and Local interface IP is successfully aquired.

  • Ping test

    ping -t <ip_addr>
    ping -t 192.168.0.9
    
  • UDP/ TCP echo test

    Download echotool from this website and execute the commands to see the response.

    • UDP echo command:

      echotool.exe <ip_addr> /p udp /r 7 /n 0
      echotool.exe 192.168.0.9 /p udp /r 7 /n 0
      
    • TCP echo command:

      echotool.exe <ip_addr> /p tcp /r 7 /n 0
      echotool.exe 192.168.0.9 /p tcp /r 7 /n 0
      
  • iperf test

    Download iperf2 from iperf website and execute the commands to see the response.

    • iperf TCP test command:

      iperf.exe -c <ip_addr> -r
      iperf.exe -c 192.168.0.9 -r
      
    • iperf UDP test command:

      iperf.exe -c <ip_addr> -r -u
      iperf.exe -c 192.168.0.9 -r -u
      

Static IP

The Enet lwIP example uses DHCP by default. If static IP needs to be tested, the following two config options need to be disabled in examples/enet_lwip_example/lwipcfg.h.

#define USE_DHCP    0
#define USE_AUTOIP  0

The IP address, gateway and netmask can be set in the same lwipcfg.h file.

#define LWIP_PORT_INIT_IPADDR(addr)   IP4_ADDR((addr), 192,168,1,200)
#define LWIP_PORT_INIT_GW(addr)       IP4_ADDR((addr), 192,168,1,1)
#define LWIP_PORT_INIT_NETMASK(addr)  IP4_ADDR((addr), 255,255,255,0)