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.

enet_io: Ethernet connection doesn't work with static IP

Other Parts Discussed in Thread: EK-TM4C1294XL

My working environment:

Code Composer Studio Version: 6.1.3.00034
TivaWare_C_Series-2.1.3.156
Board: EK-TM4C129XL Rev D
Windows 10 x64

Code sample: enet_io, path C:\ti\TivaWare_C_Series-2.1.3.156\examples\boards\ek-tm4c1294xl\enet_io

When I execute this code sample, I see the following information in debug UART output:

Waiting for IP.
Waiting for link.
Waiting for IP address.
IP Address: 169.254.104.26                    // connects after 40 seconds, OK

To use static IP, I make the following change in the code:

//    lwIPInit(g_ui32SysClock, pui8MACArray, 0, 0, 0, IPADDR_USE_DHCP);
    lwIPInit(g_ui32SysClock, pui8MACArray, 0xC0A80A01, 0xFFFFFF00, 0, IPADDR_USE_STATIC);   // // 192.168.10.1

PC network adapter is set to static IP 192.168.10.200, subnet mask 255.255.255.0

UART output:

Waiting for IP.
Waiting for link.
Waiting for IP address.

The board never connects. So, DHCP is working, and static IP doesn't work.

Code sample: enet_lwip doesn't work at all, both in DHCP and static IP.

For reference: old EK-LM3S9B92 board with enet_lwip code sample from Stellaris development kip works properly on the same computer, both with DHCP and static IP.

  • Hello,

     0xC0A80A01 used in lwipinit() is not the IP address you mentioned: IP 192.168.10.200

    Yo also need the gateway address for lwipinit() function.

    regards,

    QJ

  • hi Alex,
    first you have to set in lwipopts.h (- Configuration file for lwIP)

    in DHCP section
    #define LWIP_DHCP 0

    in AUTOIP section
    #define LWIP_AUTOIP 0

    then in your enet_io you should define the static ip,netmask,and gateway,


    //*****************************************************************************
    //
    //Definiranje IP addr, SUBNET , Gateway za staticki IP, ako e dinamicki so DHCP Ne se koristat
    //
    //*****************************************************************************
    #define IP_ADDR0 192
    #define IP_ADDR1 168
    #define IP_ADDR2 1
    #define IP_ADDR3 3
    /* Set Netmask */
    #define NET_MASK0 255
    #define NET_MASK1 255
    #define NET_MASK2 255
    #define NET_MASK3 0
    /* Set IP Gateway */
    #define IP_GW0 192
    #define IP_GW1 168
    #define IP_GW2 1
    #define IP_GW3 1

    -- in main()

    uint32_t ui32IPaddr,ui32NetMask,ui32GW,i;

    /* IP address */
    ui32IPaddr=((uint32_t)((IP_ADDR0) & 0xff) << 24) |
    ((uint32_t)((IP_ADDR1) & 0xff) << 16) |
    ((uint32_t)((IP_ADDR2) & 0xff) << 8) |
    (uint32_t)((IP_ADDR3) & 0xff);
    ui32NetMask=((uint32_t)((NET_MASK0) & 0xff) << 24) |
    ((uint32_t)((NET_MASK1) & 0xff) << 16) |
    ((uint32_t)((NET_MASK2) & 0xff) << 8) |
    (uint32_t)((NET_MASK3) & 0xff);
    ui32GW=((uint32_t)((IP_GW0) & 0xff) << 24) |
    ((uint32_t)((IP_GW1) & 0xff) << 16) |
    ((uint32_t)((IP_GW2) & 0xff) << 8) |
    (uint32_t)((IP_GW3) & 0xff);


    then you should call

    lwIPInit(g_ui32SysClock, pui8MACArray,ui32IPaddr,ui32NetMask, ui32GW,IPADDR_USE_STATIC);

    I think that will help you.

    regards