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.
nx_ip_status_check()
ether_phy_mii_write1()
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);
(*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:
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?
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?
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.
Thank you for reaching out to Renesas Engineering Community.
From the r_ether_phy drivers ( https://renesas.github.io/fsp/group___e_t_h_e_r___p_h_y.html ) you can call R_ETHER_PHY_LinkStatusGet to get the status of physical link.
I hope it helps.
Regards
Great thanks will try this now.
Am I doing anything obviously wrong, doesn't seem to be working:
I suspect that you get a FSP_ERR_NOT_OPEN because you have not opened the PHY module. You need to call R_ETHER_PHY_Open before that:
renesas.github.io/.../group___e_t_h_e_r___p_h_y.html