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.

Problem with enet_lwip running on EK-TM4C1294XL LaunchPad

Other Parts Discussed in Thread: EK-TM4C1294XL

I am having problems withe the enet_lwip example for the EK-TM4C1294XL LaunchPad.

As the software header text says:

//! This example application demonstrates the operation of the Tiva

//! Ethernet controller using the lwIP TCP/IP Stack. DHCP is used to obtain

//! an Ethernet address. If DHCP times out without obtaining an address,

//! AutoIP will be used to obtain a link-local address. The address that is

//! selected will be shown on the UART.

If I connect using a network connection that has a DHCP server, everything is fine, with the IP address reported on the Virtual COM Port. If I leave the Ethernet disconnected, I expect an IP address to be assigned by AutoIP and reported on the Virtual COM Port. The problem is, it never does. If I use the DK-LM3S9D96 development board and its example, everything is fine and after about 20 seconds an AutoIP generated IP address is displayed.

If someone has an EK-TM4C1294XL LaunchPad, could you please load the enet_lwip example, connect to the Virtual COM Port, without an Ethernet connection, and tell me if, after a delay, an IP address is reported.

At the moment this looks like a bug, but no one has reported it after many months.

  • Hello Vito

    Not really seen the issue during test. Let me check again.

    Regards
    Amit
  • Just to add to the above, when the application is started, the Virtual COM Port messages are:


            Waiting for IP.

            Waiting for link.

    If an Ethernet cable is plugged in, then

            Waiting for IP address.

    That's as far as it gets.


    I've even tried enet_io, with the same behaviour.

  • Hello Vito Ignazzi,

    I checked the same. Loaded the code w/o connecting the ethernet cable and it went till "Waiting for link". On connecting the cable after a minute, the COM Port immediately gave a "Waiting for IP address" followed by the IP address in about 20 seconds.

    Regards
    Amit
  • Interesting thing is that for the LM3S9D96 development board, there was no need to connect the Ethernet cable and it would present an IP address. This sounds like the correct behaviour to me.
  • With an Ethernet calbe plugged in, I get:

            For enet_lwip: no IP address

            For enet_io: no IP address

            For enet_weather: IP address 169.254.207.171

    However, I am not able to ping 169.254.207.171, but this may be a problem outside the board/code.

  • Hello Vito Casa

    In the code file enet_lwip.c can you comment the code from line 188-209, recompile and then check?

    Regards
    Amit
  • Hi Amit,

    That fixed it. (Not a good way to implement an LED flashing routine!)

    I managed to find out, before the fix, that AutoIP did indeed generate an IP address, but it took 10 minutes and 50 seconds.

    Once lines 188-209 are commented out, the time to generate an IP address reduced to 39 seconds. It is interesting to note, that for enet_weather, it takes just 27 seconds.

    Thanks for pursuing this and getting me an answer. Much appreciated. I can now move on.

    Regards, Vito

  • Hello Vito,

    Thanks for confirming as well. Indeed it is a not good way to get to AutoIP ir detecting a connect post initialization. We will try to fix it for the next TivaWare release with a minimal blink...

    Regards
    Amit
  • Hi Amit,

    For the next release, and I think we are talking about the same thing, all that needs to be done is comment out lines 197, 198, 207 and 208. This way you get the quick AutoIP adress and maintain the flashing LED display indicating that an IP address is not yet available. It's basically what the LM3S9D96 enet_lwip does.

    Don't forget to also update enet_io.

    While I've got you, the DK-LM3S9D96 example enet_lwip has one other very nice feature. Even if an Ethernet calbe is not connected, it would AutoIP an IP address. This is very handy.

    Regards, Vito

  • Hello Vito

    I thought from your post that if the cable is not connected on the EK-TM4C129 LaunchPad and the lines are commented the AutoIP works in 39 seconds. Or is it that after connecting a cable the IP address is acquired by the DHCP in 39 seconds

    Please clarify

    Regards
    Amit
  • The times of 39 seconds is for Ethernet cable connected and no DHCP server (therefoe AutoIP kicks in). If the Ethernet cable is not connected, it never gets an AutoIP IP generated IP address, unlike the DK-LM3S9D96.
  • Hello Vito,

    OK Thanks that clarifies. I need to check why AutoIP does not start up....

    Regards
    Amit
  • Some insights into what was actually happening:

    1) lwIPHostTimerHandler is being called by lwip at a rate of 10 times per second (that is, every 100 ms) [as determined by the parameters input to SysTickPeriodSet and lwIPTimer].

    2) The LED flashing routine was taking about 5 seconds to complete.

    Therefore, lwIPHostTimerHandler, rather than completing its tasks in well under 100 ms, was taking 5000 ms to execute its tasks. The CPU was basically starved of any non-interrupt time. This resulted in everything slowing down.

    Amit,

    It would be nice if the example was improved in two ways:

    1) Get the whole search for a DHCP server and if unsuccessful get an AutoIP IP address assigned in 10 seconds (or 20 seconds at the most) [This can be done by simply altering the input parameter to lwIPTimer from 10 to 20 or the halving the input parameter to SysTickPeriodSet, but this may have other repercussions.]

    2) Get an IP address assigned even if there is no Ethernet connection.

    Regards, Vito

  • Hello Vito

    I would prefer to have Ethernet link established before doing an AutoIP if DHCP does not assign a IP Address.

    Regards
    Amit
  • Hi Amit,

    I like the DK-LM39D96's example  behaviour, which was to assign an IP address regardless of whether an Ethernet cable was attached.

    The reason for this is that, about 20 seconds after the device was switched on it would have an IP address. If I then wanted to talk over Ethernet (using a custom application, which requires the IP addres to be entered), the IP address was immediately available to me and I could proceed without waitng (after plugging the Ethernet cable in).

    Not a very strong preference, which would be even less of a concern if AutoIP was called sooner so that an IP address is avialable, say, 10 seconds after the Ethernet cable is plugged in.

    Regards, Vito

  • Vito,

    Thanks for explaining what was happening. I was noticing some serious problems, and suspected that my clock was not running at full speed. But your comment was the hint I needed to look into fixing lwIPHostTimerHandler.

    For the benefit of other people who run into this issue on the 1294, I'll explain how you can fix this in your source. Just find the final loop in lwIPHostTimerHandler - the one that starts with

    if ((ui32NewIPAddress == 0) || ...

    and move it to the end of main(), inside the while (1) that loops forever. You'll have to change from the local variable, ui32NewIPAddress, to the global variable, g_ui32IPAddress, but that will still work because lwIPHostTimerHandler keeps that global up to date.

    The entire enet_lwip example runs perfectly after this change and quickly connects, even without DHCP active. (note that I did not make any changes to assign an AutoIP if there is no wired connection - I'll leave that as a separate exercise).

    Brian
  • Hi Amit,

    I was having the same problem as Vito faced. Glad to find out that it is able to be shortened to 39 seconds.

    But, is there anyway to further shorten the duration of this process?

    Best Regards,
    Mike

  • Hi Vito,

    I'm interested in the method (2), could you elaborate more how to assign IP address directly if there is no Ethernet connection.

    Mike
  • Mike,

    Here are my notes relatignto this subject:

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

    lwIPHostTimerHandler is called by lwip every 100 ms to allow the top-level application to perform periodic tasks. (Such tasks could be incorporated into a 100 ms periodic task and lwIPHostTimerHandler could go!)

    The frequency of lwIPHostTimerHandler being called can be adjusted by the parameter for SysTickPeriodSet and/or lwIPTimer. Here’s the result fo some experimentation

    SysTickPeriodSet

    lwIPTimer

    IP add avail

    (secs)

    lwIPHostTimerHandler

    call rate (Hz)

    Call period

     

    1200000

    1

    360

    1

    1000 ms

    1200000

    10

    38.1

    10

    100 ms

    1200000

    100

    6

    100

    10 ms

    120000

    1

    38.1

    10

    100 ms

    120000

    10

    5.8

    100

    10 ms

    120000

    100

    ~2

    1000

    1 ms

    Enet_lwip values shown in blue. Maybe lwIPTimer would be better served with an input parameter of 20 or 50. Maybe HOST_TMR_INTERVAL could be set to 0 and the required tasks handled with application periodic tasks.

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

    The main number you want to look at is "IP add avail".  Hope it makes sense.

     

  • Hi Vito,

    I just tried IwIPTimer(100), and it is about 6 seconds to get the connection established. Thanks for sharing :D.

    Best Regards,
    Mike
  • Hi Vito,

    I've found another method which is just changing the "IPADDR_USER_DHCP" to "IPADDR_USE_AUTOIP" in main.c, since my application is mainly about to communicate the board with pc.

    //lwIPInit(g_ui32SysClock, pui8MACArray, 0, 0, 0, IPADDR_USE_DHCP);
    lwIPInit(g_ui32SysClock, pui8MACArray, 0, 0, 0, IPADDR_USE_AUTOIP);


    Best Regards,
    Mike
  • Another method is to use "IPADDR_USE_AUTOIP" in lwIPInit.

    //lwIPInit(g_ui32SysClock, pui8MACArray, 0, 0, 0, IPADDR_USE_DHCP);
    lwIPInit(g_ui32SysClock, pui8MACArray, 0, 0, 0, IPADDR_USE_AUTOIP);
  • I am using TM4C129EXL, in my case lwIPHostTimerHandler() does not been called at all. but the original code works fine, what I have done is create a  new project, copy and paste all the code to the new project, the project could compile, but the lwIPHostTimerHandler() is never touched by the code, seems some issue with triggering the interrupt.  the sample I used is the enet_lwip sample.

    Shan

  • Hello Shan,

    Did you copy the contents of the startup_ccs.c file as well?

    Regards
    Amit
  • I did not, can I know what is inside that file ?

    Shan
  • Hello Shan,

    I would suggest checking the files that you manually copied the contents of in the project,

    Regards
    Amit
  • Hi, Amit, I have solved the issue, and right now the code is working, can you tell me when and where the startup_ccs.c is implemented by the TM4C device?

    Thanks

    Shan
  • Hello Shan

    startup_ccs.c is execute by the CPU at boot to load the SP and PC.

    Regards
    Amit
  • i am using tm4c1294xl with ethernet connected to wifi of pc i am not able to get IP address when i loaded enet_lwip example. how to get ip address on ubuntu 14.04LTS