prepare-ethphy.sh: fix phy detection when interface is down
This MR improves the robustness of detection of PHY chip in FNG System. This is a result of work on issue described in [YT-181] FNGSystem: postinstall: detection of Ethernet PHY sometimes work incorrectly.
On our Tanaro board with removed content of /etc/shared
folder (e.g. config.xml
) , we observed that one of network interfaces is not visible/detectable out of box. We dug into the problem further and found that:
-
Linux kernel starts to see a network interface only when a corresponding PHY chip is initialized and a "phydev" node is created in sysyfs. But this node appears only after a "link" for corresponding Ethernet interface is up:
# stat /sys/class/net/eth0/phydev stat: can't stat '/sys/class/net/eth0/phydev': No such file or directory # ip link set dev eth0 up [ 2416.704190] Qualcomm Atheros AR8031/AR8033 30be0000.ethernet-1:00: attached PHY driver (mii_bus:phy_addr=30be0000.ethernet-1:00, irq=POLL) [ 2419.776455] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready [ 2419.783612] fec 30be0000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off # stat /sys/class/net/eth0/phydev File: '/sys/class/net/eth0/phydev' -> '../../mdio_bus/30be0000.ethernet-1/30be0000.ethernet-1:00' Size: 0 Blocks: 0 IO Block: 4096 symbolic link Device: 17h/23d Inode: 28272 Links: 1 Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2018-03-09 14:07:06.420000000 +0000 Modify: 2018-03-09 14:07:06.420000000 +0000 Change: 2018-03-09 14:07:06.420000000 +0000
-
By default (without
config.xml
in/etc/shared
folder), "links" for all interfaces are in down state when FNG System start. So, if installation of FNG System is performed using anohter Ethernet interface, SD card or USB Flash Drive, theprepare-ethphy.sh
script will ignore the second network interface and will add anethernet-without-gb-phy-overlay.dtbo
to/boot/overlays.txt
file. As a result, the problem FEC interface will become unavailable after reboot.
To not depend on content of /etc/shared
folder, we just added a routine to bring-up link, before prepare-ethpy.sh
is executed.