Handling Absence of Ethernet Link with Azure RTOS on R7FA6M3AH3CFC

Hello,

I'm currently working on a project using the Renesas R7FA6M3AH3CFC microcontroller with Azure RTOS and FSP 3.5. I've encountered an issue when the Ethernet cable is intentionally left unplugged.

In my application, I'm trying to handle the absence of an Ethernet link. Specifically, I want my application to continue running other threads when the Ethernet link isn't available, and only perform Ethernet-dependent operations once the link is established.

I'm using the nx_ip_status_check() function from NetX to check for the link status. However, when the Ethernet cable isn't plugged in, this function seems to get stuck in a function ether_phy_mii_write1() in r_ether_phy.c.

It appears that the MII interface isn't able to complete the communication with the PHY due to the absence of the link, and ends up hanging on this line: (*petherc_pir) = (ETHER_PHY_PIR_MDO_HIGH | ETHER_PHY_PIR_MMD_WRITE | ETHER_PHY_PIR_MDC_LOW);

I've tried various workarounds, including placing the nx_ip_status_check() call in a loop with a thread sleep to periodically check for the link status. But it only goes around the loop once and then gets stuck in the ether_phy_mii_write1() function.

I was under the impression that the PHY and Ethernet controller should be able to handle this kind of situation gracefully, without hanging or blocking indefinitely. So, I suspect there might be an issue with the Ethernet driver or PHY driver provided by Renesas.

Could you please provide guidance on the following:

  1. Is there an alternative way of checking for the presence of the Ethernet link that doesn't involve creating an IP instance or making a NetX call, and that won't hang when the Ethernet cable is unplugged?

  2. Is there a known issue with the Ethernet driver or PHY driver that could be causing this behavior, and if so, is there a recommended workaround or fix?

  3. Are there any specific hardware registers that I can poll to check for the link status as mentioned in the PHY datasheet or the Ethernet controller section in the microcontroller's reference manual?

Thank you in advance for your assistance.

Parents
  • Are you saying the thread that blocks checking the network prevents other threads from running?

  • Currently my device waits until internet connection is made before it performs other thread tasks but what I wanted was to do a simple loop like this to detect if the ethernet cable was plugged in:

    while (1)
    {
    // Check link status without waiting
    status = nx_ip_status_check(&g_ip0, NX_IP_LINK_ENABLED, &current_state, NX_NO_WAIT);

    // If link is enabled, we can break out of the loop
    if (status == NX_SUCCESS && current_state == NX_IP_LINK_ENABLED)
    {
    break;
    }

    // Link not enabled, so sleep for a bit to allow other threads to run
    tx_thread_sleep(2000);
    }

    }

    But instead of going back round the loop it hangs inside 'r_ether_phy.c', here:

    I didn't really want to start modifying this file, but maybe it would be worth dictating a maximum retry or timeout.? 

Reply
  • Currently my device waits until internet connection is made before it performs other thread tasks but what I wanted was to do a simple loop like this to detect if the ethernet cable was plugged in:

    while (1)
    {
    // Check link status without waiting
    status = nx_ip_status_check(&g_ip0, NX_IP_LINK_ENABLED, &current_state, NX_NO_WAIT);

    // If link is enabled, we can break out of the loop
    if (status == NX_SUCCESS && current_state == NX_IP_LINK_ENABLED)
    {
    break;
    }

    // Link not enabled, so sleep for a bit to allow other threads to run
    tx_thread_sleep(2000);
    }

    }

    But instead of going back round the loop it hangs inside 'r_ether_phy.c', here:

    I didn't really want to start modifying this file, but maybe it would be worth dictating a maximum retry or timeout.? 

Children
No Data