Porting guide ar71xx to ath79?

#22

ath79 target is now in master, but most of the boards still need to be ported.
See http://lists.infradead.org/pipermail/lede-dev/2018-May/012152.html

2 Likes

#23

That are great news :grinning:

0 Likes

#24

I would like to try the Tplink 1043nd v3 and v4, does anybody started to work on it ?

0 Likes

#25

so I tried to poke around and I got this

[    0.000000] Linux version 4.14.37 (build@build) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 r6854-4aacd6388a)) #0 Mon May 7 16:54:23 2018
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019750 (MIPS 74Kc)
[    0.000000] SoC: Qualcomm Atheros QCA9558 ver 1 rev 0
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] User-defined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] OF: fdt: No valid device tree found, continuing without
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] random: get_random_bytes called from start_kernel+0x8c/0x474 with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: console=ttyS0,115200 root=31:02 rootfstype=jffs2 init=/sbin/init mtdparts=ath-nor0:256k(u-boot),64k(u-boot-env),6336k(rootfs),1408k(uImage),64k(mib0),64k(ART) mem=64M rootfstype=squashfs,jffs2
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] Memory: 58424K/65536K available (3639K kernel code, 145K rwdata, 868K rodata, 1228K init, 212K bss, 7112K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 51
[    0.000000] Failed to get CPU node
[    0.000000] sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 21474836475000000ns

this is the DTS file

Summary
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;

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

#include "qca9557.dtsi"

/ {
	compatible = "tplink,tl-wr1043nd-v2", "qca,qca9557";
	model = "TP-Link TL-WR1043ND Version 2";

	memory@0 {
		device_type = "memory";
		reg = <0x0 0x8000000>;
	};

	extosc: ref {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-output-names = "ref";
		clock-frequency = <40000000>;
	};

	leds {
		compatible = "gpio-leds";

		system {
			label = "tp-link:green:system";
			gpios = <&gpio 19 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "heartbeat";
		};

		usb {
			label = "tp-link:green:usb";
			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		wifi_green {
			label = "tp-link:green:wlan";
			gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		wifi_wps {
			label = "tp-link:green:wps";
			gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
	};

	keys {
		compatible = "gpio-keys-polled";
		#address-cells = <1>;
		#size-cells = <0>;
		poll-interval = <100>;

		button@0 {
			label = "Reset button";
			linux,code = <KEY_RESTART>;
			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
			debounce-interval = <60>;
		};

		button@1 {
			label = "RFKILL button";
			linux,code = <KEY_RFKILL>;
			gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
			debounce-interval = <60>;
		};
	};
};

//&pcie0 {
//	status = "okay";
//};

&uart {
	status = "okay";
};

&pll {
	clocks = <&extosc>;
};

&spi {
	status = "okay";
	num-cs = <1>;

	flash@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "s25sl064a";
		reg = <0>;
		spi-max-frequency = <25000000>;

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

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

//			partition@1 {
//				label = "u-boot-env";
//				reg = <0x040000 0x010000>;
//			};

//			partition@2 {
//				label = "firmware";
//				reg = <0x850000 0x7a0000>;
//			};

//			partition@3 {
//				label = "ART";
//				reg = <0xff0000 0x010000>;
//				read-only;
//			};
		};
	};
};

&mdio0 {
	status = "okay";

	phy4: ethernet-phy@4 {
		reg = <4>;
		phy-mode = "rgmii-id";
	};
};

&mdio1 {
	status = "okay";

	phy1: ethernet-phy@1 {
		reg = <1>;
		phy-mode = "sgmii";
	};
};

&eth0 {
	status = "okay";

	phy-handle = <&phy4>;
	phy-mode = "rgmii";
};

&eth1 {
	status = "okay";

	phy-handle = <&phy1>;
	phy-mode = "sgmii";
};

If somebody has something to say I'm all ears :slight_smile:

0 Likes

#26

OF: fdt: No valid device tree found, continuing without
...
Failed to get CPU node

Are you sure your device tree was attached to the kernel image?

How looks your tplink.mk and how you named your dts?

I would suggest it should look like:

tplink.mk

define Device/tl_wr1043nd_v2
  $(Device/tplink-8mlzma)
  ATH_SOC := qca9558
  DEVICE_TITLE := TP-LINK TL-WR1043N/ND v2
  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport
  BOARDNAME := TL-WR1043ND-v2
  DEVICE_PROFILE := TLWR1043
  TPLINK_HWID := 0x10430002
endef
TARGET_DEVICES += tl_wr1043nd_v2

dts:
qca9558_tl_wr1043nd_v2.dts

0 Likes

#27

I tried to build an image for 1043nd v1, but I was unable to find it in the make menuconfig list.
Surely, I'm missing something, but what?

0 Likes

#28

Dont know why, but target is uncommented...
Look in tplink.mk

#TARGET_DEVICES += tl_wr1043nd_v1

Looks like tplink image building is not yet complete...

1 Like

#29

the DTS file is evaluated because I added usb_phy and errored because is not defined

define Device/tl-wr1043nd-v2
  $(Device/tplink-8mlzma)
  ATH_SOC := qca9558
  DEVICE_TITLE := TP-LINK TL-WR1043N/ND v2
  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport
  BOARDNAME := TL-WR1043ND-v2
  DEVICE_PROFILE := TLWR1043
  TPLINK_HWID := 0x10430002
endef
TARGET_DEVICES += tl-wr1043nd-v2

define Device/tl-wr1043nd-v3
  $(Device/tl-wr1043nd-v2)
  DEVICE_TITLE := TP-LINK TL-WR1043N/ND v3
  TPLINK_HWID := 0x10430003
endef
TARGET_DEVICES += tl-wr1043nd-v3

filenames
qca9558_tl-wr1043nd-v2.dts
qca9558_tl-wr1043nd-v3.dts

I think kernel image needs append-dtb i'll try that

0 Likes

#30

that was the key, now I'm at mtd detection

0 Likes

#31

there are minor changes needed to Makefile, also you need to include the legacy.mk in it otherwise the images will not be created
I'll make a PR or add the patch to the mailing list

0 Likes

#32

Great, i´d like to see it on git to dive into too...

0 Likes

#33

I'm stuck on this

Summary
[    0.000000] Linux version 4.14.37 (build@build) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 r6854-4aacd6388a)) #0 Mon May 7 16:54:23 2018
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019750 (MIPS 74Kc)
[    0.000000] MIPS: machine is TP-Link TL-WR1043ND Version 3
[    0.000000] SoC: Qualcomm Atheros QCA9558 ver 1 rev 0
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] User-defined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] random: get_random_bytes called from start_kernel+0x8c/0x474 with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: console=ttyS0,115200 root=31:02 rootfstype=jffs2 init=/sbin/init mtdparts=ath-nor0:256k(u-boot),64k(u-boot-env),6336k(rootfs),1408k(uImage),64k(mib0),64k(ART) mem=64M rootfstype=squashfs,jffs2
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] Memory: 58400K/65536K available (3639K kernel code, 145K rwdata, 868K rodata, 1228K init, 212K bss, 7136K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 51
[    0.000000] CPU clock: 720.000 MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 5309056796 ns
[    0.000008] sched_clock: 32 bits at 360MHz, resolution 2ns, wraps every 5965232126ns
[    0.008300] Calibrating delay loop... 358.80 BogoMIPS (lpj=1794048)
[    0.074992] pid_max: default: 32768 minimum: 301
[    0.080092] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.087128] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.097799] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.108304] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.114863] pinctrl core: initialized pinctrl subsystem
[    0.120858] NET: Registered protocol family 16
[    0.143211] clocksource: Switched to clocksource MIPS
[    0.149493] NET: Registered protocol family 2
[    0.154819] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.162248] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.169055] TCP: Hash tables configured (established 1024 bind 1024)
[    0.175954] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.182174] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.189123] NET: Registered protocol family 1
[    0.196894] Crashlog allocated RAM at address 0x3f00000
[    0.203732] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.214876] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.221076] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.238402] io scheduler noop registered
[    0.242572] io scheduler deadline registered (default)
[    0.249789] pinctrl-single 1804002c.pinmux: 512 pins at pa b804002c size 64
[    0.258095] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[    0.265515] console [ttyS0] disabled
[    0.269352] 18020000.uart: ttyS0 at MMIO 0x18020000 (irq = 8, base_baud = 2500000) is a 16550A
[    0.278571] console [ttyS0] enabled
[    0.278571] console [ttyS0] enabled
[    0.285989] bootconsole [early0] disabled
[    0.285989] bootconsole [early0] disabled
[    0.299205] m25p80 spi0.0: found gd25q64, expected m25p80
[    0.307103] m25p80 spi0.0: gd25q64 (8192 Kbytes)
[    0.311840] 6 fixed-partitions partitions found on MTD device spi0.0
[    0.318321] Creating 6 MTD partitions on "spi0.0":
[    0.323183] 0x000000000000-0x000000020000 : "u-boot"
[    0.328951] 0x000000020000-0x000000172e88 : "kernel"
[    0.334683] 0x000000172e88-0x0000007f0000 : "rootfs"
[    0.340337] mtd: device 2 (rootfs) set to be root filesystem
[    0.346180] mtdsplit: no squashfs found in "rootfs"
[    0.351140] 0x0000006f0000-0x0000007f0000 : "rootfs_data"
[    0.357325] 0x0000007f0000-0x000000800000 : "art"
[    0.362721] 0x000000020000-0x0000007f0000 : "firmware"
[    0.369356] libphy: Fixed MDIO Bus: probed
[    0.375238] ag71xx 19000000.eth: invalid MAC address, using random address
[    1.053548] libphy: mdio: probed
[    1.060300] switch0: Atheros AR8327 rev. 4 switch registered on mdio-bus.0
[    1.067493] ag71xx 19000000.eth: connected to PHY at mdio-bus.0:04 [uid=004dd034, driver=Atheros AR8216/AR8236/AR8316]
[    1.078916] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode:RGMII
[    1.085379] ag71xx 1a000000.eth: invalid MAC address, using random address
[    1.763548] libphy: mdio: probed
[    1.767778] ag71xx 1a000000.eth: connected to PHY at mdio-bus.1:01 [uid=00000000, driver=Generic PHY]
[    1.777716] eth1: Atheros AG71xx at 0xba000000, irq 5, mode:SGMII
[    1.785838] NET: Registered protocol family 10
[    1.794333] Segment Routing with IPv6
[    1.798149] NET: Registered protocol family 17
[    1.802696] 8021q: 802.1Q VLAN Support v1.8
[    1.810082] jffs2: Flash size not aligned to erasesize, reducing to 6592KiB
[    1.817494] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000000: 0x166c instead
[..]
[    1.913694] jffs2: Further such events for this erase block will not be printed

I think that patch-cmdline is not working either

I'll upload a bit later

0 Likes

#34

Is patch cmd line needed?
Though all would be defined in dts

0 Likes

#35

don't know exactly, but the cmdline is different than in 4.9, no sure it will fix the

[    0.340337] mtd: device 2 (rootfs) set to be root filesystem
[    0.346180] mtdsplit: no squashfs found in "rootfs"
0 Likes

#36

here:
https://github.com/openwrt/openwrt/pull/931

0 Likes

#37

You could define cmdline with choosen node...

Eg.:

chosen {
    bootargs = "console=ttyS0,115200";
};
0 Likes

#38

yes I was about to try that, thanks

0 Likes

#39

https://github.com/openwrt/openwrt/pull/931

so if somebody has an idea with the switch part, don't hesitate :slight_smile:

0 Likes

#40

I manage to get the QCA8337 working! :smiley:
I also wrote this in a comment of the pull request(https://github.com/openwrt/openwrt/pull/931#issuecomment-388234537)
However I want to share with you the magic of the offload and 4.14 kernel:

WITHOUT offload (option flow_offloading 0)

root@root:~# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.1.103, port 57241
[  5] local 192.168.1.201 port 5201 connected to 192.168.1.103 port 57242
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec  55.8 MBytes   468 Mbits/sec
[  5]   1.00-2.00   sec  57.1 MBytes   479 Mbits/sec
[  5]   2.00-3.00   sec  56.6 MBytes   475 Mbits/sec
[  5]   3.00-4.00   sec  61.2 MBytes   513 Mbits/sec
[  5]   4.00-5.00   sec  60.3 MBytes   506 Mbits/sec
[  5]   5.00-6.00   sec  61.4 MBytes   515 Mbits/sec
[  5]   6.00-7.00   sec  60.3 MBytes   506 Mbits/sec
[  5]   7.00-8.00   sec  61.0 MBytes   512 Mbits/sec
[  5]   8.00-9.00   sec  60.6 MBytes   508 Mbits/sec
[  5]   9.00-10.00  sec  61.1 MBytes   512 Mbits/sec
[  5]  10.00-10.03  sec  1.97 MBytes   510 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  5]   0.00-10.03  sec   597 MBytes   499 Mbits/sec    0             sender
[  5]   0.00-10.03  sec   597 MBytes   499 Mbits/sec                  receiver

WITH offload (option flow_offloading 1)

root@root:~# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.1.103, port 57270
[  5] local 192.168.1.201 port 5201 connected to 192.168.1.103 port 57271
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec   109 MBytes   911 Mbits/sec
[  5]   1.00-2.00   sec   111 MBytes   930 Mbits/sec
[  5]   2.00-3.00   sec   112 MBytes   939 Mbits/sec
[  5]   3.00-4.00   sec   111 MBytes   932 Mbits/sec
[  5]   4.00-5.00   sec   112 MBytes   940 Mbits/sec
[  5]   5.00-6.00   sec   110 MBytes   922 Mbits/sec
[  5]   6.00-7.00   sec   111 MBytes   929 Mbits/sec
[  5]   7.00-8.00   sec   111 MBytes   931 Mbits/sec
[  5]   8.00-9.00   sec   112 MBytes   940 Mbits/sec
[  5]   9.00-10.00  sec   111 MBytes   932 Mbits/sec
[  5]  10.00-10.03  sec  3.54 MBytes   940 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  5]   0.00-10.03  sec  1.09 GBytes   931 Mbits/sec    0             sender
[  5]   0.00-10.03  sec  1.09 GBytes   931 Mbits/sec                  receiver

I nearly doubled my bandwidth!!! :smiley: Thank you guys!

2 Likes

#41

Ethernet speeds could probably be improved by tweaking the Ethernet driver as well. Hacking on the driver is quite annoying though.

0 Likes