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.

[参考译文] TM4C129ENCPDT:断开/连接线路时以太网连接丢失-链路状态

Guru**** 2386620 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1273577/tm4c129encpdt-ethernet-connection-lost-when-disconnect-connect-of-wire---link-status

器件型号:TM4C129ENCPDT

https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/524931/1909843?tisearch=e2e-sitesearch&keymatch=EPHY_STS#1909843报告的旧故障 似乎未包含在 Tivaware 的新版本(版本2.2.0.295)中的文件 Tiva-tm4c129.c 中。

该解决方案在调用下行链路功能之前读取一个寄存器以获得链路状态:

/*在这种情况下,我们会继续,因为我们可能需要重新配置
* MAC 取决于速度和半双工/半双工设置。
*/

否则
{
//这里是我的解决方案
/*通过读取基本模式状态寄存器来修复链路状态位错误*/
EMCPHYRead (EMAC0_BASE、PHY_PHY_ADDR、EPHY_BMSR);
//我的修正结束

/*告知 lwIP 链接已关闭*/
#if NO_SYS
netif_set_link_down (psNetif);
#else
TCPIP_CALLBACK ((TCPIP_CALLBACK_fn) netif_set_link_down、psNetif);
#endif

由于我们正在对近海风力涡轮机地点的传感器进行升级、这是一个非常昂贵的过程、我们希望能够确认这一旧威胁的结果?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

     我不认为它是结论性的发现由海报报告的帖子你参考。 正如本文中提到的 Amit (不再支持 TM4C)、在运行库存的 TivaWare 以太网示例时、插拔期间的链路状态不存在问题。 您是否看到与引用帖子相同的问题? 该帖子中的解决方法是否解决了问题? 据我所知, 最新 TivaWare 版本中的 tivaif_process_phy_interrupt ()添加了对 EEE 模式的支持。 否则、内容与该帖子中粘贴的内容大体相同。 在 ISR 中、它首先检查 MISR1寄存器中的 LINK 位是否有变化。 如果愿意、请在将相应的链接信息传递到 lwip 栈之前检查 STS 寄存器中的 LINK 位是高电平还是低电平。  

    /**
     * Process interrupts from the PHY.
     *
     * should be called from the Stellaris Ethernet Interrupt Handler.  This
     * function will read packets from the Stellaris Ethernet fifo and place them
     * into a pbuf queue.  If the transmitter is idle and there is at least one packet
     * on the transmit queue, it will place it in the transmit fifo and start the
     * transmitter.
     *
     */
    void
    tivaif_process_phy_interrupt(struct netif *psNetif)
    {
        uint16_t ui16Val, ui16Status;
    #if EEE_SUPPORT
        uint16_t ui16EEEStatus;
    #endif
        uint32_t ui32Config, ui32Mode, ui32RxMaxFrameSize;
    
        /* Read the PHY interrupt status.  This clears all interrupt sources.
         * Note that we are only enabling sources in EPHY_MISR1 so we don't
         * read EPHY_MISR2.
         */
        ui16Val = EMACPHYRead(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_MISR1);
    
        /* Read the current PHY status. */
        ui16Status = EMACPHYRead(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_STS);
    
        /* If EEE mode support is requested then read the value of the Link
         * partners status
         */
    #if EEE_SUPPORT
        ui16EEEStatus = EMACPHYMMDRead(EMAC0_BASE, PHY_PHYS_ADDR, 0x703D);
    #endif
    
        /* Has the link status changed? */
        if(ui16Val & EPHY_MISR1_LINKSTAT)
        {
            /* Is link up or down now? */
            if(ui16Status & EPHY_STS_LINK)
            {
                /* Tell lwIP the link is up. */
    #if NO_SYS
                netif_set_link_up(psNetif);
    #else
                tcpip_callback((tcpip_callback_fn)netif_set_link_up, psNetif);
    #endif
    
                /* if the link has been advertised as EEE capable then configure
                 * the MAC register for LPI timers and manually set the PHY link
                 * status bit
                 */
    #if EEE_SUPPORT
                if(ui16EEEStatus & 0x2)
                {
                    EMACLPIConfig(EMAC0_BASE, true, 1000, 36);
                    EMACLPILinkSet(EMAC0_BASE);
                    g_bEEELinkActive = true;
                }
    #endif
    
                /* In this case we drop through since we may need to reconfigure
                 * the MAC depending upon the speed and half/fui32l-duplex settings.
                 */
            }
            else
            {
                /* Tell lwIP the link is down */
    #if NO_SYS
                netif_set_link_down(psNetif);
    #else
                tcpip_callback((tcpip_callback_fn)netif_set_link_down, psNetif);
    #endif
    
                /* if the link has been advertised as EEE capable then clear the
                 * MAC register LPI timers and manually clear the PHY link status
                 * bit
                 */
    #if EEE_SUPPORT
               	g_bEEELinkActive = false;
               	EMACLPILinkClear(EMAC0_BASE);
               	EMACLPIConfig(EMAC0_BASE, false, 1000, 0);
    #endif
            }
        }
    
        /* Has the speed or duplex status changed? */
        if(ui16Val & (EPHY_MISR1_SPEED | EPHY_MISR1_SPEED | EPHY_MISR1_ANC))
        {
            /* Get the current MAC configuration. */
            EMACConfigGet(EMAC0_BASE, &ui32Config, &ui32Mode,
                            &ui32RxMaxFrameSize);
    
            /* What speed is the interface running at now?
             */
            if(ui16Status & EPHY_STS_SPEED)
            {
                /* 10Mbps is selected */
                ui32Config &= ~EMAC_CONFIG_100MBPS;
            }
            else
            {
                /* 100Mbps is selected */
                ui32Config |= EMAC_CONFIG_100MBPS;
            }
    
            /* Are we in fui32l- or half-duplex mode? */
            if(ui16Status & EPHY_STS_DUPLEX)
            {
                /* Fui32l duplex. */
                ui32Config |= EMAC_CONFIG_FULL_DUPLEX;
            }
            else
            {
                /* Half duplex. */
                ui32Config &= ~EMAC_CONFIG_FULL_DUPLEX;
            }
    
            /* Reconfigure the MAC */
            EMACConfigSet(EMAC0_BASE, ui32Config, ui32Mode, ui32RxMaxFrameSize);
        }
    }
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我们毫不怀疑这是我们客户的一个主要问题。 上述修复使拔下/插拔情况良好。 我们只需要确认我们现在使用的修复程序是正确的。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Peter:

     感谢您确认您的观察、因为我对这个发现很陌生。 我也很高兴该权变措施解决了您的问题。 我会将此帖子作为书签以供将来参考。 当前代码正在读取 STS 寄存器位0中的链路状态。 在读取数据表时、可看到"读取 EPHSTS 寄存器时该位不会被清零"的提示。 我不确定这意味着什么。 我想知道当拔出网卡时、该位仍然粘滞且不会改变。 因此、该参考柱中的海报设计的权变措施是强制读取 BMSR 寄存器来刷新粘滞位。  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我同意您对寄存器描述的思考和解读。 我不得不补充说、旧代码很少能正常运行、可能20次中有一次能正常运行。 实际上,我们试图进行 Wireshark 比较的活动,当成功/没有成功,但没有什么可以提供进一步的解释。

    通过在链路建立和链路断开操作中设置断点,可以看出在连接线时,链路标志的变化工作正常,从而导致对向上或向下的评估,但最终会停止!

    在移除导线的过程中、内部状态似乎已损坏。

    现在的问题是简单地,如果解决方案是可靠和正确的?