linux-sunxi / meta-sunxi

Official sunxi OpenEmbedded layer for Allwinner-based boards.
MIT License
140 stars 172 forks source link

Ethernet not working on Orange Pi One Plus (H6) #387

Closed retpolanne closed 11 months ago

retpolanne commented 1 year ago

Hello! I wanted to use this issue to document what we need to enable Ethernet on the Orange Pi One Plus.

It seems that the Orange Pi One Plus doesn't have upstream support for ethernet:

U-Boot 2023.04-gfd4ed6b (Apr 03 2023 - 20:38:50 +0000) Allwinner Technology

CPU:   Allwinner H6 (SUN50I)
Model: OrangePi One Plus
DRAM:  2 GiB
Core:  53 devices, 16 uclasses, devicetree: separate
WDT:   Not starting watchdog@7020400
MMC:   mmc@4020000: 0
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... 
In:    serial@5000000
Out:   serial@5000000
Err:   serial@5000000
Net:   No ethernet found.
starting USB...
Bus usb@5101000: USB EHCI 1.00
Bus usb@5101400: USB OHCI 1.0
Bus usb@5311000: USB EHCI 1.00
Bus usb@5311400: USB OHCI 1.0
scanning bus usb@5101000 for devices... 1 USB Device(s) found
scanning bus usb@5101400 for devices... 1 USB Device(s) found
scanning bus usb@5311000 for devices... 1 USB Device(s) found
scanning bus usb@5311400 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0 
=> dhcp
No ethernet found.

I made a hacky patch (attached to this issue) and added it to sunxi bbappends. 0003-sunxi-H6-Enable-Ethernet-on-Orange-Pi-One-Plus.patch

=> dhcp
sun8i_emac_eth_start: Timeout

Added the CONFIG_RTL8211E_PINE64_GIGABIT_FIX from [3] and started seeing also this error:

=> dhcp
mdio_register: non unique device name 'ethernet@5020000'
sun8i_emac_eth_start: Timeout

The thread [4] reports the same error.

These are a few links I'm using for reference:

[1] https://patchwork.ozlabs.org/project/uboot/patch/20200507231052.23706-3-samuel@sholland.org/ [2] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20180722053955.25266-6-icenowy@aosc.io/ [3] https://patchwork.ozlabs.org/project/uboot/patch/20180214230216.2001-2-kevans@FreeBSD.org/ [4] https://lists.denx.de/pipermail/u-boot/2021-June/451357.html [5] https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=67&state=%2A&archive=both

DTB dump for Orange Pi One Plus

dtc -I dtb -O dts ./1_2023.04-r0/build/arch/arm/dts/sun50i-h6-orangepi-one-plus.dtb

                ethernet@5020000 {
                        compatible = "allwinner,sun50i-h6-emac\0allwinner,sun50i-a64-emac";
                        syscon = <0x1c>;
                        reg = <0x5020000 0x10000>;
                        interrupts = <0x00 0x0c 0x04>;
                        interrupt-names = "macirq";
                        resets = <0x02 0x21>;
                        reset-names = "stmmaceth";
                        clocks = <0x02 0x54>;
                        clock-names = "stmmaceth";
                        status = "okay";
                        pinctrl-names = "default";
                        pinctrl-0 = <0x1d>;
                        phy-mode = "rgmii-id";
                        phy-handle = <0x1e>;
                        phy-supply = <0x1f>;
                        allwinner,rx-delay-ps = <0xc8>;
                        allwinner,tx-delay-ps = <0xc8>;
                        phandle = <0x58>;

                        mdio {
                                compatible = "snps,dwmac-mdio";
                                #address-cells = <0x01>;
                                #size-cells = <0x00>;
                                phandle = <0x59>;

                                ethernet-phy@1 {
                                        compatible = "ethernet-phy-ieee802.3-c22";
                                        reg = <0x01>;
                                        phandle = <0x1e>;
                                };
                        };
                };
retpolanne commented 1 year ago

For documentation:

Mailing thread: https://lore.kernel.org/u-boot/d0427cea18fad6e36537931962fa5070b084045e.camel@collabora.com/T/#t

Changing TFA make parameters

--- a/recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend
+++ b/recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend
@@ -5,3 +5,5 @@ TFA_PLATFORM:sun50i-h6 = "sun50i_h6"
 TFA_PLATFORM:sun50i-h616 = "sun50i_h616"

 TFA_BUILD_TARGET = "bl31"
+#EXTRA_OEMAKE += " SUNXI_SETUP_REGULATORS=0 LOG_LEVEL=40"
+EXTRA_OEMAKE += " LOG_LEVEL=40"

Recompiling TFA and bootloader

bitbake -ccleansstate trusted-firmware-a 
bitbake virtual/bootloader

Sending to SDCard only the bootloader

sudo dd if=../orange-pi-one-plus/tmp/deploy/images/orange-pi-one-plus/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8
retpolanne commented 12 months ago

Sent a patch fixing it :)

https://lore.kernel.org/u-boot/20230711003957.658805-2-retpolanne@posteo.net/T/#u

nandra commented 12 months ago

ok nice, can you post PR with this patch to this meta layer please? Thanks.

retpolanne commented 12 months ago

Sure! Will do. I'll be out the whole day but I should send it today or tomorrow Brazil time

retpolanne commented 11 months ago

Patch sent to upstream and added to bbappend. Closing this ;)