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.

Starterware/SW-EK-TM4C1294XL: Issue in Configure STATIC IP address

Part Number: SW-EK-TM4C1294XL

Tool/software: Starterware

Dear All

Just imported the enet_lwip example and started playing, it words when I configure it with a DHCP IP address and able to be pinged back with PC. However, when I try to configure it with a STATIC IP address with LWIP_DHCP option set to 1, my IP address is failed to set and all end up with 0s. Traced the lwiplib.c and found the following:

1.       lwIPLinkDetect() is running at regular interval (called by lwIPServiceTimer()) when LWIP_DHCP option is set, and where when a Link state is changed it clears all IP settings by following code snip:

   //

    // Clear any address information from the network interface.

    //

    ip_addr.addr = 0;

    net_mask.addr = 0;

    gw_addr.addr = 0;

    netif_set_addr(&g_sNetIF, &ip_addr, &net_mask, &gw_addr);

                I don’t know the definition of a Link state change, is it caused by initialization to a IP address?

2.       Clear LWIP_DHCP to 0, STATIC IP address works fine. But I need to leave both option open to customers.

3.       Checked equivalent StellarisWare we has been using, it seems like it checks the Link state in LwIpServiceTimers() too,  but do not clear any settings. Wonder whether it is a bug?

 

Anyone had similar issue please?

  • Hi Ping,

    The Ethernet client might initialize IP shown below. I believe a bug exists (tiva129.c) abstraction layer in duplex etc.... The auto IP mode is similar to static but it checks DHCP first like a windows client might do.

    //Stellarisware client: Initialize lwIP with the system clock, MAC and use DHCP.
      lwIPInit(ui32SysClock, pucMACArray, //0, 0, 0,
            DEF_IPADDR, DEF_GATEWAY_ADDR, DEF_NET_MASK,
           (bUseDHCP ? IPADDR_USE_DHCP : IPADDR_USE_STATIC)); // IPADDR_USE_AUTOIP 
    //
    // Tivaware client: Initialize lwIP with the system clock, MAC and use DHCP.
    //
    lwIPInit(ui32SysClock, g_sEnet.pui8MACAddr, 0, 0, 0, IPADDR_USE_DHCP);

  • Hi, BP101

    Thanks for reply, are you able to get TivaWare works with Static IP like below with lwipopt.h setting:

    #define LWIP_DHCP 1

    /* TiveWare: to do static IP line work */
    lwIPInit(g_ui32SysClock, pui8MACArray,IpAddr, IpMask, GateWay, IPADDR_USE_STATIC);

    I can only get it working with LWIP_DHCP clear to 0 . :(

    Ping
  • Hi Ping,

    I hope the below post may provide some insights in acquiring static address if the DHCP does not assign IP address. First try to change from IPADDR_USE_STATIC to IPADDR_USE_AUTOIP.
    e2e.ti.com/.../1458810
  • Hi Ping,

    As Charles mentions Auto IP does the same thing as static IP but gives us a preset IP address by LWIP (autoip.c) client.

    Last time checked static function it worked after adding lines to client..

    //
    //! The Default Auto IP address to be used.
    //
    #ifndef DEF_IPADDR
    #define DEF_IPADDR          ((192u << 24) | (168 << 16) | (10 << 8) | 1)
    #endif
    
    //
    //! The Default Gateway address to be used.
    //
    #ifndef DEF_GATEWAY_ADDR
    #define DEF_GATEWAY_ADDR    ((255u << 24) | (255 << 16) | (255 << 8) | 0)
    #endif
    
    //
    //! The Default Network mask to be used.
    //
    #ifndef DEF_NET_MASK
    #define DEF_NET_MASK        ((255u << 24) | (255 << 16) | (255 << 8) | 0)
    #endif

  • Hi, All

    Thanks for reply. tried AUTOIP, and it works fine, but I don't think it has control over which IpAddr to use. the definition above is ignored

    I ended up with same one every time it runs, and it is a valid one between 169.254.0.0 - 169.254.255.255 as defined by standard.

    Ping

  • Hi Ping,

    You are correct the auto IP is not considered static IP by IEEE and acts more like local DHCP client. You have to still state IPADDR_USE_STATIC for it to assign the above static IP address or use it to fall back when DHCP fails. The Boolean test selects which way DHCP or STATIC IP based on the flag passed during LwIPIinit() call. There are 3 ways to assign an IP address.

    The code above I posted should provide a static IP and might deserves question answered. Not clear why note say Auto IP as it always produced the static IP with Stellarisware.