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.

How does NDK handle Ethernet link down?

Other Parts Discussed in Thread: SYSBIOS

Hi,

I am using BIOS version 6.33.04.39 with NDK version 2.21.01.38.  These were both installed as part of MCU SDK 1.00.01.74.  I am developing an application for the Stellaris LM3S9B92 which was built leveraging an example called TCPEcho from the MCU SDK examples directory.  My question is regarding how link down and link up events should be handled by NDK.

Everything generally works for me when I boot up this project.  I get an IP address on my Ethernet interface, am able to ping the board and talk to my custom network components.  I can even start up without the Ethernet cable plugged in and when I plug it in I get an IP address and everything progresses normally.  

The problem comes in when I try to run an Ethernet cable pull test.  I'm getting no indication that the Ethernet link has gone down and even after a few minutes, NDK has not relinquished the IP address that it was assigned via DHCP.  I am able to determine the link status by polling the appropriate Stellaris register, but then when I determine that the link has gone down, I'm not sure how to properly restart NDK.  I should also note that my link status and speed LEDs are working as designed.

Any suggestions would be greatly appreciated.

Thanks,

Lance

  • Hi Lance,

    Unfortunately the Ethernet driver is missing an API to do this.  I've filed a bug to ensure that this issue gets resolved:

    SDOCM00102004 TI-RTOS Ethernet driver needs API for determining link status

    But, you should be able to determine the link status by reading Register 19: Ethernet PHY Management Register 1, bit field 2.  You can find the details for that in the datasheet:

    http://www.ti.com/lit/ds/symlink/lm3s9b96.pdf

    Steve

  • Hi Steve,

    Thanks for replying and for entering the bug report.  Reading the PHY management register is indeed working for me to determine link status.  For the 2nd part of my question, do you have recommendations on how to reset NDK when link down is detected?  All of the NDK initialization and startup is handled by generated configuration code rather than application code so this is the first time I've had to deal with it.  I've reviewed the NDK documentation and found NC_NetStart and NC_NetStop functions.  I'm planning to try these out today.  Let me know if there is a better option.

    Thanks,

    Lance

  • Hi Lance,

    Yes, you should call the NetStop with an argument of 1:

    NC_NetStop(1);

    The '1' is for reboot.  Passing an argument of '0' will cause the stack to shut down.

    Steve

  • Hi Steve,

    Hopefully you are still following this thread.  I'll post a new topic if I don't hear from you.

    I'm having an issue stopping and restarting NDK.  I didn't notice this before because I had disabled most debug printf statements in NDK but I turned them back on and discovered this issue.

    The problem occurs after NC_NetStop() is called and eventually invokes a shutdown.  When NIMUShutdown() is processing the list of devices (nimu_mcb.devices) it removes the node from the list and then calls mmfree() on the ptr.  This mmfree() call results in a "mmFree: double free" error message out of the memory manager.  I looked into this further and found out that the actual cause of this problem is that in the file packages\ti\drivers\EMAC.c in the function EMAC_NIMUInit() a statically allocated device is passed to the function NIMURegister().

    From EMAC.c - EMAC_NIMUInit():
    /* Register the device with NIMU */
    if (NIMURegister(&EMAC_device) < 0) {
         Log_print0(Diags_USER1, "EMAC: failed to register with NIMU");
         return (-1);
    }

    So when mmFree casts that pointer to a MEMORYBLOCK structure it ends up pointing into some other data structure and thinks that the BUSY flag is not set for that block.

    I know how to fix this by using mmAlloc() to create EMAC_device rather than using statically allocated memory, but the problem is I have no idea how to rebuild EMAC.c.  I've tried re-building both the NDK and StellarisWare with a forced compiler error in that file, but neither of those builds seem to include that file.  Is this part of the SYSBIOS build?  If so, how do I rebuild it?

    I greatly appreciate your continued support.

    Lance

  • Lance,

    This is a bug in the driver.

    Good news is that it's already been fixed, but that means you would need to upgrade to a newer version of TI-RTOS (note that MCUSDK has had a name change and the product is now known as TI-RTOS).

    I see that it's fixed in version TIRTOS 1_01_00_25.  You can find that version on the TI-RTOS download page.

    Note also that this is not the latest version on that download page.  You need to download this slightly older version because support for the LM3S9B92 has been dropped in TI-RTOS 1.10.00.23 (and future releases).  From the 1.10.00.23 release notes:

    "Support for LM3 devices has been discontinued. If required a patch release off the 1.01 release can be made."

    Steve

  • Thanks for the excellent support Steve.  I've made a note of that version of code for my next project, but I have just hacked around the problem for now to keep myself on schedule.

    Lance

  • Hi Steve,

    I have the same problem, when I unplug the ethernet link I can't manage to make an http get. I want to restart the interface but can't manage to find where the NC_NetStop function is located, what header do I need to include ?

    Thank you in advance,

    Best Regards,

  • Hi Yannick,
    To get your question answered and tracked better can you make a fresh post for your issue?

    Thanks,
    Moses