Hello,
I'm using the MIMXRT1170-EVK board with the MIMXRT1176 MCU.
I have an older project which was written with different SDK version where was some problem with ethernet. Nowdays I'm trying to make the program works but somehow I'm still getting into some infinite loop whenever I call the `netif_add()` function.
After some debugging I found out it always fails inside the PHY_KSZ8081_Init() function after this loop:
do
{
result = MDIO_Read(handle->mdioHandle, handle->phyAddr, PHY_ID1_REG,
®Value);
if (result != kStatus_Success)
{
return result;
}
counter--;
}
while ((regValue != PHY_CONTROL_ID1) && (counter != 0U));
if (counter == 0U)
{
return kStatus_Fail;
}
The bahaviour is:
- counter is always going down to 0
- regValue is always 65535 -> the do/while loop is checking for value PHY_CONTROL_ID1 which is 0x283
So the program (MDIO_Read() function) can't find value 0x283 on address handle->phyAddr (which is set to BOARD_ENET1_PHY_ADDRESS)
. Since it's trying to get the desired value 1000times, I wildly guess there might be something that takes time to setup / something with only probability to be set at some point in the program (but since it's hardware and not OTA apps I guess this theory isn't the right one but it might wait for some data and since it's initialization of ethernet, something may cause a delay? I have no idea honestly).
To provide more informations that might come handy since some of them were kinda hard to get working and might cause some struggle:
I tried all the possible PHY addresses etc. but still can't figure out what am I missing or what might be the problem here. I'm pretty new to these NXP MCUs and Ethernet so it might be something really stupid but I have no idea what it is.
Solved! Go to Solution.
Found the problem.
Probably the issue was caused by converting the previous project to new SDK where some ethernet SDK changes were made. So instead of using the `netif_add` function with whole initialized `ethernetif_config_t` structure, there were some parameters as `.phyAddr` or `.phyOps` missing, well they were passed to `mdio_handle_t` variable - dunno if using this was mistake on our side or just old SDK example thing.
So that's what allowed me to debug the program past the `netif_add()` function. I don't know exactly why this cause a whole program to crash in the `PHY_KSZ8081_Init()` function, I would expect the function just return some error value and program going to run without the ethernet working but it is what it is.
Found the problem.
Probably the issue was caused by converting the previous project to new SDK where some ethernet SDK changes were made. So instead of using the `netif_add` function with whole initialized `ethernetif_config_t` structure, there were some parameters as `.phyAddr` or `.phyOps` missing, well they were passed to `mdio_handle_t` variable - dunno if using this was mistake on our side or just old SDK example thing.
So that's what allowed me to debug the program past the `netif_add()` function. I don't know exactly why this cause a whole program to crash in the `PHY_KSZ8081_Init()` function, I would expect the function just return some error value and program going to run without the ethernet working but it is what it is.