Ethernet not working (JL2101)

tmm1

Member
I bought 5pc T95 Plus from https://zwin.en.alibaba.com/

In stock android, ethernet is working

But when I use the armbian image, ethernet fails.

I see this in dmesg:

Code:
rk_gmac-dwmac fe010000.ethernet: Failed to reset the dma
eth0: stmmac_hw_setup: DMA engine initialization failed
eth0: stmmac_open: Hw setup failed

I wonder if there is some hardware difference and I need a different DTB?

How can I download DTB from the stock Android image?
 

tmm1

Member
I pulled the dtb from /sys/firmware/ftd (after rooting with Magisk)

It looks identical..

I tried BSP kernels, with 4.19.232 it fails with DMA error:

Code:
[    3.790322] rk_gmac-dwmac fe010000.ethernet: Failed to reset the dma
[    3.790354] rk_gmac-dwmac fe010000.ethernet eth0: stmmac_hw_setup: DMA engine initialization failed
[    3.790363] rk_gmac-dwmac fe010000.ethernet eth0: stmmac_open: Hw setup failed

If I add a patch to msleep(1500), it can continue and sees link but never gets an IP:

Code:
[    8.242444] rk_gmac-dwmac fe010000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[    8.242626] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: no lease, forking to background

With BSP 5.10.110 I also see link but never get an IP.

Code:
[    4.258784] rk_gmac-dwmac fe010000.ethernet eth0: PHY [stmmac-1:00] driver [Generic PHY] (irq=POLL)

If I add a patch for JL2xx1 drivers (with and without this one too), the PHY changes from Generic to the custom drivers, but I still am not able to get IP address.

Code:
[    4.365597] rk_gmac-dwmac fe010000.ethernet eth0: PHY [stmmac-1:00] driver [JL2101 Gigabit Ethernet] (irq=POLL)

At the same time, the 4.19.172 kernel in the stock Android image is able to access ethernet no problem, with the generic driver:

Code:
[    0.000000] Linux version 4.19.172 (lb@ubuntu-PowerEdge-R730) (Android (6573524 based on r383902b) clang version 11.0.2 (https://android.googlesource.com/toolchain/llvm-project b397f81060ce6d701042b782172ed13bee898b79), LLD 11.0.2 (/buildbot/tmp/tmpF3FjA8 b397f81060ce6d701042b782172ed13bee898b79)) #35 SMP PREEMPT Mon Jun 27 10:26:20 CST 2022
[    0.000000] Machine model: Rockchip RK3566 BOX DEMO V10 ANDROID Board
...
[    0.538778] rk_gmac-dwmac fe010000.ethernet: no regulator found
[    0.538801] rk_gmac-dwmac fe010000.ethernet: clock input or output? (input).
[    0.538816] rk_gmac-dwmac fe010000.ethernet: TX delay(0x4f).
[    0.538830] rk_gmac-dwmac fe010000.ethernet: RX delay(0x2d).
[    0.538847] rk_gmac-dwmac fe010000.ethernet: integrated PHY? (no).
[    0.538883] rk_gmac-dwmac fe010000.ethernet: clock input from PHY
[    0.543905] rk_gmac-dwmac fe010000.ethernet: init for RGMII
[    0.544157] rk_gmac-dwmac fe010000.ethernet: User ID: 0x30, Synopsys ID: 0x51
[    0.544177] rk_gmac-dwmac fe010000.ethernet:     DWMAC4/5
[    0.544189] rk_gmac-dwmac fe010000.ethernet: DMA HW capability register supported
[    0.544201] rk_gmac-dwmac fe010000.ethernet: RX Checksum Offload Engine supported
[    0.544214] rk_gmac-dwmac fe010000.ethernet: TX Checksum insertion supported
[    0.544226] rk_gmac-dwmac fe010000.ethernet: Wake-Up On Lan supported
[    0.544260] rk_gmac-dwmac fe010000.ethernet: TSO supported
[    0.544274] rk_gmac-dwmac fe010000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    0.544288] rk_gmac-dwmac fe010000.ethernet: TSO feature enabled
[    0.677668] libphy: stmmac: probed
[   16.264962] Generic PHY stmmac-1:00: attached PHY driver [Generic PHY] (mii_bushy_addr=stmmac-1:00, irq=POLL)
[   19.318761] dwmac4: Master AXI performs any burst length
[   19.318838] rk_gmac-dwmac fe010000.ethernet eth0: No Safety Features support found
[   19.318864] rk_gmac-dwmac fe010000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[   19.327772] rk_gmac-dwmac fe010000.ethernet eth0: registered PTP clock
[   20.350144] rk_gmac-dwmac fe010000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
 

tmm1

Member
I found some more debugging information on csdn:


I think the PHY is not receiving proper clock, so its not functioning correctly.

My kernel:

Code:
[    0.935304] rockchip-dmc dmc: Looking up center-supply from device tree
[    0.935357] rockchip-dmc dmc: Linked as a consumer to regulator.6
[    0.935415] rockchip-dmc dmc: Cannot get the clk dmc_clk. If using SCMI, trusted firmware need update to V1.01 and above
[    0.935473] rockchip-dmc dmc: Dropping the link to regulator.6
[    0.935513] rockchip-dmc: probe of dmc failed with error -2

Android kernel:

Code:
[    1.076744] rockchip-dmc dmc: Linked as a consumer to regulator.6
[    1.076788] rockchip-dmc dmc: current ATF version 0x101
[    1.077625] rockchip-dmc dmc: leakage=54
[    1.077689] rockchip-dmc dmc: leakage-volt-sel=0
[    1.077738] rockchip-dmc dmc: pvtm = 87980, from nvmem
[    1.078085] rockchip-dmc dmc: avs=0
[    1.078122] rockchip-dmc dmc: failed to get vop pn to msch rl
[    1.078277] rockchip-dmc dmc: l=0 h=2147483647 hyst=5000 l_limit=0 h_limit=0 h_table=0
[    1.078326] rockchip-dmc dmc: could not find power_model node
[    1.093907] devfreq dmc: Couldn't update frequency transition information.
 

tmm1

Member
If I add a patch to msleep(1500), it can continue and sees link but never gets an IP:

I made a better version of this patch which waits longer in stmmac_reset for DMA reset:

Code:
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
index 32461909264a..adbb107fe750 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
@@ -22,7 +22,7 @@ int dwmac4_dma_reset(void __iomem *ioaddr)
     /* DMA SW reset */
     value |= DMA_BUS_MODE_SFT_RESET;
     writel(value, ioaddr + DMA_BUS_MODE);
-    limit = 10;
+    limit = 150;
     while (limit--) {
         if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET))
             break;

With this version the dwmac-rk-tool.c also works, which allows delayline scanning via:

Code:
echo 1000 > /sys/devices/platform/fe010000.ethernet/phy_lb_scan

With my kernel the scan returns no results. With stock android kernel it works fine.
 

tmm1

Member
I realized I was building BSP kernel but with generic rk356x defconfig. I used imgrepackerrk /cid /2nd on the original T95.img to get the working kernel. Then I used scripts/extract-ikconfig to get original Kconfig

I used that Kconfig to compile linux-rockchip, and tried my tests again. I was able to get a DHCP IP using this patch: https://github.com/LubanCat/LubanCa...ckchip/patches-5.15/209-fix-stmmac_mdio.patch

With the original kernel file, I was also able to use vmlinux-to-elf to load into Ghidra, and I confirmed that they are using the same patch inside that kernel also.
 

tmm1

Member
I confirmed ethernet is also working in rockchip-linux/kernel 5.10.110. I was also able to make delayline scanning and phy test work.

Code:
root@rk3566-t95plus:/sys/devices/platform/fe010000.ethernet# echo 1000 > phy_lb
[  194.787080] PHY loopback speed set to 1000
[  196.642842] dwmac4: Master AXI performs any burst length
[  196.850269] rk_gmac-dwmac fe010000.ethernet eth0: PHY [stmmac-1:00] driver [Generic PHY] (irq=POLL)
[  197.948028] dwmac4: Master AXI performs any burst length
[  197.948138] rk_gmac-dwmac fe010000.ethernet eth0: No Safety Features support found
[  197.948209] rk_gmac-dwmac fe010000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[  197.948894] rk_gmac-dwmac fe010000.ethernet eth0: registered PTP clock
[  197.948957] rk_gmac-dwmac fe010000.ethernet eth0: configuring for phy/rgmii link mode
[  197.949636] PHY loopback: PASS

Code:
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index 093a223fe408..e160aaa43be1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -365,6 +365,11 @@ int stmmac_mdio_register(struct net_device *ndev)
         goto bus_register_fail;
     }
 
+    stmmac_mdio_write(new_bus, 0, 31, 2627);
+    stmmac_mdio_write(new_bus, 0, 25, 0x1801);
+    stmmac_mdio_write(new_bus, 0, 31, 0);
+    stmmac_mdio_write(new_bus, 0, 0,  0x8000);
+
     if (priv->plat->phy_node || mdio_node)
         goto bus_register_done;
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
index e40e312c00a4..14c93d600cc6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
@@ -22,7 +22,7 @@ int dwmac4_dma_reset(void __iomem *ioaddr)
 
     return readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
                  !(value & DMA_BUS_MODE_SFT_RESET),
-                 500, 1000000);
+                 500, 1500000);
 }
 
 void dwmac4_set_rx_tail_ptr(void __iomem *ioaddr, u32 tail_ptr, u32 chan)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk-tool.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk-tool.c
index 541788f9e2c8..6a49ad76328a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk-tool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk-tool.c
@@ -1306,7 +1306,7 @@ static int dwmac_rk_get_max_delayline(struct stmmac_priv *priv)
 static int dwmac_rk_phy_poll_reset(struct stmmac_priv *priv, int addr)
 {
     /* Poll until the reset bit clears (50ms per retry == 0.6 sec) */
-    unsigned int val, retries = 12;
+    unsigned int val, retries = 12 * 3;
     int ret;
 
     val = mdiobus_read(priv->mii, addr, MII_BMCR);
@@ -1366,7 +1366,7 @@ static int dwmac_rk_loopback_run(struct stmmac_priv *priv,
             reset_control_deassert(priv->plat->stmmac_rst);
     }
     /* wait for phy and controller ready */
-    usleep_range(100000, 200000);
+    usleep_range(1500000, 2000000);
 
     dwmac_rk_set_loopback(priv, lb_priv->type, lb_priv->speed,
                   true, phy_addr, true);
 

mmie4jbcu

New member
I confirmed ethernet is also working in rockchip-linux/kernel 5.10.110. I was also able to make delayline scanning and phy test work.

Code:
root@rk3566-t95plus:/sys/devices/platform/fe010000.ethernet# echo 1000 > phy_lb
[  194.787080] PHY loopback speed set to 1000
[  196.642842] dwmac4: Master AXI performs any burst length
[  196.850269] rk_gmac-dwmac fe010000.ethernet eth0: PHY [stmmac-1:00] driver [Generic PHY] (irq=POLL)
[  197.948028] dwmac4: Master AXI performs any burst length
[  197.948138] rk_gmac-dwmac fe010000.ethernet eth0: No Safety Features support found
[  197.948209] rk_gmac-dwmac fe010000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[  197.948894] rk_gmac-dwmac fe010000.ethernet eth0: registered PTP clock
[  197.948957] rk_gmac-dwmac fe010000.ethernet eth0: configuring for phy/rgmii link mode
[  197.949636] PHY loopback: PASS

Code:
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index 093a223fe408..e160aaa43be1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -365,6 +365,11 @@ int stmmac_mdio_register(struct net_device *ndev)
         goto bus_register_fail;
     }
 
+    stmmac_mdio_write(new_bus, 0, 31, 2627);
+    stmmac_mdio_write(new_bus, 0, 25, 0x1801);
+    stmmac_mdio_write(new_bus, 0, 31, 0);
+    stmmac_mdio_write(new_bus, 0, 0,  0x8000);
+
     if (priv->plat->phy_node || mdio_node)
         goto bus_register_done;
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
index e40e312c00a4..14c93d600cc6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
@@ -22,7 +22,7 @@ int dwmac4_dma_reset(void __iomem *ioaddr)
 
     return readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
                  !(value & DMA_BUS_MODE_SFT_RESET),
-                 500, 1000000);
+                 500, 1500000);
 }
 
 void dwmac4_set_rx_tail_ptr(void __iomem *ioaddr, u32 tail_ptr, u32 chan)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk-tool.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk-tool.c
index 541788f9e2c8..6a49ad76328a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk-tool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk-tool.c
@@ -1306,7 +1306,7 @@ static int dwmac_rk_get_max_delayline(struct stmmac_priv *priv)
 static int dwmac_rk_phy_poll_reset(struct stmmac_priv *priv, int addr)
 {
     /* Poll until the reset bit clears (50ms per retry == 0.6 sec) */
-    unsigned int val, retries = 12;
+    unsigned int val, retries = 12 * 3;
     int ret;
 
     val = mdiobus_read(priv->mii, addr, MII_BMCR);
@@ -1366,7 +1366,7 @@ static int dwmac_rk_loopback_run(struct stmmac_priv *priv,
             reset_control_deassert(priv->plat->stmmac_rst);
     }
     /* wait for phy and controller ready */
-    usleep_range(100000, 200000);
+    usleep_range(1500000, 2000000);
 
     dwmac_rk_set_loopback(priv, lb_priv->type, lb_priv->speed,
                   true, phy_addr, true);
Can you please share the kernel and the dtb file?
I tried doing the patches from above posts but ethernet is not working on my board having the rtl8211f chip.
 

tmm1

Member
Hm these patches are only required for JL2101 chipset.

What issue are you having with yours? Can you share dmesg
 

mmie4jbcu

New member
Hm these patches are only required for JL2101 chipset.

What issue are you having with yours? Can you share dmesg

Ethernet is being detected and being brought up. After that it continuously shows link up/down
Here's the dmesg:
Code:
$ dmesg | grep eth
[    0.000000] psci: probing for conduit method from DT.
[    2.916802] rk_gmac-dwmac fe010000.ethernet: IRQ eth_lpi not found
[    2.917695] rk_gmac-dwmac fe010000.ethernet: no regulator found
[    2.918247] rk_gmac-dwmac fe010000.ethernet: clock input or output? (input).
[    2.918893] rk_gmac-dwmac fe010000.ethernet: TX delay(0x4f).
[    2.919413] rk_gmac-dwmac fe010000.ethernet: RX delay(0x2d).
[    2.919959] rk_gmac-dwmac fe010000.ethernet: integrated PHY? (no).
[    2.920649] rk_gmac-dwmac fe010000.ethernet: clock input from PHY
[    2.926229] rk_gmac-dwmac fe010000.ethernet: init for RGMII
[    2.927159] rk_gmac-dwmac fe010000.ethernet: User ID: 0x30, Synopsys ID: 0x51
[    2.927823] rk_gmac-dwmac fe010000.ethernet:     DWMAC4/5
[    2.928341] rk_gmac-dwmac fe010000.ethernet: DMA HW capability register supported
[    2.929025] rk_gmac-dwmac fe010000.ethernet: RX Checksum Offload Engine supported
[    2.929703] rk_gmac-dwmac fe010000.ethernet: TX Checksum insertion supported
[    2.930341] rk_gmac-dwmac fe010000.ethernet: Wake-Up On Lan supported
[    2.931027] rk_gmac-dwmac fe010000.ethernet: TSO supported
[    2.931535] rk_gmac-dwmac fe010000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    2.932294] rk_gmac-dwmac fe010000.ethernet: Enabled RFS Flow TC (entries=10)
[    2.932951] rk_gmac-dwmac fe010000.ethernet: TSO feature enabled
[    2.933503] rk_gmac-dwmac fe010000.ethernet: Using 32 bits DMA width
[   12.341060] Driver 'hci_uart_qca' needs updating - please use bus_type methods
[   19.715442] rk_gmac-dwmac fe010000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
[   19.808175] rk_gmac-dwmac fe010000.ethernet eth0: PHY [stmmac-0:01] driver [RTL8211F Gigabit Ethernet] (irq=POLL)
[   19.816210] rk_gmac-dwmac fe010000.ethernet eth0: No Safety Features support found
[   19.816247] rk_gmac-dwmac fe010000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[   19.816658] rk_gmac-dwmac fe010000.ethernet eth0: registered PTP clock
[   19.817233] rk_gmac-dwmac fe010000.ethernet eth0: configuring for phy/rgmii link mode
[   30.089707] rk_gmac-dwmac fe010000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[   30.089775] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   34.180207] rk_gmac-dwmac fe010000.ethernet eth0: Link is Down
[   46.473335] rk_gmac-dwmac fe010000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[   50.564110] rk_gmac-dwmac fe010000.ethernet eth0: Link is Down
[   59.784996] rk_gmac-dwmac fe010000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[   63.875437] rk_gmac-dwmac fe010000.ethernet eth0: Link is Down
[   70.027107] rk_gmac-dwmac fe010000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[   73.091623] rk_gmac-dwmac fe010000.ethernet eth0: Link is Down

Additional info: I am using kernel version 6.1.1-rk35xx from the armbian repo.
 

BliteKnight

New member
Hm these patches are only required for JL2101 chipset.

What issue are you having with yours? Can you share dmesg
I also have the JL2101 chipset - could you provide how you implemented the patch as I can't get my ethernet to get an IP
Thanks
 
Top