We are using an LPC4088 microcontroller with an Ethernet PHY (LAN8720) connected via RMII interface. The software stack includes MDK middleware version 7.12.0 and DFP version 2.2.2. The PHY is located on an Ethernet plug-in board.
When we call the netInitialize() function:
If the plug-in board is connected: netInitialize() returns success and Ethernet works as expected.
If the plug-in board is NOT connected: The code hangs inside netInitialize() and does not return.
Issue: We need a way to prevent the system from hanging when the Ethernet hardware is not present. Ideally, netInitialize() should return an error code or timeout instead of blocking indefinitely.
Questions:
1. Is there a recommended approach to handle missing Ethernet hardware in MDK middleware?
2. Can we configure a timeout or detect PHY presence before calling netInitialize()?
3. Are there any known fixes or patches for this behavior in version 7.12.0?
Thanks for your response.
We already verify the presence of the plug-in board before invoking netInitialize(), which indicates whether the board is present or not. However, we also have some PCBs where the Ethernet hardware is integrated directly on the board without a plug-in module. For these cases, we are looking for a software-based solution that can reliably return an error if the Ethernet hardware is missing or if there is a hardware-related issue.
netInitialize()
You can use the bit-banding routines that implement MDIO communication by manually toggling the port pins in software. This avoids accessing the EMAC peripheral and therefore prevents any hard-fault exceptions it might generate.
The necessary functions are available in the EMAC_LPC17xx.c Ethernet driver for LPC17xx devices. Try reading the REG_PHYIDR1 register at address 0x2; the expected value is 0x0007.
EMAC_LPC17xx.c
REG_PHYIDR1
0x2
0x0007
If the read operation returns 0x0007, then the PHY is present and it is safe for the software to call netInitialize(). If not, netInitialize() should not be invoked.