Porting guide ar71xx to ath79?

I made some progress after opening the PR for the CF-E375AC. I'm still seeing these messages on my bootlog indicating that something is wrong with the watchdog timer. Could this be something wrong with my wdt node at DTS?

The first boot after flash also has these messages about the filesystem marker found at 0x0

[ 32.951236] jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
[ 32.972862] jffs2_build_filesystem(): unlocking the mtd device...

From what I could poke around all the partitions seem to be working fine. But I'm not sure I should see the of the fs at 0x0.

Any help with any of these two topics would be much appreciated.

ar71xx has now been removed from OpenWrt master.

Hi @joaohcca, did you ever manage to resolve this? I'm struggling with the same problem on RB2011. Switch is detected, swconfig and dmesg shows plug/unplug events, the device even builds the ARP table of the devices on the network, but I can't connect to anything (ping doesn't work).

1 Like

Hi @danijeltudek , I've managed to fix it by making some changes to my dts. I don't recall exactly what it was the issue, but most likely something was wrong in mdio or phy nodes.

1 Like

Hi there,

This has everything to do with the pll-data in the dts.

So based on http://en.techinfodepot.shoutwiki.com/wiki/COMFAST_CF-E375AC the SoC is a QCA9563.

You should look on the board to find if it uses external PHYs or if the switch does the PHY modulation on its own.

You should check the logs of other ath79-ported devices with the same SoC to see if they used any different .pll-data values.

When porting the Meraki MR12 to ath79 I also encountered issues -- as have other developers:

TL;DR it comes down to poking pll-data (and referring also to the pll-data values in the .dtsi that your board's dts includes) so that they're set just right for the PHY to be OK.

Finally, you could also try reading through the mach.*.c files for the board when it was on ar71xx. Some C code used to be used to set up the pll just right.

Don't forget to come into the IRC if you're having any issues -- if you're patient someone will take a look if you can post code to Github. #openwrt-devel on Freenode.

1 Like

pll values are correct, I took them from the mach file. However, re-reading this thread: Porting the MikroTik SXT Lite5 (SXT 5nD r2) from ar71xx to ath79 and looking at ar934x.dtsi, I noticed that I still didn't try with phy-swap, and that ath79 defines only one gmac? RB2011 in ar71xx uses both gmac0 and gmac1...

2 Likes

Thanks for the reply, I've managed to get my ethernet ports working after some try and error using other boards as reference. I'll double-check the values with the links you sent.

I think I still need to do some work on the watchdog chip to finish the port, according to the ar71xx files it has an external chip for it but I don't know how to set it up correctly on the dts.

Hey guys!

Trying my hand at porting the Netgear WNR2000 v1 from ar71xx to ath79. According to the wiki it has an AR8216 switch. The switch is at eth0 and the WAN is eth1 on ar71xx. eth0 is coming up on ath79 but eth1 doesn't.

ar71xx boot log is showing this:

[ 0.936016] libphy: Fixed MDIO Bus: probed
[ 0.962890] libphy: ag71xx_mdio: probed
[ 1.302310] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode: rmii
[ 1.641720] ag71xx ag71xx.1: connected to PHY at ag71xx-mdio.0:04 [uid=004dd042, driver=Generic PHY]
[ 1.651800] eth1: Atheros AG71xx at 0xba000000, irq 5, mode: rmii

ath79 boot log:

[    0.883985] libphy: Fixed MDIO Bus: probed
[    1.231012] ag71xx 19000000.eth: connected to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]
[    1.240952] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode: rmii

My DTS so far:

WNR2000 v1 DTS
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "ar9132.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/mtd/partitions/uimage.h>

/ {
	compatible = "netgear,wnr2000-v1", "qca,ar9132";
	model = "Netgear WNR2000 v1";

	chosen {
		bootargs = "console=ttyS0,115200n8";
	};

	aliases {
		led-boot = &led_power_amber;
		led-failsafe = &led_power_amber;
		led-running = &led_power_green;
		led-upgrade = &led_power_amber;
		label-mac-device = &eth0;
	};

	keys {
		compatible = "gpio-keys";
		poll-interval = <20>;

		reset {
			label = "reset";
			linux,code = <KEY_RESTART>;
			gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
			debounce-interval = <60>;
		};

		wps {
			label = "wps";
			linux,code = <KEY_WPS_BUTTON>;
			gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
			debounce-interval = <60>;
		};
	};

	leds {
		compatible = "gpio-leds";

		// Onduidelijk of onderstaande code nodig is.
		// pinctrl-names = "default";
		// pinctrl-0 = <&jtag_disable_pins &switch_led_disable_pins &clks_disable_pins>;

		led_power_green: power_green {
			label = "green:power";
			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
		};

		led_power_amber: power_amber {
			label = "amber:power";
			gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
		};

		wlan {
			label = "blue:wlan";
			gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
		};

		wps {
			label = "green:wps";
			gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
		};
	};
};

&spi {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <25000000>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "u-boot";
				reg = <0x0 0x40000>;
				read-only;
			};

			partition@40000 {
				label = "u-boot-env";
				reg = <0x40000 0x10000>;
			};

			partition@50000 {
				label = "firmware";
				reg = <0x50000 0x3a0000>;
				compatible = "openwrt,uimage", "denx,uimage";
				openwrt,ih-magic = <0x32303031>;
				openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
			};

			art: partition@3f0000 {
				label = "art";
				reg = <0x3f0000 0x10000>;
				read-only;
			};
		};
	};
};

&eth0 {
	status = "okay";

	phy-mode = "rmii";
	mtd-mac-address = <&art 0x1000>;

	fixed-link {
		speed = <100>;
		full-duplex;
	};
};

&eth1 {
	status = "okay";

	phy-mode = "rmii";
	mtd-mac-address = <&art 0x1006>;
};

&wmac {
       status = "okay";

       mtd-cal-data = <&art 0x1000>;
       mtd-mac-address = <&art 0x0>;
       //mtd-mac-address-increment = <1>;
};

&uart {
	status = "okay";
};

The ar71xx mach file looks straightforward enough but I'm not seeing it...

Thanks!

you may need to parse that dts include chain through ar9132.dtsi down to ath79.dtsi

ath79.dtsi defines both eth0 and eth1, but then ar9132.dtsi makes additional settings only to eth0.

Note that none of the other three ar9132 devices defines eth1 in their device .dts. They all only mention eth0. Any idea, why?

EDIT:
And if you look at the ar71xx network edeafults in 19.07, those devices only set eth0, I think:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ar71xx/base-files/etc/board.d/02_network;h=44fce970c0fd8b4811242fac0b53764a09244a2f;hb=refs/heads/openwrt-19.07

I have a PR based on ar9132.dtsi pending and there the eth1 is set. Maybe it will give you some ideas. Never mind it being "disabled" as that file is a DTSI too and the DTS turns in "okay" later on.

I have no idea how those existing tp-link devices work. From what it looks like mdio0 and mdio1 nodes are left "disabled" too. Maybe they don't need managing. And compatible values for eth0 and eth1 seem to be different at the end of the day.

Thanks, that would be PR 3062 right?

I am going to test with this:

&eth1 {
	status = "okay";

	compatible = "qca,ar9130-eth", "syscon";
	reg = <0x1a000000 0x200
		0x18070004 0x4>;

	phy-mode = "rmii";
	reset-names = "mac";
	qca,mac-idx = <1>;
	mtd-mac-address-increment = <1>;
};

What line are you referring to? Since I'm seeing this as catch-all in ar71xx_setup_interfaces():

ucidef_set_interfaces_lan_wan "eth0" "eth1"

I have no idea why the few AR9132 devices present only set eth0. The TL-WA901ND is a single-port AP e.g., so that's easy.

Yes, let's race who gets their PR approved first. :slight_smile:

Haha I'm not that ambitious :wink: . Thanks for your help and good luck!

Mine has been open since June or something, so I am not holding my breath any more. :slightly_smiling_face: It's been a bit dynamic too, I'll have to say that.

If that does not play nicely try adding the PLL. The interface might need a clock signal too.

1 Like

I naturally mean the lines for the three 9132 devices that have DTS files in ath79:

  • ar9132_tplink_tl-wa901nd-v2.dts
 141         tl-wa901nd|\
 142         tl-wa901nd-v2|\
 143         tl-wa901nd-v3|\
 144         tl-wa901nd-v4|\
 145         tl-wa901nd-v5|\
 146         tl-wr703n|\
 147         tl-wr802n-v1|\
 148         tl-wr802n-v2|\
 149         tl-wr902ac-v1|\
 150         ts-d084|\
 151         tube2h|\
 152         unifi|\
 153         unifiac-lite|\
 154         wi2a-ac200i|\
 155         wifi-pineapple-nano|\
 156         wndap360|\
 157         wp543)
 158                 ucidef_set_interface_lan "eth0"
 159                 ;;
  • ar9132_tplink_tl-wr1043nd-v1.dts
 516         tl-wr1043nd)
 517                 ucidef_add_switch "switch0" \
 518                         "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"

ar9132_tplink_tl-wr941-v2.dts

 324         rb-941-2nd)
 325                 ucidef_add_switch "switch0" \
 326                         "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:wan:1"

All those define only eth0 in the ar71xx network config.

OK, thanks. The ar71xx build for the WNR2000 v1 has both eth0 and eth1, so it must be set up in some way, no? The mach file refers to it as well. The WNR2000 has no match in /etc/board.d/02_network and that makes it revert to default settings, which is ucidef_set_interfaces_lan_wan "eth0" "eth1".

You should make sure your patches are refreshed on top of current master branch.

OK, so I got a bit further! Log is now looking a lot more similar to what it was in ar71xx, but the UID is 00000000 for both PHYs, where it was 004dd042. It was explained to me that this value is kind of similar to a PCI ID, and refers to a specific kind of switch. Is there a way to get that UID 'back'? I am not finding any references to the AR8216 switch in other DTSes currently in OpenWrt. Some Lantiq devices seem to use AR8216 switches but I am not finding anything particular there either. Grepping the tree for ar8216 doesn't give me anything DTS-wise...

ar71xx

[ 0.936016] libphy: Fixed MDIO Bus: probed
[ 0.962890] libphy: ag71xx_mdio: probed
[ 1.302310] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode: rmii
[ 1.641720] ag71xx ag71xx.1: connected to PHY at ag71xx-mdio.0:04 [uid=004dd042, driver=Generic PHY]
[ 1.651800] eth1: Atheros AG71xx at 0xba000000, irq 5, mode: rmii

ath79

[    0.884446] libphy: Fixed MDIO Bus: probed
[    1.231143] ag71xx 19000000.eth: connected to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]
[    1.241088] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode: rmii
[    1.564046] libphy: ag71xx_mdio: probed
[    1.592392] ag71xx 1a000000.eth: connected to PHY at mdio.0:04 [uid=00000000, driver=Generic PHY]
[    1.602332] eth1: Atheros AG71xx at 0xba000000, irq 5, mode: rmii

DTS looks like this now:


&eth0 {
	status = "okay";

	phy-mode = "rmii";
	mtd-mac-address = <&art 0x1000>;

	fixed-link {
		speed = <100>;
		full-duplex;
	};
};

&eth1 {
	status = "okay";

	compatible = "qca,ar9130-eth", "syscon";
	reg = <0x1a000000 0x200
		0x18070004 0x4>;

	phy-mode = "rmii";
	phy-handle = <&phy4>;
	resets = <&rst 13>;
	reset-names = "mac";
	qca,mac-idx = <1>;
	mtd-mac-address = <&art 0x1006>;
};

&mdio1 {
	status = "okay";

	phy4: ethernet-phy@4{
		reg = <4>;
	};
};

@hnyman I'm in way over my head, I'm just a bit puzzled as to why on ath79 one would end up with just one ethX interface whereas there were two on ar71xx. Unless ar71xx was misconfigured from the start, of course, but then you'd wonder why it would work...

By choice of implementation I guess. My WNDR4300 has only eth0.

root@WNDR4300:~# ip li
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:85 brd ff:ff:ff:ff:ff:ff
5: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:d1 brd ff:ff:ff:ff:ff:ff
6: eth0.1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:d1 brd ff:ff:ff:ff:ff:ff
7: eth0.2@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:d2 brd ff:ff:ff:ff:ff:ff
8: wlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:d3 brd ff:ff:ff:ff:ff:ff
9: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:d1 brd ff:ff:ff:ff:ff:ff
root@WNDR4300:~# 

For clarity: ppmm is the owner of said WNR2000 v1.