cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
2,583 Views
Registered: ‎04-07-2014

Zynq lwip 202 initialization without ethernet cable

Dear Xilinx Support,

 

I am using a baremetal Zynq-7000 platform with lwip network stack. My example design is a ZC706 with the provided echo_server project.

 

Since Vivado 2018.2 hotplug support for the network cable is supported represented by the new eth_link_detect() function. This was good news for me.

 

There is however a piece missing: When no ethernet cable is plugged in in during initialization, xemac_add() will throw an assert and never recover. xemac_add() tries to bring up the link and fails of course.

 

Thus there is no possibility to start a lwip network capable device without ethernet cable connection.

 

Are there any plans to fix this? Wouldn't it be better to remove autonegotiation from xemac_add() ?

 

Help is appreciated.

 

Regards,

Sebastian

 

 

Tags (1)
0 Kudos
11 Replies
Highlighted
Explorer
Explorer
2,566 Views
Registered: ‎04-07-2014

Followup:

 

get_IEEE_phy_speed() within xemacpsif_physpeed.c serves three functions right now:

 

1. Resets the PHY,

2. Waits for auto-negotiation to complete and

3. Reads the link speed.

Its name only implies the third.

 

get_IEEE_phy_speed() is called during initialization by xemac_add(), where only the 1st function (PHY reset) is needed. Thus, there are problems during init when no cable is connected.

 

get_IEEE_phy_speed() is called again during eth_link_detect(), where only the 3rd function (read link speed) is needed. Thus, main loop is delayed for several seconds, because PHY is resetted after successful auto-negotiation again.

 

My proposal: Split get_IEEE_phy_speed() into a reset-function and a get_link_speed-function. Call reset-function during xemac_add() and call get_link_speed-function during eth_link_detect(). The waiting for auto-negotiation is already realized by baremetal while(1) loop itself, which regularly calls eth_link_detect().

 

This has two advantages:

1. Initialization can be done without Ethernet cable connection.

2. Auto-negotiation is not blocking the remaining application.

 

Are there any reasons to do PHY reset over and over again? Is there perhaps some odd PHY behavior, which requires reset after each link establishment?

 

Your comments are highly welcome.

 

Regards,

Sebastian

 

 

Highlighted
Explorer
Explorer
2,515 Views
Registered: ‎04-07-2014

Hi all,

 

is there anyone else using lwip and facing the problem, that his or her device might be powered up without an ethernet cable attached?

 

I thought, this should be quite common.

 

Anyway, my solution to split get_IEEE_phy_speed works well at my side.

 

Regards,

Sebastian

0 Kudos
Highlighted
Adventurer
Adventurer
2,252 Views
Registered: ‎08-17-2009

Hi Sebastian,

 

i have the same issue, it is not acceptable that I'm running into an assertion if there is no ethernet cable connected during startup, the user must be allowed more than 30s to do that.

 

As far as I am aware, Xilinx up to date did not provide a solution for that, is that correct?

 

When you write "my solution to split get_IEEE_phy_speed", how did you do that? 

How do you prevent SDK from overriding your code changes every time you rebuild the BSP?

 

Thanks,

Stefan

 

0 Kudos
Highlighted
Visitor
Visitor
2,218 Views
Registered: ‎08-28-2018

I have the same problem.
Since you do not connect the Ethernet cable, xemac_add locks all tasks.
Did you find a solution? I need help.

0 Kudos
Highlighted
Adventurer
Adventurer
2,205 Views
Registered: ‎08-17-2009

For now, I use the workaround to disable auto negotiation and set the link speed to 1000 fixed.

This is not satisfying, but I can work with it until I find a better solution.

 

0 Kudos
Highlighted
Explorer
Explorer
2,116 Views
Registered: ‎04-07-2014

Hi

my solution currently is to overwrite xemacpsif_hw.c and xemacpsif_physpeed.c with my own versions after generating the BSP inside the directory

your_bsp_name\ps7_cortexa9_0\libsrc\lwip202_v1_1\src\contrib\ports\xilinx\netif

This is not very convenient, but helps for the time being.

All my changes are marked with the tag SGi in the comment

I attach both files for you. Perhaps Xilinx could use my proposal for the following releases?

Have fun and leave me a Kudos if you wish,

Sebastian

Highlighted
Adventurer
Adventurer
2,106 Views
Registered: ‎08-17-2009

Thank you very much, I will try this out ASAP!

Xilinx should really fix this for good, not the least because this method of patching in the BSP is very error prone: if you forget to apply the patch after rebuiliding the BSP, you will not notice, but loose this important fix.

 

0 Kudos
Highlighted
Explorer
Explorer
2,090 Views
Registered: ‎04-07-2014

Hi,

if I remember correctly it will be necessary to regularly call

eth_link_detect(&netif);

inside the while(1) loop for example right after xemacif_input(&netif);

Hope that helps.

Sebastian

Highlighted
Xilinx Employee
Xilinx Employee
2,066 Views
Registered: ‎02-01-2008

A better way is to patch the library once in a local repository so that any time the BSP is regenerated, it will use your patched library.

So for example, if you want a custom lwip:

  1. copy <sdk install dir>/data/embeddedsw/ThirdParty/sw_services/lwip202_v1_1 to your custom location such as c:/projectA/mySdkRepo/sw_services
  2. make the .c changes in c:/projectA/mySdkRepo/sw_services
  3. Optionally rename c:/projectA/mySdkRepo/sw_services/lwip202_v1_1 to lwip202_v1_9 and edit lwip202_v1_9/data/lwip202.mld and change the 'OPTION VERSION' to 1.9 and alter 'OPTION desc' to something like "My lwip202 library:....."
  4. In SDK, go to Xilinx->Repositories and add c:/projectA/mySdkRepo path as a new repository
  5. Or, if using sdk batch, use "repo -set c:/projectA/mySdkRepo"

Now, next time you create a new bsp, you will see your v1.9 lwip library. If you already have an existing bsp, you may have to remove the old lwip version, let the bsp recompile, and then try adding your version library to the bsp. You may have to close and reopen the workspace in order to add the new version lwip to an existing bsp.

Highlighted
Adventurer
Adventurer
2,053 Views
Registered: ‎08-17-2009

Thank you John, this is very helpful! Not only for lwip, I also wanted to modify other libraries in the past and usually ended up copying vast amounts of code, this is much more elegant way of achieving this.

0 Kudos
Highlighted
Explorer
Explorer
1,155 Views
Registered: ‎10-09-2017

Thanks for your code. I will try to test them tomorrow. If ok, I will give you kudo

0 Kudos