Porting guide ar71xx to ath79?

@hnyman I can do the PR for WNDR3800, but can you help me too?

Im very bad in bash. I need scripts for getting mac addresses.

I can do the PR for WNDR3800, no problem with that.
But I need to compile the test build first :wink:

And if your PR gets accepted and merged first, I can simply modify your 10-ath9k-eeprom by adding lines for WNDR3800 there (instead of adding the whole sections in the PR).

@hnyman Can you help with the mac address scripts. They don't work.
My device can't get them in dts.

How is it coded in caldata? Not the normal 6-bytes MAC?

Ps. You have a typo on the commit: "suuport"

@most
In the Github PR you suggested removing the reset for 8 / phy for eth0 in WNDR3800 (and leaving only 9 / mac). Where did that come from? Likely quite correct, but why?

I got the wifi working on WNDR3800, thanks for pointers. Did not much test it, but works at least somehow.

I still wonder about

  • the shared IRQ 12 for wlan0 and wlan1
  • the MAC addresses (how should wlan0 have different MAC than eth0, if the "locally managed address" bit can't be set in DTS. )

It is stored in ascii in the form of 00:11:22:33:44:55.
Actually I figured that out. It didn't accept the script after sysupgrade. firstboot was needed.

...suggested removing the reset for 8 / phy for eth0 in WNDR3800... Likely quite correct, but why?

To remove the resets was suggested by 981213 ~2 days ago in the PR:

Try to remove the phy resets defined in ar7100.dtsi. they might cause some unwanted switch reset if the switch reset pin is connected to either ETH0_RESET_L or ETH1_RESET_L.

I guess that then is the case. Or should that instead be stated as a "switch" reset in the switch section (that I have seen in some dts files)?

I previously have tried to use initvals to mitigate the problems there was with the switch that only port 1 worked correctly. Initvals seemed to have solved the problem as well (I found some values for ramips based unit that also had rtl8366s).

I don't really understand how the eth0 and eth1 interfaces are connected with the switch and with the phy (for eth0 and eth1 respectively). One thing that I think is odd is that the switch is involved as well in the eth1 interface somehow? (the phy is connected trough the mdio-bus sorted under the switch entry in the dts.) I tested a lot of variants to solve the switch problem, including creating a separate mdio0 entry outside the switch. Not really successfull.

Why is only the mac reset kept for the eth1 interface in the current dts file? For me it makes sense to have the phy reset there.

the shared IRQ 12 for wlan0 and wlan1

I wonder as well. According to juppin above (June 10) there is a dummy irq driver in ar71xx - so maybe that is ok to appear to share IRQ? (according to juppin there are physical IRQs between 0-7).

the MAC addresses..."locally managed address" bit...

There is a hotplug script 10_fix_wifi_mac. Can that be adjusted?

Regarding wlan0 having the earlier the same MAC address (read from art) as eth0:

Set the locally administered bit on the eth0 MAC to make it unique. ...

In the ar71xx version, eth0 has the first byte of MAC has been ORred with 2 to make it unique (and "locally administered"). C6:3D:xx:xx:3F:50 for eth0 vs. C4:3D:xx:xx:3F:50 for wlan0

Could be.

Other alternative might be to extend the Openwrt-specific kernel patch that defines mtd-mac-address property: https://github.com/openwrt/openwrt/blob/master/target/linux/generic/pending-4.14/681-NET-add-of_get_mac_address_mtd.patch

It might be enhanced to mimic the same actions that init ath79_init_local_mac has done earlier. https://github.com/openwrt/openwrt/blob/c49ae68cbaf078a3dacaebf453d9e7ece2e861f5/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c#L1247

That could be done by defining an additional property in style of mtd-mac-address-increment that would then toggle the one bit to set "locally managed" status.

But that might be farfetched, as there are apparently only 4 users of init ath79_init_local_mac function in ar71xx.

I got also the wifi LEDs to work in WNDR3800 with the patch below. I used the same LED names as are visible in ar71xx.

diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index b55ae0dbb3..36d1b249f0 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -71,4 +71,24 @@ case "$FIRMWARE" in
 		;;
 	esac
 	;;
+"ath9k-eeprom-pci-0000:00:11.0.bin")
+	case $board in
+	netgear,wndr3800)
+		ath9k_eeprom_extract "art" 4096 3768
+		;;
+	*)
+		ath9k_eeprom_die "board $board is not supported yet"
+		;;
+	esac
+	;;
+"ath9k-eeprom-pci-0000:00:12.0.bin")
+	case $board in
+	netgear,wndr3800)
+		ath9k_eeprom_extract "art" 20480 3768
+		;;
+	*)
+		ath9k_eeprom_die "board $board is not supported yet"
+		;;
+	esac
+	;;
 esac
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts b/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts
index 59b868480a..4ccd7533e0 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts
@@ -70,6 +70,22 @@
 		};
 	};
 
+	ath9k-leds {
+		compatible = "gpio-leds";
+		wlan2g {
+			label = "ath9k-phy0";
+			gpios = <&ath9k0 5 GPIO_ACTIVE_LOW>;
+			default-state = "off";
+			linux,default-trigger = "phy0tpt";
+		};
+		wlan5g {
+			label = "ath9k-phy1";
+			gpios = <&ath9k1 5 GPIO_ACTIVE_LOW>;
+			default-state = "off";
+			linux,default-trigger = "phy1tpt";
+		};
+	};
+
 	gpio-keys-polled {
 		compatible = "gpio-keys-polled";
 		#address-cells = <1>;
@@ -137,6 +153,24 @@
 
 &pcie0 {
 	status = "okay";
+
+	ath9k0: wifi@0,11 {
+		compatible = "pci168c,0029";
+		reg = <0x8800 0 0 0 0x10000>;
+		mtd-mac-address = <&art 0x0>;
+		qca,no-eeprom;
+		#gpio-cells = <2>;
+		gpio-controller;
+	};
+
+	ath9k1: wifi@0,12 {
+		compatible = "pci168c,0029";
+		reg = <0x9000 0 0 0 0x10000>;
+		mtd-mac-address = <&art 0xc>;
+		qca,no-eeprom;
+		#gpio-cells = <2>;
+		gpio-controller;
+	};
 };
 
 &uart {
@@ -192,6 +226,9 @@
 
 	mtd-mac-address = <&art 0x00>;
 
+	resets = <&rst 9>;
+	reset-names = "mac";
+
 	fixed-link {
 		speed = <1000>;
 		full-duplex;
diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk
index a6de86eade..e5c4bd0fb2 100644
--- a/target/linux/ath79/image/generic.mk
+++ b/target/linux/ath79/image/generic.mk
@@ -115,7 +115,7 @@ define Device/netgear_wndr3800
   IMAGE/default := append-kernel | pad-to $$$$(BLOCKSIZE) | netgear-squashfs | append-rootfs | pad-rootfs
   IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | check-size $$$$(IMAGE_SIZE)
   IMAGE/factory.img := $$(IMAGE/default) | netgear-dni | check-size $$$$(IMAGE_SIZE)
-  DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport kmod-leds-reset
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport kmod-leds-reset kmod-owl-loader
   SUPPORTED_DEVICES += wndr3800
 endef
 TARGET_DEVICES += netgear_wndr3800

I included above your reset change, although it is a separate issue, I think.

Note that the patch above still has the same unadjusted MAC for eth0 and wlan0

@hnyman Does forwarding from lan to wan work for you?
It doesn't for me. This happened before on other devices and is probably unrelated.
The break firewall in trunk from time to time.

So I finished DIR-825, I can create a PR for 3800.

So the PR is there. Test and comment please.

You mean normal traffic to internet? Yes, it works normally, also from wifi.

Already writing feedback, as there are several errors.

See https://github.com/openwrt/openwrt/pull/1250#issuecomment-410848962

Hello all,

Let me first thank all who have been contributing to move ath79 support forward. Great work!
I've been following this thread with great interest as I own a WNDR300. I'm not familiar with DTS files but I have just a few (maybe dumb) questions regarding the WNDR300 support:

  • Is antenna setup needed or already implemented (see snippet from ar71xx mach file below)?
	/* 2.4 GHz uses the first fixed antenna group (1, 0, 1, 0) */
	ap9x_pci_setup_wmac_gpio(0, (0xf << 6), (0xa << 6));

	/* 5 GHz uses the second fixed antenna group (0, 1, 1, 0) */
	ap9x_pci_setup_wmac_gpio(1, (0xf << 6), (0x6 << 6));
  • What's the number 4 in the switch setup?
	rtl8366s {
        ...
			phy4: ethernet-phy@4 {
				reg = <4>;
				phy-mode = "rgmii";
			};
        ...

Glad to do some testing if needed.

It is the number of phy it is connected to.

In my case I can't get to the internet from lan. It pings OK from the device.

Forget the forwarding problem. It's not router related. I am forgetting things i set up.

Can you test wps buttons events? It looks like it is too sensitive. Maybe poll intervals should be updated.

It looks like poll-interval and debounce-interval are not applied at all.
It generates multiple events on press.