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

  • In reply to marinayelken:

    Rizwan,

    It is recommended that you check the signal strength of the pins. Interfaces like ethernet, QSPI, and SDRAM usually require the strength to be set to HIGH.

    It would be best if get a (free) production license. That would allow you to debug encrypted files, and would be better for us to continue in support.

    Regards,
    janet
  • In reply to marinayelken:

    Hi Janet

    I dont have access to framework\el folder.
    I have access to framework\sf_el_nx folder only.

    I am trying to get free production licence for debugging purpose.As of now all pins have high strength for Ethernet.

  • In reply to JanetC:

    Hi Marina

    Can you please share more details how you have solved this issue?
    What does stand alone means?
  • In reply to JanetC:

    Hi Janet,

    I am able to build your project.One port as DHCP and Other as Static.

    It has started working and i will keep it for over night test.

    Actually my current requirement is, I need to have both Ports with DHCP.

    In the existing code which has one port as DHCP and Other as Static.Do i need to add one more DHCP client to make other port to work as DHCP?

    I have a project with netx ip instance which works fine for both ports in DK board and not on custom board.

    Let me try with netx duo ip instance and check it it makes a difference on my custom board.

    Thanks and Regards

    Rizwan Syed

  • In reply to rizwan:

    IOTSG-1544_NetXDuo_Multiple_Network_Interfaces_AP.docxHI Rizwan

    One DHCP Client can handle multiple network interfaces. Actually creating two instances of DHCP Client might cause undefined behavior because the NetX DHCP Client uses global variables. I attached a document that you can refer to for the API to set up the secondary interface for DHCP Client. The project I sent you only uses DHCP Client on one interface because the other does not have a DHCP server set up.

  • In reply to JanetC:

    Hi Janet

    Please find our observations:

    1.Please find the attached IO registers for Ethernet 0 in pinging condition, Ethernet 1 pinging condition and Ethernet 1 ping stop condition.

    There is a difference in CEFCR(CRC Error Frame Receive Counter Register) and FRECR(Frame Receive Error Counter Register) registers.

    2.When tested with TFTPD software which generates the IP addresses (to avoid any ethernet network traffic)  for ethernet 0 and ethernet 1 instead of our office network.

    Ping works for both the boards.

    3.Ping with static connection works fine.

    4.When port 0 is DHCP and Port 1 is static, Both ports ping was working fine.

    5.When port 0 is static and port 1 is DHCP then port 1 is stopping after sometime.

     

    Thanks and Regards

    Rizwan Syed

  • In reply to rizwan:

    Hi Rizwan,

    1. I mentioned previously that you should only use 1 DHCP Client in your project. Is this the case? I ask because the presence of DHCP on two interfaces, even if one address is static, might be causing problems. Please feel free to send me your project. I might spot something that has been overlooked. There was recently a bug fix on DHCP CLient regarding DHCP running on the secondary interface but not the primary. What SSP are you using?

    2. You mentioned that in the stopped state, the nx_receive() function is still working. Can you put a breakpoint on this line

    _nx_ip_packet_deferred_receive(nx_rec_ptr->ip_ptr, packet_ptr);

    in the stopped state and see if it is being hit when the device is pinged?

    That is where the driver officially hands off the packet to the IP thread. If it does get hit, then we have to debug the IP stack.

    3. My suggestion then is to get a production license from Renesas. It is free. Any engineer responding on a CHAT session can do this for you. Once that is in place, we move the breakpoints further up the IP stack in the stopped state, until they stop getting hit. That will be the best way to track down the failed interface.

    4. I am not a hardware person so I will inquire about the CRC error frame and frame receive error registers with Renesas.

    Thanks,
    Janet
  • In reply to JanetC:

    Hi again

    As a quick test, try modifying your nxd_dhcp_client.c file as follows.

    Replace this line in _nx_dhcp_client_send_with_zero_source_address():

    interface_ptr = &(ip_ptr -> nx_ip_interface[dhcp_ptr ->
    nx_dhcp_interface_record[iface_index].nx_dhcp_interface_index]);

    with this line

    interface_ptr = &(ip_ptr -> nx_ip_interface[iface_index]);

    And rebuild your project. NetX application source code should be accessible, it is not prebuilt like the NetX library is. You might require the production license though.

    Anyway this might explain the failure on the secondary interface. it was only recently fixed in an SSP not released by Renesas yet.

    Regards
  • In reply to JanetC:

    2860.S7_DK_nx_http_eth_dual_1_3_2.zip

    Hi Janet

    1.I am using SSP 1.4.0
    Please find the attached SSP project for Dual ethernet DHCP.

    2. when breakpoint is kept at _nx_ip_packet_deferred_receive(nx_rec_ptr->ip_ptr, packet_ptr); in pinging condition.
    It shifts to nx_receive(); as mentioned in below and hits the breakpoint.
    if (status == (UINT) NX_SUCCESS)
    {
    /** Send the packet up the stack. */
    packet_ptr->nx_packet_ip_interface = nx_rec_ptr->ether_interface_ptr;
    nx_receive( nx_rec_ptr, packet_ptr);
    }

    In Non working condition,It does not stop at break point.
    But after 2 to 3 minutes, sometimes it used to hit the breakpoint at nx_receive(); but ping does not start.
    (only port 1 is connected).

    3.Now i have received a production licence but i cannot change the source code in _nx_dhcp_client_send_with_zero_source_address() function
    Because the file shows its protected.

    4.I have saved a log for ping test.When ping for port 1 is stopped then after 2 to 3 hours again it starts pinging for some time and stops again.
    Then again it starts and then it stops in a similar manner.

    But when i have tested with 10 mbps speed making by making changes to Phy_Start_Autonegotiate() and Phy_Get_Autonegotiate()
    I observed ping was working fine for approximately 12 hours.( need to test mnore to check if it works fine).
    What could be the issue with 100 mbps speed.

    5.Is it possible to do loop back test for Port 1 ?
    How can we do it ?

    Thanks and Regards
    Rizwan Syed

  • In reply to rizwan:

    Rizwan

    I checked your project set up and source code and it all looks fine to me. I don't see any problems there. The problem of DHCP CLient on the secondary interface is likely fixed by the code modification i suggested once you get your code in a writeable state (see below). But that still does not resolve the more basic problem of packets not getting to the IP stack.

    When you get a new license you need to go to the help menu and make sure that license is selected, and the check box for encrypting files is checked. Then click Generate Project Content and build the project. Now check the nxd_dhcp_client.c file in the synergy folder for being writeable.

    But now based on your latest debugging, it appears that the problem happens before packets are sent to the driver and before nx_receive. Set a breakpoint in nx_rx_interrupt to the top of the file when the 2nd interface gets in a stopped state, and see if an interrupt is even generated, and if it is, why it doesn't get to the nx_receive() call.

    All interfaces have the loopback capacity. Not sure how it works on the secondary interface e.g. if it defaults to the primary interface but I'll check it out on a known good system.

    I noticed your project configuration is set to an iwave board. I am not even sure what that is. If it is similar to the DK-S7G2 board, be sure that you have the dipswitch settings correct (in the IOTSG-1544 article I sent). I am pretty sure they are or you would not get any transmission on the second interface.

    For your hardware questions (auto negotiation, modifications you made to the board) , I am not very helpful. I will need to get a hardware engineer involved here, especially if you made modifications to the board (do I remember that correctly)?

    Let me check on the loopback test and get back to you.

    Janet
  • In reply to JanetC:

    Hi janet

    1.In ping stopping condition,_nx_ip_packet_deferred_receive() is not being hit.But in normal ping state it hits.
    #ifdef FEATURE_NX_IPV6
    if (packet_type == NX_ETHERNET_IP || packet_type == NX_ETHERNET_IPV6)
    #else
    if (packet_type == NX_ETHERNET_IP)
    #endif
    {
    _nx_ip_packet_deferred_receive(nx_rec_ptr->ip_ptr, packet_ptr);
    }

    I have observed that in ping stop condition,packet_type is getting change .so the _nx_ip_packet_deferred_receive() is not being called.
    i think there is some mismatch happening in packet receive format.
    I have checked the wire shark, from PC side its proper.

    when the packet_type is different from the below mentioned values.,Ping gets stop.

    #define NX_ETHERNET_IP 0x0800U
    #define NX_ETHERNET_IPV6 0x86DDU
    #define NX_ETHERNET_ARP 0x0806U
    #define NX_ETHERNET_RARP 0x8035U

    nx_rx_interrupt is called when ping stops also.


    What could be the issue with Packet change?

    2.After selecting check box for encrypting files is checked in licence selection apth.
    Still i cant able to modify the _nx_dhcp_client_send_with_zero_source_address();

    3.Its a custom board, so the pack name is iwave board.

    4.Is there a way to find the total length of packet_ptr and nx_packet_prepend_ptr (from where packet_type is extracted).

    The values are changing for nx_packet_prepend_ptr  and not able to monitor all the values.

    I wanted to check whether any Byte shift is happening in the packet format.


    Thanks and Regards
    Rizwan Syed

  • In reply to rizwan:

    Hi Rizwan

    I created a support ticket for you since some of your questions are beyond the scope of what I have expertise on (licensing, hardware). As soon as I get that ticket number to you, you can start using that for debugging this issue. This has really gone far beyond the scope of RenesasRulz. You need to be talking with a Renesas Engineer at this point.

    It sounds like when the packet gets to your board, the 'front end' of the packet is modified such that packet type is not longer read properly. Is that what you are seeing? If so, there is currently another customer also using a custom board who experiencing the exact same issue.

    The prepend pointer should be pointing to the beginning of the ethernet frame in nx_receive(). Then this function moves the prepend pointer to the start of the IP header. The packet length nx_packet_length is changed as the prepend pointer is moved. The total size of the packet payload is from nx_packet_data_start to nx_packet_data_end. The start data pointer is located after the NX_HEADER of each packet. The append pointer should be pointing to the end of the actual data written to the buffer.

    Janet
  • In reply to JanetC:

    Rizwan

    We created a ticket for you, #194433 in our support system. I will try to find out how you can log in so you can read and write posts to it similar to RenesasRulz. In the meantime, we have two [more] questions to try to rule in/out if this is a hardware issue or software:

    1) if you just run network traffic on the secondary interface, does network traffic stop after awhile like it does if both interfaces are in use? I think you said it never fails on the primary interface regardless if the seondary interface is active. Please confirm.

    2) Do you have a DK-S7G2 board, and if so can you run the same program over it and duplicate the failure scenarios?

    Thanks,
    Janet
  • In reply to JanetC:

    Rizwan, you should receive an email if you haven't already for this ticket, so you can access it from there. So don't put any more information into this post since we are now moving to the support ticket database. Thanks,
    Janet