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.

EMAC fails when reconnection of ethernet

Hi,

  When I run the ethernet functionality I am able to ping my static IP address and everything runs fine.  When I disconnect the ethernet cable, and then re-connect the ethernet cable, I am unable to ping the IP address.  Why is this?

Thanks,

Will

  • Will,

    I'm not sure about your particular OS. But can you check whether your Ethernet interface has an IP address set? If not, try to configure a static IP address again and try to ping.

  • Hi Renjith,

      I have set up the EVM to a static IP.  Im using Bios 6.  Im guessing its the pdk emac code that doesn't handle this.  Also, the emac thread hangs if a connection is not made during power-on. 

    Will

  • Will,

    So you mean you PDK code can't set IP address at run time? I don't have experience with PDK platforms. I'm helpless here.

  • Hi Renjith,

      THe PDK can set the IP address.  It acts like the PDK code doesn't handle a disconnect and then a reconnect.  Once I disconnect and then reconnect, i try to ping the EVM and get no response.

    Will

  • Will,

    What I meant was when the evm reconnects, its not able to re-assign the IP to the interface. Also can you see whether the Link is getting detected? 

  • Hi.
    I have the same probrem, now.
    case 1. once up TCP and remove Ether calbe and, reconnect cable. Then never reup the network.
    case 2. Remove Ether cable, and start program. Next connect cable. Then doesn't up Networks.

    My Emviroment is..
    - EVM6657
    -SYS/BIOS 6_33_06_50
    -MCSDK 2_01_02_05
    -pdk_C6657_1_1_2_5
    -ndk_2_21_01_38
    -xdctools_3_23_04_60

    I tried sample. HUA and  udp  helloworld,  and the original rom boot program(same as HUA)
    Case 1: (cable remove and reconnect)CCS Console Log is following.

    [C66xx_0] Setting hostname to tidemo-0092
    [C66xx_0] MAC Address: 08-00-28-32-xx-xx
    [C66xx_0] Configuring DHCP client
    [C66xx_0] emac_init: core 0, port 0, total number of channels/MAC addresses: 1/1
    [C66xx_0] MAC addresses configured for channel 0:
    [C66xx_0] 08-00-28-32-xx-xx
    [C66xx_0] SGMII reset successful........
    [C66xx_0] SGMII config successful........
    [C66xx_0] emac_open core 0 port 0 successfully
    [C66xx_0] Registration of the EMAC Successful, waiting for link up ..
    [C66xx_0] Service Status: DHCP     : Enabled  :          : 000
    [C66xx_0] Service Status: Telnet   : Enabled  :          : 000
    [C66xx_0] Service Status: DHCP      : Enabled  : Running  : 000
    [C66xx_0] Network Added: If-1:192.168.4.44
    [C66xx_0] Service Status: DHCP      : Enabled  : Running  : 017
     Cable remove and reconnect.
     few munites later, log continues following.
    [C66xx_0] emac_send core 0 port 0 TX queue is empty
    [C66xx_0] emac_send core 0 port 0 TX queue is empty
    [C66xx_0] emac_send core 0 port 0 TX queue is empty
    [C66xx_0] emac_send core 0 port 0 TX queue is empty
    [C66xx_0] emac_send core 0 port 0 TX queue is empty

    Case2:(start program withouot connect cable and connect cable later)
    [C66xx_0] Setting hostname to tidemo-0092
    [C66xx_0] MAC Address: 08-00-28-32-xx-xx
    [C66xx_0] Configuring DHCP client
    [C66xx_0] emac_init: core 0, port 0, total number of channels/MAC addresses: 1/1
    [C66xx_0] MAC addresses configured for channel 0:
    [C66xx_0] 08-00-28-32-xx-xx
    [C66xx_0] SGMII reset successful........
    [C66xx_0] SGMII config successful........
     CONNECT ETHER CABLE HERE
    [C66xx_0] emac_open core 0 port 0 successfully
    [C66xx_0] Registration of the EMAC Successful, waiting for link up ..
    [C66xx_0] Service Status: DHCP      : Enabled  :          : 000
    [C66xx_0] Service Status: Telnet   : Enabled  :          : 000
    [C66xx_0] Service Status: DHCP      : Enabled  : Running  : 000
      few munites later...
    [C66xx_0] Service Status: DHCP      : Enabled  : Fault    : 002
    [C66xx_0] Service Status: DHCP      : Disabled :          : 000
    [C66xx_0] Service Status: DHCP      : Enabled  :          : 000
    [C66xx_0] Service Status: DHCP      : Enabled  : Running  : 000
      few munites later...
    [C66xx_0] emac_send core 0 port 0 TX queue is empty
    [C66xx_0] emac_send core 0 port 0 TX queue is empty

    I want  some advice too.
     

  • Hi Renjith,

      Any updates on why the emac software can not re-establish the ethernet connection once disconnected?

  • HI Will,

    How long you are staying disconnected? Also I assume you are connecting back to the same network again?

    Thanks,

    Arun.

  • Hi Arun,

      I am pulling the plug for about 30 seconds and then re-connecting.

    Will

  • HI Will,

    I believe that you are trying the example in the folder MCSDK\mcsdk_02_02_01_05\pdk_C6657_1_1_2_5\packages\ti\drv\emac\example\EMACBenchmark? Please try the example in the NDK. The example is in C:\MCSDK\mcsdk_02_02_01_05\mcsdk_2_01_02_05\examples\ndk\helloWorld

    Thanks,

    Arun.

  •  

    Hi,all.

     I'm tracing this thred cause I have the same probrem.
    My project is from Helloworld.(I changed some ..)
    now I using static IP address rather than DHCP.
    and host PC pings to DSP forever.

    I set break points at
    Point A :[emac_drv.c] line 1317  emac_send()function
    Point B :[emac.c]  line 2803     EMAC_TxServiceCheck() function
     
    I found DSP stops at Point A and B 12 times, after re-connect.(every hosts ping packet)
    and next ,DSP stop only at Point A.
    DSP writes to TX0HDP descriptor 12 times,(frame length is 0x4A)
    and TX0CP replys 12 times.

    so, I think dsp trying to send echo (back) frame, after re-connect the cable.
    so, I think DSP receives ECHO frame.


    but 13th write to TX0HDP, Transmit DMA Engine(fig.10 sect 2.3.1 SPRUGK9A) stalls.

    Transmit FIFO has 24 cells of 64bytes. It seems to be full.

    And I found MACSTATUS register (0x2c08164) changes.
    in fine state: 0x8000 0008
    pull cable:    0x8000 0000
        next  :    0x0000 0000
    re-connect:    0x0000 0008

    (I connect board to 100base SW)

    Next, I hand edited TXEN in TXCONTROL(bit 0 of 0x02c0 8004)
    1 to 0 next,  0 to 1
    Then Transmit DMA Engine restarts.
    but MACSTATUS stays 0x0000 0008, and 12th write to TX0HDP makes fifo full.
    And host dosn't receive ECHO back frame.

    ---- I Correct  my mistake remark.  Editting TXEN can't clear FIFO.
    Should I make another thread?

    thankyou.

     

  • One fundamental thing you should check is the PHY configuration. Make sure that it is not programmed to allow half-duplex autonegotiation. If all abilities are set for advertise in the PHY, when disconnected it might try re-negotiation and it might try half-duplex as it just lost a full-duplex link. In this case EMAC will not recover since, as per the spec, it does not support 1000Base-T Half-Duplex mode. If you are using hardware PHY configuraiton and not software configuration then I can double check this particular's EVM configuration to see if this indeed is the case.

    Kind regards,

    Javier

  • Hi Javier.
    I don't know how to secern hardware PHY configuration and software PHY configuration.
    but I using pdk and PDK seems not to write PHY register through MDIO.USERACCESS0 in C6657.

    I Read PHY registers through MDIO.USERACCESS0 (0x02c0880)
    Adr0: 0x1140
    Adr1: 0x796D
    Adr4:0x01E1
    Adr5:0x45E1(100 SW)
    Adr9:0x0F00
    AdrA:0x4000

    Next , I wrote 0x0041 to Adr4 for 10base-T Fullduplex mode only .
    And I wrote 0x0C00 to Adr 9 not for  1000base.
    And restart program. then left LED changed to orange blink(ACT).
    after restart program, EVM returns ping. but after re-connect the cable, EVM doesn't return ping back.

    ofcource I want to establish gigabit full duplex finally.
    thank you.

  • Hi All.
    bit 4 of MACCONTROL register (0x02c08160) , field name is TX_FLOW_EN.
    I change this bit turn 0 and turn 1(toggle), and I've found Tx engine restarted.

    I've read
    Section 2.9.2.6 transmit Flow Control in EMAC/MDIO User Guide(SPRUHH1)

    but I can't understand well. in this section . isn't it written such a thing?
    I think I 've done is only reset state of Tx Engine.

    Best regards,   Kazunori.
    This is incorrect , Not TX_FLOW_EN . correct is Bit 5 of MACCONTROL, field name is GMII_EN (fixed 15 JAN)

  • Hi Javier,

      When looking through the emac pdk, in emac_open function, the commonCfg.ModeFlags is set to EMAC_CONFIG_MODEFLG_FULLDUPLEX.  This struct is passed into EMAC_commonInit().  I am unable to follow all the structures to get to the exact memory mapped location of the mdio mode flag for full duplex.  Can you give me to memory and bit location for validating Full Duplex.

    Thanks,

    Will

  • Hi Javier,

      Nevermind.  Found it.  Address 0x2C08160 bit 0.  Its set to a 1 which means full duplex mode.  Its in the Mac control register in the EMAC subsystem configuration.  Any other thoughts as to why the emac can't re-establish connection?

  • Hi, all.

    I found toggling Bit 5 of MACCONTROL can re-establish connection, after reconnecting cable.
    1. make usertask
             TaskCreate(intvlTsk, "intvlTsk", 10/*Priority*/, 4096, 0, 0, 0);
    2. toggle GMII_EN if LINKSTATUS 0->1
    #include <ti/csl/csl_mdio.h>
    #define CSL_MDIO_0_REGS 0x02C08800
    #include <ti/csl/csl_emac.h>
    #define CSL_EMAC_0_REGS 0x02C08000

      void itvlTsk(Uint32 arg1, Uint32 arg2 , Uint32 arg3){
       for(;;) {
       static int last_link = 0;
       static int down_cnt = 0;
       static int up_cnt = 0;
       int link;
       link =MDIO_REGS->LINK;
       if(link) up_cnt++; else down_cnt++;
       if(last_link != link){
        /* if link changes , print down/up count*/
        if(link){/* Down -> Up */
         platform_write("Down->Up  Down Count:%d \n ",down_cnt);
         /* toggle Tx Flow Control Enable */
         Emac_osalEnterSingleCoreCriticalSection(0);
         EMAC_REGS->MACCONTROL &= ~0x00000020;
         EMAC_REGS->MACCONTROL |= 0x00000020;
         Emac_osalExitSingleCoreCriticalSection(0);
         down_cnt=0;
        } else { /* Up -> Down */
         platform_write("Up -> Down  Up Count  :%d  \n",up_cnt);
         up_cnt=0;
        }
        last_link = link;
       }
      }
      TaskSleep(1000);
      }

    Kazunori

  • Hi Kazunori,

      Toggling the GMII_EN bit when the status bit goes from 0 to 1 does not fix the reconnection issue on my board.

    Will

  • Hi Will.

    I was sometimes helped by clearing hosts arp table.
    To clear Windows Host PC's arp table, type "arp -d *" command in command prompt.

    This is my inference....
    Some SW-HUBs clear their own MAC tables when pull the cable, and they never transport packets except MAC broadcast frame to re-pluged port until EVM outs a new packet.
    Sending packet ARP WHO HAS can trigger to EVM to new packet.

    Regards.
    Kazunori

  • Hi.

    I apologize for having caused any confusion.
    Clearing  arp table can sometimes re-establish network is correct for my EVM.

    But the reason why I inference is NOT correct.

    If I set wrong default gateway to the NDK , Re-connection trouble  issures from wrong gateway.

    sincerely.
     

  • Hi Kazunori,

    I had a similar problem, but I could not link at speeds below 1000BT.  Toggling GMII_EN seems to break the MAC out of whatever bad state it is in, thanks for the tip!

    Do we have any response from TI?  Is toggling GMII_EN a workaround for a problem in the C6657 DSP, or is it an indication that something isn't quite right in the EMAC or PHY configuration?

    -Mike