avafinger / orangepi-h6-ubuntu-base-minimal

Mainline kernel 5.1 5.2 5.3 5.4 H6 (Orange Pi One Plus)
19 stars 5 forks source link

Can't get ethernet to work #1

Closed iscle closed 5 years ago

iscle commented 5 years ago

Hi,

thanks for your incredible work. I've tested the latest LXDE build and the one hosted on Mega (available on the README.md), and neither of them seem to have ethernet working. It won't even get an IP from the DHCP server. I've tried editing the "/etc/network/interfaces" file and still not working. Of course, I know my ethernet cable works fine.

Do you have any clue at what could be happening?

My link should be 100Mbps instead of Gigabit, maybe 100Mbps is unsupported right now?

Thanks, Iscle

avafinger commented 5 years ago

Yes, 100Mbps has a high latency and should be avoided, better consider it broken. But works fine with Gbps. I have 100 Mbps working here but it is a pain....

iscle commented 5 years ago

Hmm, is there any way to get it working with 100Mbps? I don't have an accessible Gigabit port to use...

avafinger commented 5 years ago

You can try to adjust emac rx-delay and/or tx-delay, which is in /boot/opi-h6.dtb (DT). Start with rx (rx-delay must be a multiple of 100 i.e 100,200,300...) and see if can get an IP at some point. Every time you change the value you must shut down and power cycle the board and see if has improved.

Check wihich file you should edit (opi-h6.dtb is a symlink to a file): ls -la opi-h6.dtb

Decompile the file (not the symlink) DTB with DTC (install dtc): For example: sudo dtc -I dtb -o opi.dts opi-h6.dtb_5.1.0-rc2-hdmi-h6

Edit the file **opi.dts(( and change the value, save and compile to DTB again. Boot and check if improved.

Find the string: ethernet@5020000 { compatible = "allwinner,sun50i-h6-emac", "allwinner,sun50i-a64-emac"; syscon = <0x1f>; reg = <0x5020000 0x10000>; interrupts = <0x0 0xc 0x4>; interrupt-names = "macirq"; resets = <0x2 0x21>; reset-names = "stmmaceth"; clocks = <0x2 0x54>; clock-names = "stmmaceth"; status = "okay";

address-cells = <0x1>;

        #size-cells = <0x0>;
        pinctrl-names = "default";
        pinctrl-0 = <0x20>;
        phy-mode = "rgmii";
        phy-handle = <0x21>;
        phy-supply = <0x22>;
        **allwinner,rx-delay-ps = <0x0>;**
        **allwinner,tx-delay-ps = <0x0>;**

re-compile with: sudo dtc -I dts -o opi-h6.dtb_5.1.0-rc2-hdmi-h6 opi.dts

Not sure this will work but it worth a try.

iscle commented 5 years ago

Perfect, I will try it and report back. It's strange, as with the original OrangePi image and with Armbian it works perfectly!

avafinger commented 5 years ago

Alternatively you can use kernel 3.10.65-h6 which is a bit improved from the Xulong version. I have one Image with this kernel but it is Ubuntu 16.04.5 LTS , can't run 18.04 on this old kernel or you get some missing sys message due to up to date systemd.

avafinger commented 5 years ago

I think Armbian is based on a different kernel or has some additional patch. Maybe you can compare the DTS and see what is different and apply it to dtb and see what happens.

avafinger commented 5 years ago

Armbian has this setup:

allwinner,rx-delay-ps = <200>;
allwinner,tx-delay-ps = <200>;
iscle commented 5 years ago

Nice, thanks for looking into it. I will try to do the changes and report back. I'm still learning about dtb and dts, as well as the Linux kernel, so I'll have to do some research first :)

Thanks for your help!

avafinger commented 5 years ago

@Iscle I tested these values and this fixed the 100Mbps. It works.

Anyway, Since you want to learn how to work with dtc, the command to recompile missed one parameter: sudo dtc -I dts -O dtb -o opi-h6.dtb_5.1.0-rc2-hdmi-h6 opi.dts

To install DTC: sudo apt-get install device-tree-compiler , but hey, you need ethernet connection. Not to worry, you can do it on any host PC with linux and copy the dtb back.

Here is the latest dtb with 100Mbps fixed. opi-h6.dtb_5.1.0-rc2-hdmi-h6.tar.gz opi-h6.dtb_5.0.2-h6.tar.gz

iscle commented 5 years ago

Works perfectly now! Thanks :)