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.

RTOS/PROCESSOR-SDK-AM437X: Ethernet link status

Part Number: PROCESSOR-SDK-AM437X

Tool/software: TI-RTOS


I want to read the link status of Ethernet interfaces of AM437x.


I´ve tried to pass a hook funcion to the NDK via NC_setLinkHook(). It did not work.


I am calling  emac_poll() and it always return EMAC_LINKSTATUS_NOLINK.

At at initialization this is displayed on the terminal, which is very strange:
SetPhyMode:000021e1 Auto:1, FD10:64, HD10:32, FD100:256, HD100:128, FD1000:8192 LPBK:0

When I disconnect and connect again the cable, this is displayed on the terminal:
Phy: 4, NegMode 01e1, NWAYadvertise 01e1, NWAYREadvertise 45e1
Negotiated connection: FullDuplex 100 Mbs.

The driver detects the change but emac_poll() always return EMAC_LINKSTATUS_NOLINK.

If seems ENETPHY_GetLinked is reading the correct value, but EMAC_poll_v4 only calls it when (tickChange == 1). In this case, should p_info->link_status set to 0? Could it keep the previous value?

Installed itens:
CCS 7.2
GCC ARM Compiler 4.9.3
processor_sdk_rtos_am437x  4.00.00.04
am437x PDK v1.0.7
bios 6.46.05.55
xdctools 3.32.02.25_core

Board: AM437x Starter Kit


regards,
Marcio.

  • The RTOS team have been notified. They will respond here.
  • Hi Marcio,

    I don't quite follow why p_info->link_status need to be set to 0. I think if ENETPHY_GetLinked is reading the correct value, it's expected tickChange = 1. You may try to step into the ENETPHY_Tic() in board\src\evmAM437x\device\enet_phy.c function to find out why tickChange is not 1.

    Regards,
    Garrett
  • Hi Garrett,

    Ok. I´ll debug ENETPHY_Tic().

    ENETPHY_GetLinked() is called by some other piece of code (NDK maybe) at initialization. If a put breakpoint in ENETPHY_GetLinked()  the program stops there. The value of *PhyState seems to be correct.

    Regarding to the message displayed at initialization, could you check whether this statment in ENETPHY_SetPhyMode is correct? I don't know exactly the program wants to display. For instance, FD100:1 instead of FD100:256.

         ENET_PHY_log("SetPhyMode:%08X Auto:%d, FD10:%d, HD10:%d, FD100:%d, HD100:%d, FD1000:%d LPBK:%d\n", PhyMode,
         (PhyMode & NWAY_AUTO), (PhyMode & MII_NWAY_FD10),(PhyMode & MII_NWAY_HD10),(PhyMode & MII_NWAY_FD100),
         (PhyMode & MII_NWAY_HD100), (PhyMode & NWAY_FD1000),
         (PhyMode & NWAY_LPBK)  );
    

    regards,

    Marcio.

    Edited:

    A comment says "ENETPHY_Tic is called every 10 mili seconds to process Phy states".

    Another comment says "Called every 100 milli Seconds, returns TRUE if there has been a mode change".

    ENETPHY_Tic returns 0  and mdioStatus = MDIO_EVENT_NOCHANGE when status of the link has not changed.

    If ENETPHY_Tic returns 1 only when the status of the link has changed, EMAC_poll_v4 would return the link status only when it has changed, all other times it would return 0 (link down). And worst, EMAC_poll_v4 would returns EMAC_DRV_RESULT_OK.

    If EMAC_poll_v4 evaluates p_info->link_status only when the status of the link has changed, e.i. when ENETPHY_Tic returns 1, p_info->link_status will keep the previous value, which seems ok.

    Edited 2:

    I´ve changed EMAC_poll_v4 to store the link status info in an static array named mLinkStatusInfo. The link status is updated only when the status has changed. It seems to resolved my problem.

    I am attaching the files .I´d appreciate if you revise the changes.
     
    The constants defined in emac_drv.h, do not reflet the values returned by EMAC_poll_v4. I do not know whether the EMAC_poll_v4 or the constants should be fixed. I do not know whether they a used in another place. EMAC_poll_v4 returns the following values:

    #define EMAC_LINKSTATUS_NOLINK          0
    /**< Link Status: No Link                                                   */
    #define EMAC_LINKSTATUS_HD10            2
    /**< Link Status: Half Duplex 10Mbps                                        */
    #define EMAC_LINKSTATUS_FD10            3
    /**< Link Status: Full Duplex 10Mbps                                        */
    #define EMAC_LINKSTATUS_HD100           4
    /**< Link Status: Half Duplex 100Mbps                                       */
    #define EMAC_LINKSTATUS_FD100           5
    /**< Link Status: Full Duplex 100Mbps                                       */
    #define EMAC_LINKSTATUS_FD1000          7
    /**< Link Status: Full Duplex 1000Mbps     

    MB-AM437x-EMAC-20171113.zip   

     

  • Marcio,

    The statement is to display each bit of the PHY KSZ9031RNX register on AM437x IDK, see the register definitions in ww1.microchip.com/downloads/en/DeviceDoc/KSZ9031RNX.pdf, for example: FD100:256 represents Full duplex - bit 8 of register 0. It's probably a bit more clear if displaying hex values.

    Thanks for the details. Your changes make sense. I will discuss with team internally.

    Regards,
    Garrett