IMX6 Ethernet. Development process to add second ethernet PHY IC support. part 3.

In previous chapter we modified DTS to add support for second PHY IC on our IMX6 Ethernet equipped SoM.

Time to test it.

After compilation of image:

$ ./compile.sh flexcan_wifi
and updating device firmware:
root@OpenWrt:/#  scp user@host_address:/path_to_project/lorawan-imx6ull/bin/targets/imx6ull/cortexa7/openwrt-imx6ull-cortexa7-flexcan_wifi-squashfs.mtd-sysupgrade.bin /tmp
root@OpenWrt:/# sysupgrade -c /tmp/openwrt-imx6ull-cortexa7-flexcan_wifi-squashfs.mtd-sysupgrade.bin
check logs first:
root@OpenWrt:/# dmesg | grep eth
[     0.669455] fec 20b4000.ethernet: 20b4000.ethernet supply phy not found, using dummy regulator
[     0.736068] fec 20b4000.ethernet: Invalid MAC address: 00:00:00:00:00:00
[     0.743299] fec 20b4000.ethernet: Using random MAC address: 06:ad:5c:86:06:fb
[     0.793239] fec 20b4000.ethernet eth0: registered PHC device 0
[     0.796583] fec 2188000.ethernet: 2188000.ethernet supply phy not found, using dummy regulator
[     0.869365] fec 2188000.ethernet eth1: registered PHC device 1
[     7.792766] Micrel KSZ8081 or KSZ8091 2188000.ethernet-2:03: attached PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=2188000.ethernet-2:03, irq=POLL)
[     7.793353] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[     9.841219] fec 20b4000.ethernet eth0: Link is Up – 100Mbps/Full – flow control off
[     9.841291] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   58.249878] Micrel KSZ8081 or KSZ8091 2188000.ethernet-2:03: attached PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=2188000.ethernet-2:03, irq=POLL)
[   58.250094] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   60.482398] fec 20b4000.ethernet eth0: Link is Up – 100Mbps/Full – flow control off
[   60.483099] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 114.436870] Micrel KSZ8081 or KSZ8091 2188000.ethernet-2:03: attached PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=2188000.ethernet-2:03, irq=POLL)
[ 114.437720] br-lan: port 1(eth0) entered blocking state
[ 114.437744] br-lan: port 1(eth0) entered disabled state
[ 114.438204] device eth0 entered promiscuous mode
[ 114.444940] br-lan: port 1(eth0) entered blocking state
[ 114.444969] br-lan: port 1(eth0) entered forwarding state
[ 115.377165] br-lan: port 1(eth0) entered disabled state
[ 116.465173] fec 20b4000.ethernet eth0: Link is Up – 100Mbps/Full – flow control off
[ 116.465271] br-lan: port 1(eth0) entered blocking state
[ 116.465292] br-lan: port 1(eth0) entered forwarding state

here we see that both ethernet controllers 20b4000 and 2188000 initialized.

Let’s try to configure networks.

Step 5. Network configuration.

root@OpenWrt:/# vi /etc/config/network
modify lan to get it as following:
config interface ‘lan’
# option type ‘bridge’
option ifname ‘eth0’
option proto ‘dhcp’
#                 option ipaddr ‘192.168.1.1’
#                 option netmask ‘255.255.255.0’
#                 option ip6assign ’60’
and add another one network:
config interface ‘lan2’
option ifname ‘eth1’
option proto ‘dhcp’
then exit (by typing :wq) and restart network configuration:
root@OpenWrt:/# /etc/init.d/network  restart
and check if ip addresses taken:
root@OpenWrt:/# ifconfig eth0 && ifconfig eth1
eth0           Link encap:Ethernet HWaddr 06:AD:5C:86:06:FB
inet addr:192.168.0.122 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::4ad:5cff:fe86:6fb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:605 errors:0 dropped:0 overruns:0 frame:0
TX packets:1228 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:88497 (86.4 KiB) TX bytes:231956 (226.5 KiB)
eth1           Link encap:Ethernet HWaddr 00:11:22:33:44:55
inet addr:192.168.0.118 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::211:22ff:fe33:4455/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:482 errors:0 dropped:0 overruns:0 frame:0
TX packets:133 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:39921 (38.9 KiB) TX bytes:12518 (12.2 KiB)
it is working!
Let’s check if link exists under u-boot. Reboot device and press enter during u-boot countdown and check mdio bus info:
=> mii info
PHY 0x00: OUI = 0x0885, Model = 0x16, Rev = 0x01, 10baseT, HDX
PHY 0x03: OUI = 0x0885, Model = 0x16, Rev = 0x01, 10baseT, HDX
10baseT Half-Dupliex is the lowest possible speed and duplicity, which is an indicator then network is not exist.
Dumping phy registers shows that link is not exist:
=> mii dump 0 1
1. (7849)                             — PHY status register —
(8000:0000)   1.15     =    0       100BASE-T4 able
(4000:4000)   1.14    =     1      100BASE-X full duplex able
(2000:2000)   1.13    =     1      100BASE-X half duplex able
(1000:1000)   1.12    =     1      10 Mbps full duplex able
(0800:0800)   1.11    =     1      10 Mbps half duplex able
(0400:0000)   1.10    =     0      100BASE-T2 full duplex able
(0200:0000)   1. 9    =      0      100BASE-T2 half duplex able
(0100:0000)   1. 8    =      0      extended status
(0080:0000)   1. 7    =      0      (reserved)
(0040:0040)   1. 6    =      1      MF preamble suppression
(0020:0020)   1. 5    =      0      A/N complete
(0010:0000)   1. 4    =      0      remote fault
(0008:0008)   1. 3    =      1      A/N able
(0004:0004)   1. 2    =      0      link status
(0002:0000)   1. 1    =      0      jabber detect
(0001:0001)   1. 0    =      1      extended capabilities

Seems that DTS used by u-boot unable to initialize properly at least first PHY IC in a case of MDIO shared between two ICs. Again need to modify DTS but for u-boot now.

Step 6. U-boot’s DTS modification.

It is not so obvious to find u-boot DTS in source code repo as in the case of linux DTS as u-boot’s DTS created by patch during build process.
As we already have built image we could find it here:
$ cat ./build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/u-boot-wirelessroad_ecspi3/u-boot-2017.07/arch/arm/dts/wirelessroad_ecspi3.dts
scrolling to fec1 node:

&fec1 {
pinctrl-names = “default”;
pinctrl-0 = <&pinctrl_enet1>;
phy-mode = “rmii”;
phy-handle = <&ethphy0>;
status = “okay”;
mdio {
#address-cells = <1>;
#size-cells = <0>;

ethphy0: ethernet-phy@2 {
compatible = “ethernet-phy-ieee802.3-c22”;
reg = <2>;
};

};
};

Looks similar to Linux’s DTS but PHY IC address on MDIO bus is 2. Seems it is a mistake. Changed it to 0, recompiled image again, updated firmware and checked PHY status again:

=> mii info
PHY 0x00: OUI = 0x0885, Model = 0x16, Rev = 0x01, 100baseT, FDX
PHY 0x03: OUI = 0x0885, Model = 0x16, Rev = 0x01, 100baseT, FDX
=> setenv ipaddr 192.168.0.99
=> setenv ethaddr 00:11:22:33:44:55
=> ping 192.168.0.100
Using FEC0 device
host 192.168.0.100 is alive
It works!
So commit with all described changes might be found here.
Join our telegram channel to see more photo and video of hardware development.