05-04-2016 09:20 AM
SDK 2015.4, Zynq XC7Z020, baremetal application on PS0, lwip 1.4.1 and FreeRTOS 8.2.3 enabled in the BSP, Micrel KSZ9031RNX PHY
Various link auto-negotiation/speed/detection issues; details below.
Custom board, but hardware is fine because if we run linux (petalinux 2015.4) instead of baremetal, the ethernet works perfectly. And same observations on many different hardware units.
So I guess there is some issue in the lwip code or the xemacps code in the BSP, for this particular PHY, related to link up/down/negotiation activities. Has anyone made (lwip/xemacps for 2015.4 BSP) plus ksz9031 phy work reliably, and if so what are the required steps ? Many thanks.
a) lwip API function 'netif_is_link_up' doesn't work, always returns false
b) Link speed auto-negotiation doesn't work; link light will come up but then no traffic gets through; if my board is connected direct to PC, this can be 'worked around' by disabling auto-negotiation in the partner (my PC), and then in lwip BSP settings in SDK GUI, also set a fixed link speed. Then traffic will pass OK after link established.
c) I am suspicious problem is in xemacps driver (maybe some PHY register definitions different from the Marvell PHY that Xilinx uses... or maybe Micrel PHY needs some extra kicks or steps in its configuration/bringup...) because if I substitute FreeRTOS+TCP stack instead of lwip, I also have wrong link speed value reported back up into FreeRTOS+TCP stack, and also have to disable auto-negotiation to get any traffic through. Figuring out the functional differences between linux driver code and lwip/xemacps code for this PHY is way beyond me...
d) In my baremetal software I pulse the MIO pin I use for the ethernet PHY hardware reset, before calling lwip stack initialisation... so I guess PHY should be in the same/fresh state every time I try to start up the stack.
I've seen this thread;
but it doesn't mention tool versions and original post is a year ago and no solutions offered, so I start new one... but I get the feeling I might not be alone in my KSZ9031/Zynq link struggles. I guess a lot of people replaced the Marvell PHY in the reference designs with KSZ9031 PHY.
The 2 most recent changes to KSZ9031 linux driver described here;
seem very relevant indeed to my issues described above ... but I've no idea how to integrate the same functional steps/fixes into the lwip/xemacps code.
05-16-2016 09:12 AM
I've used this PHY, but only with the lwip version from SDK 2014.3 (we did build the vivado project with 2015.3 though since we needed VHDL2008 support, and added the 2014.3 repository to our workspace to make use of 2014.3 lwip since we verified it worked with that version). We had to disable auto negotiation in the BSP, setting the link speed to 1Gbps. Also, if you are making use of interrupts we had to change sys_arch_protect/unprotect to disable/enable only the emac interrupt and not all interrupts using the assembly calls (dafault). the Hopefully this works the same in SDK 2015.4.
11-08-2016 10:42 AM
check this link (http://www.elogics.net/bbs/board.php?bo_table=manual03&wr_id=58&page=). I already check the modification it work using the lwip 1.4.1 and FreeRTOS 8.2.3 echo server example . You need only to compare the files xemacpsif_hw.c, xemacpsif_hw.c and xemacpsif_speed.c in the BSP project with the partial code in the link, pay attention basically to the functions get_Micrel_phy_speed() and get_IEEE_phy_speed().
code in the web page
// 파일명: xemacpsif.c
02-08-2017 05:26 AM
I also used the same PHY in my custom board and after lot of study I have solved this problem.
create the new application LWiP Echo server from template.
replace the below file with the file attached with this post.
use the packet sender to send and receive the packets from LWIP echo server application
NOTE: the actual board address 192.168.1.10 Port:7
02-08-2017 08:37 PM
to support a different phy other than marvell, you should be following this AR.
10-11-2018 10:54 PM
I run the LWIP echo template after replaced the file.
it's also not work correctly。
TCP packets sent to port 6001 will be echoed back
Start Micrel PHY autonegotiation
Waiting for PHY to complete autonegotiation.
link speed for phy address 3: 0
it always break here .
02-11-2019 05:19 PM
1000M can be achieved according to the instructions, but how to achieve 100mbps, or automatic negotiation。
02-15-2019 03:07 AM
i have boards with KZ9031. The patch mentioned previously by another user to add Micrel's OEM and DEV ID speed detect routines are required. I added those patches.
For me Auto negotiation works only the PHY for which the MDIO is configured. There are some links in the web which discuss about the problem with MDIO config and the auto negotiation. Sorry, did not book mark them.
But, in Board Support Package Settings, under lwip.., you can select the Speed 1000 or 100 or 10. I fixed it at 1000 and do not require auto nego.
Hope that is of some help.