Ethernet reinitialization

Hi

I have a issue with Ethernet in my custom board based on S7G2-DK .

Ping for one of the Ethernet gets stopped after some time.So i need to reinitialize the interface so that it again starts pinging.

My code below is:

void reinit_ethernet(UINT interface_index)
{

UINT status;
ULONG ip_address, ip_mask;
UINT request_option=0;
UCHAR *destination_ptr="ab";
ULONG ip_status[2] =
{ 0 };
status = nx_icmp_ping (&g_ip,
IP_ADDRESS(192, 168, 3, 187),
"Hello World", sizeof("Hello World"), &packet, 1000);
if (NX_SUCCESS != status)
{
__BKPT(0);
}
status = nx_dhcp_interface_stop (&g_dhcp_client, interface_index);
if (NX_SUCCESS != status)
{
__BKPT(0);
}
status = nx_dhcp_interface_reinitialize (&g_dhcp_client, interface_index);
if (NX_SUCCESS != status)
{
__BKPT(0);
}
status = nx_dhcp_interface_start (&g_dhcp_client, interface_index);
if (NX_SUCCESS != status)
{
__BKPT(0);
}
status = nx_ip_interface_status_check (&g_ip, interface_index, NX_IP_ADDRESS_RESOLVED, &ip_status[interface_index],
1000);

if (NX_SUCCESS != status)
{
__BKPT(0);
}

status=nx_dhcp_user_option_retrieve(&g_dhcp_client, request_option, destination_ptr, sizeof(destination_ptr));
if (NX_SUCCESS != status)
{
__BKPT(0);
}
status = nx_icmp_ping (&g_ip,
IP_ADDRESS(192, 168, 3, 187),
"Hello World", sizeof("Hello World"), &packet, 1000);
if (NX_SUCCESS != status)
{
__BKPT(0);
}
}

 

Is there any issue with the code.

My code gets a status =0x43 for status = nx_ip_interface_status_check (&g_ip, interface_index, NX_IP_ADDRESS_RESOLVED, &ip_status[interface_index],
1000);

Please suggest how to solve it.

 

Thanks and Regards

Rizwan Syed

  • Hi Rizwan-
    Take a look at this post that shows how to restart NetX:
    renesasrulz.com/.../solved-----need-process-steps-to-re-start-netx

    Let us know if this helps you.

    Warren
  • In reply to WarrenM:

    Hi Warren

    Thanks for the reply.
    I have 2 Ethernets and one Ethernet is working fine.
    So i dont need to delete dhcp and recreate again.
    I just need to reinitialize the dhcp for that particular Ethernet port.
    I have followed the instructions from netx guide for reinitialization.

    Thanks and Regards
    Rizwan Syed
  • In reply to rizwan:

    Rizwan,

    When you say only one ethernet is working, did the other Ethernet initially work e.g. able to ping another host?

    It would be helpful to get a packet trace or capture (e.g. Wireshark) of when the ping fails if possible. Otherwise you can only guess what is actually going on. There may be another problem that has nothing to do with DHCP Client. The fact that you cannot obtain another IP address after restarting DHCP Client indicates something might be wrong with the network link or the driver.

    If possible, leave out DHCP client and manually set the NetX IP address for the interface that is not working and see if the ping transmission still drops out.

    Janet
  • In reply to JanetC:

    Hi Janet,

    Initially Both Ethernets starts pinging.After sometime one of the Ethernet stops pinging and other Ethernet will be pinging continuously.

    With static , it works fine.
    Even after the ping stops, i can able to print the ip address of the stopped Ethernet port.It shows the same ip address.
    So my thinking is, ip is always assigned to that port, but ping is not happening.

    So i try to reinitialize that particular port and i get a error 0x43 for status = nx_ip_interface_status_check (&g_ip, interface_index, NX_IP_ADDRESS_RESOLVED, &ip_status[interface_index],
    1000);

    Since ip is already available , so it not resolving and may be getting fail.
    Is there a way to reinitialize that stopped Ethernet port as ip is already available.

    Thanks and Regards
    Rizwan Syed
  • In reply to rizwan:

    I don't think re initializing the IP will 'solve' the problem, in fact it is more of a workaround and masks the underlying problem.

    So since you haven't provided a packet trace, I need to ask more questions.

    What is the IP address assigned each port (or what I call network interface)?

    Are you using a single IP instance or multiple IP instances for the two interfaces?

    How long is is this period of time before the pings fail?

    what happens if you modify your project to use just one interface, and start pinging? Do the pings still fail after a while, on either interface?

    Can you confirm that the interface where pinging stops is still link enabled, and that the recipient of the pings from NetX is still responsive? You can do this by pinging that host from another host on the same local network. The problem may not be your NetX device.


    Try NX_IP_LINK_ENABLED in the nx_ip_interface_status_check. Since you manually assigned the IP address, that is not the question but whether the link is enabled.

    You can also step into the source code of nx_icmp_ping or whatever API you use to ping an external host to try to figure out what is going on. You will have to include the NetX or NetX Duo source code in the project and rebuild your library, if your license permits you to do that. This will at least verify if the ICMP ping request packet gets to the driver level (thereafter it is trickier to step through driver code).

    Janet
  • In reply to JanetC:

       Hi Janet,

    IP address is assigned using the DHCP and different ip addresses for both are assigned.

    Am using a single ip instance and attaching the other Ethernet to it using nx_ip_interface_attach.

    Period of ping fails is variable always.sometimes after 5 pings , sometimes 50 pings etc.its not constant.

    modified  the code for just one 1 Ethernet and still facing the same issue.

    I will check with  NX_IP_LINK_ENABLED in nx_ip_interface_status_check.

    I have a attached old wireshark snapshots which were captured using the local dhcp when i got issue.

     

    Thanks and Regards

    Rizwan Syed

  • In reply to rizwan:

    Hi Rizwan

    Thanks for confirmation of my questions.

    1. Can you send the actual packet trace instead of the screenshots? In general it is always much better to send the actual packet trace, not screenshots. Packet traces let you examine the packet headers, which you cannot do with a screenshot, and is more convenient for longer sequences.

    2. For more debugging on your own, when your board stops responding, put a break point at the top of nx_receive() in nx_renesas_synergy.c.

    [your workspace]\[your project]\synergy\ssp\src\framework\sf_el_nx

    Then try pinging it again. If the breakpoint is hit, verify the packet is forwarded to IP or ARP processing. If that breakpoint does not get hit, add a breakpoint to nx_rx_interrupt() in the same file.

    This will at least verify if the hardware is still sending interrupts and processing incoming data into packets.

    3. If they are, then something is happening to the packet in the IP layer. Do you have access to NetX source code? If the driver/hardware is working properly, the next step is stepping through nx_ip_packet_receive() to verify if the IP layer receives the packet and find out what it does with it.

    Thanks,
    Janet
  • In reply to JanetC:

    Hi

    When Ethernet Ping stops, nx_receive() and nx_rx_interrupt() are getting executed.
    Am not able to access nx_ip_packet_receive() in ip layer.
    How to access this function.Actually i have a evaluation licence.


    Thanks and Regards
    Rizwan Syed
  • In reply to rizwan:

     wire5 - Copy.txt

    Hi Janet

    My Assigned IP addresses are as follows:

    PC IP address: 192.168.3.187 

    Port 0  IP address : 192.168.1.24 

    Port 1  IP address : 192.168.1.88 ( Ping stops for port 1 )

    Please find the attached screenshot of wire shark  which contains "reply" and "no response" for port 1 at lines 575 and at 594 respectively.

    Also attached the wire5 - Copy.txt file which should be replaced with .PCAPNG format after downloading to open in wire shark.(There is an error in upload of .PCAPNG file , so uploaded as .txt file).

    Is there anything else required other than the above mentioned items.

    Please let me know for further  queries.

    Thanks and Regards

    Rizwan Syed

  • In reply to rizwan:

    Hi Rizwan

    I didn't realize the two ports shared the same network address. Actually I am surprised the second port works at all. Why do you need two separate ports on the same network interface? I don't believe NetX supports this, but I'm checking with our development team.

    I assume you are connecting through two physically separate ethernet ports on the DK-S7G2 board.

    Are you using the one driver instance g_sf_el_nx for both interfaces (ports), or creating a second NetX Ether Port instance for Port 1?

    In your packet trace, the PC stops responding to the ARP queries from 192.1.68.1.88, at around 44 seconds into the packet trace. The last successful ping to Port 1 was about 19 seconds. I have no explanation for this. I will try to duplicate what you are doing, so let me know about the driver used for port 1.

    Thanks,
    Janet
  • In reply to JanetC:

    HI again

    I finally got an old dual ported project to work. I tested I think what you are doing:

    Two separate physical connections to the same network
    Two separate instances of the NetX Ether Port driver (one for each interface)
    Two separate IP addresses assigned each interface, 192.2.2.241 and 192.2.2.69
    Open two command shells on a PC and have them each ping one of the interfaces.

    So far I haven't seen any failed pings. I can send you my project if you would like to look at it.
  • In reply to JanetC:

    Hi Janet,

    I have tested in DK board with the same code and it works fine , When i port the same code to my custom board i face the  ping issue as i mentioned.

    Please share the code which you have tested let me check once.

    I am attaching a second interface to the first interface.I have attached the image of the configuration for the same.

    Can you please suggest how should i proceed to solve this Ethernet ping issue as it has become a bottle neck for this project?

    Please let me know for further queries

     

    Thanks and Regards

    Rizwan Syed

     

  • In reply to rizwan:

    Hi Janet,

    I checked with only one Ethernet which was stopping after sometime to debug where the issue occurs

    While trying to debug Ethernet issue , I found that
    1.When pings works fine , then nx_ether_send() function is always called, but in stop case this function is not called.

    2.In nx_ether_driver() function, there is a driver_command whose value is 0 in case of success and driver_command value is 18 in case of stop condition.
    Based on above value ,switch case is executed.
    Cant find the code from where nx_ether_driver() function is called.Since i dont have full access to code.

    Thanks and Regards
    Rizwan Syed
  • In reply to rizwan:

    NetXDuo_DualEthernetPort_DK_S7G2.zip NetXDuo_DualEtherPort_DK_S7G2.zip

    The command 0x18 should not by itself indicate something is wrong. It is the NX_LINK_DEFERRED_PROCESSING command for the driver to execute the command in the context of the IP thread task (as opposed to in ISR context). This is usually used for received packets. The 0x0 command is the NX_LINK_PACKET_SEND command.  

    You should have access to all the driver source code since I don't believe that is ever encrypted.  And it seems that the driver is where the problem is occurring.  I may not be the best person to debug the Renesas Ethernet driver.  Let me check with Renesas and see what they can suggest here as the best way to track this problem.

    I attached the file, not sure if I did it right since I don't send projects out much in RenesasRulz. Let me know if you can download it. 

  • In reply to JanetC:

    I am not sure but I had a similar problem. I gave up and find another way for communication. I think my prıblem was because of the vias and unequal trace lengths between s7 and phy chip. The communication started normal,  but some undefinete time, lost. I suggest to try the port with problems standalone, without using the  one working normal.