"Check PHY ID" Fails inside the PHY_KSZ8081_Init() function

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

"Check PHY ID" Fails inside the PHY_KSZ8081_Init() function

Jump to solution
731 Views
MichalKv
Contributor III

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, 
      &regValue);
   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:

  • The M7 core is running in Flash
    • On this core is running only "hello world" example with setting LED into 1 and starting the second core.
  • The M4 core is running in SDRAM
  • IDE: MCUXpresso (so the latest SDK since it should update automatically)
  • The PHY_KSZ8081_Init() is the ending function. It all starts with function netif_add()

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.

Tags (2)
0 Kudos
Reply
1 Solution
673 Views
MichalKv
Contributor III

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. 

View solution in original post

0 Kudos
Reply
1 Reply
674 Views
MichalKv
Contributor III

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. 

0 Kudos
Reply