Add support for MikroTik RB5009UG

Great!!! Should this be patch 3 then after following patch 1 and 2 applied to HEAD as mentioned on the RB5009 openwrt wiki ? So in that order?

Yes that patch goes on top of the other patches for master. I will link an updated master patch set for 5.15 on the wiki in the days to come, so it's included.

Edit: oh well, let's get it over with. Link has been updated.

2 Likes

Now that master is exclusively on 5.15, the original 5.10 patch set has been removed from the wiki. There's a single patch set now, for kernel 5.15.

It is a pity that Mikrotik used such a non-standard solution. I hope that their solution was not intended to be malicious that Mikrotik's website towards OpenWRT. I hope we can find some solution to include the rb5009 in the OpenWRT mainline.

Oh the malicious intent is clearly there. It's a pattern with MikroTik.

2 Likes

I wonder what benefit Mikrotik has from making it harder to run OpenWRT.

Hi! Bit quiet over here. Any news / developments on the RB5009 <> openwrt combo ?

It seems like the patch linked on the wiki no longer applies against master, or either of the v23.05 rc tags.

It could be something I'm doing wrong.

I'm running:
git am --ignore-space-change --ignore-whitespace ../master.patch

I'm getting the following errors:

error: patch failed: target/linux/generic/backport-5.15/766-v5.16-net-phy-at803x-use-phy_modify.patch:13
error: target/linux/generic/backport-5.15/766-v5.16-net-phy-at803x-use-phy_modify.patch: patch does not apply
error: patch failed: target/linux/generic/backport-5.15/775-v5.16-net-phy-add-qca8081-config_init.patch:71
error: target/linux/generic/backport-5.15/775-v5.16-net-phy-add-qca8081-config_init.patch: patch does not apply
error: patch failed: target/linux/generic/backport-5.15/776-v5.16-net-phy-add-qca8081-soft_reset-and-enable-master-sla.patch:32
error: target/linux/generic/backport-5.15/776-v5.16-net-phy-add-qca8081-soft_reset-and-enable-master-sla.patch: patch does not apply
error: patch failed: target/linux/mvebu/patches-5.15/706-net-dsa-mv88e6xxx-add-Amethyst-specific-SMI-GPIO-fun.patch:51
error: target/linux/mvebu/patches-5.15/706-net-dsa-mv88e6xxx-add-Amethyst-specific-SMI-GPIO-fun.patch: patch does not apply
Patch failed at 0017 kernel: refresh RB5009UG patches

Looks like you are. Today's master main branch:

$ wget https://0paste.com/461058.txt
--2023-08-18 13:18:30--  https://0paste.com/461058.txt
Resolving 0paste.com (0paste.com)... 172.104.83.182, 2400:8902:e002:47ff::
Connecting to 0paste.com (0paste.com)|172.104.83.182|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 163538 (160K) [text/plain]
Saving to: '461058.txt'

461058.txt                                  100%[=========================================================================================>] 159.71K   150KB/s    in 1.1s    

2023-08-18 13:18:32 (150 KB/s) - '461058.txt' saved [163538/163538]

$ ./scripts/getver.sh 
r23766-5356462ce5
$ git am 461058.txt
Applying: generic: fix mikrotik/rb_softconfig work(crc mismatch) with 64K block size
Applying: mvebu: add aux-loader2 support
.git/rebase-apply/patch:24: space before tab in indent.
 	cat "bin/aux-loader.elf" "$@" > "$@.tmp" &&	\
.git/rebase-apply/patch:25: space before tab in indent.
 	cat "$@.tmp" > "$@" && rm -f "$@.tmp"
.git/rebase-apply/patch:189: space before tab in indent.
  	append-rootfs | pad-rootfs | check-size | append-metadata
warning: 3 lines add whitespace errors.
Applying: mvebu: mvebu: add support for RB5009UG+S+IN.
Applying: mvebu: RB5009: start to use UBI
Applying: mvebu: RB5009: update aux-loader.elf
Applying: mvebu: RB5009: remove sfp port from wan bridge
Applying: mvebu: rb5009: add SFP GPIO pins
Applying: mvebu: rb5009: use QCA8081 label for 2.5 GbE port in DTS
Applying: mvebu: cortexa72: add missing symbol
Applying: mvebu: cortexa72: enable SBSA Watchdog, Mikrotik RB Sysfs and MTD_SPLIT_FIT_FW
Applying: mvebu: cortexa72: schedutil as default scheduler
Applying: mvebu: add Amethyst specific SMI setup
.git/rebase-apply/patch:41: trailing whitespace.
 
.git/rebase-apply/patch:42: space before tab in indent.
 	if (external) {
.git/rebase-apply/patch:43: space before tab in indent.
 		mv88e6xxx_reg_lock(chip);
.git/rebase-apply/patch:49: space before tab in indent.
 		mv88e6xxx_reg_unlock(chip);
.git/rebase-apply/patch:50: trailing whitespace.
 
warning: squelched 8 whitespace errors
warning: 13 lines add whitespace errors.
Applying: kernel: 5.15: backport QCA8081 PHY support
.git/rebase-apply/patch:65: trailing whitespace.
 
.git/rebase-apply/patch:71: space before tab in indent.
 	const u8 *mac;
.git/rebase-apply/patch:72: space before tab in indent.
 	int ret;
.git/rebase-apply/patch:73: space before tab in indent.
 	u32 value;
.git/rebase-apply/patch:77: space before tab in indent.
 		AT803X_LOC_MAC_ADDR_32_47_OFFSET,
warning: squelched 243 whitespace errors
warning: 248 lines add whitespace errors.
Applying: mvebu: rb5009: add QCA8081 PHY support for 5.15
Applying: generic: 5.15: adapt AT803x fiber support patch after e1242fc3390
.git/rebase-apply/patch:111: space before tab in indent.
 	int err, old_link = phydev->link;
.git/rebase-apply/patch:139: space before tab in indent.
 	/* Do not restart auto-negotiation by setting ret to 0 defautly,
.git/rebase-apply/patch:140: space before tab in indent.
 	 * when calling __genphy_config_aneg later.
.git/rebase-apply/patch:141: space before tab in indent.
 	 */
.git/rebase-apply/patch:164: space before tab in indent.
 	/* Qualcomm Atheros QCA9561 */
warning: squelched 11 whitespace errors
warning: 16 lines add whitespace errors.
Applying: kernel: replace QCA8081 2.5Gb patch with upstream one
.git/rebase-apply/patch:41: space before tab in indent.
 	if (ret < 0)
.git/rebase-apply/patch:42: space before tab in indent.
 		return ret;
.git/rebase-apply/patch:43: trailing whitespace.
 
.git/rebase-apply/patch:70: space before tab in indent.
 		if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) {
.git/rebase-apply/patch:71: space before tab in indent.
 			qca808x_phy_ms_seed_enable(phydev, false);
warning: squelched 1 whitespace error
warning: 6 lines add whitespace errors.
Applying: kernel: refresh RB5009UG patches
.git/rebase-apply/patch:221: space before tab in indent.
 	.phy_id_mask		= QCA8K_PHY_ID_MASK,
warning: 1 line adds whitespace errors.

No issues on 23.05 HEAD either btw.

:person_facepalming: Must have been a problem with my original download of the patch. I got it applied now.

However, it does look like one of the commits today has actually broken the patch.

When I roll back to the commit before that one on the main branch the patch applies fine, if I'm on that commit or newer it does not.

I was also able to apply it to the current 23.05 HEAD.

Thanks.

I'll look into it, the at803x driver is indeed heavily patched for the RB5009UG. Lots of things on my plate now though, so don't expect it to be soon.

The 5.15 bump will at some point hit 23.05 as well, I would recommend to roll it back until the patch set has been updated.

How to turn off the led?
It is possible ?

I tried to flash my brand new rb5009 but openwrt not booting. It always loops in flash mode.

Hi. The RB5009 (RB5009UG+S+IN) flash proces that should work, it did for me a couple of times, is on @adron 's GitHub: https://github.com/adron-s/openwrt-rb5009. Did you use it ?

Patch set for 23.05 / master has been updated following the 5.15.127 bump.

I'll look into 6.1 when I got the time, lot of patches that can be dropped with it.

4 Likes

Yes, I used it. but nothing happened after the sysupgrade success. Boot loop only after reboot

Asking for a friend :slight_smile: found some time for the 6.1 patch ?

1 Like

I was on holidays.

A patch set for 6.1 can be found on the wiki now.

Please note you cannot mix the 5.15 and 6.1 patch sets, it's one or the other.

It looks like the QCA8081 isn't fully functional however. I see this in dmesg:

[    1.888044] mv88e6085 f212a200.mdio-mii:00: OF node /cp0/config-space@f2000000/mdio@12a200/switch@0/ports/port@0 of CPU port 0 lacks the required "phy-mode" property
[    1.902937] mv88e6085 f212a200.mdio-mii:00: OF node /cp0/config-space@f2000000/mdio@12a200/switch@0/ports/port@0 of CPU port 0 lacks the required "phy-handle", "fixed-link" or "managed" properties
[    1.920515] mv88e6085 f212a200.mdio-mii:00: Skipping phylink registration for CPU port 0
[    2.026930] mv88e6085 f212a200.mdio-mii:00 p8 (uninitialized): PHY [!cp0!config-space@f2000000!mdio@12a200!switch@0!mdio:01] driver [Marvell 88E6393 Family] (irq=53)
[    2.042741] mvpp2 f2000000.ethernet: all ports have a low MTU, switching to per-cpu buffers
[    2.084429] mvpp2 f2000000.ethernet: using 8 per-cpu buffers
[    2.186864] mv88e6085 f212a200.mdio-mii:00 p7 (uninitialized): PHY [!cp0!config-space@f2000000!mdio@12a200!switch@0!mdio:02] driver [Marvell 88E6393 Family] (irq=54)
[    2.286853] mv88e6085 f212a200.mdio-mii:00 p6 (uninitialized): PHY [!cp0!config-space@f2000000!mdio@12a200!switch@0!mdio:03] driver [Marvell 88E6393 Family] (irq=55)
[    2.376878] mv88e6085 f212a200.mdio-mii:00 p5 (uninitialized): PHY [!cp0!config-space@f2000000!mdio@12a200!switch@0!mdio:04] driver [Marvell 88E6393 Family] (irq=56)
[    2.477015] mv88e6085 f212a200.mdio-mii:00 p4 (uninitialized): PHY [!cp0!config-space@f2000000!mdio@12a200!switch@0!mdio:05] driver [Marvell 88E6393 Family] (irq=57)
[    2.577104] mv88e6085 f212a200.mdio-mii:00 p3 (uninitialized): PHY [!cp0!config-space@f2000000!mdio@12a200!switch@0!mdio:06] driver [Marvell 88E6393 Family] (irq=58)
[    2.666942] mv88e6085 f212a200.mdio-mii:00 p2 (uninitialized): PHY [!cp0!config-space@f2000000!mdio@12a200!switch@0!mdio:07] driver [Marvell 88E6393 Family] (irq=59)
[    2.787943] mv88e6085 f212a200.mdio-mii:00 p1 (uninitialized): PHY [!cp0!config-space@f2000000!mdio@12a200!switch@0!mdio1:00] driver [Qualcomm QCA8081] (irq=POLL)

@robimarko From what I could tell only your Amethyst modifications are still needed for 6.1, QCA8081 should be fully supported by now? Any idea how I can fix the OF node warnings? And does the irq=POLL for the QCA8081 suggest anything further needs to be

DTS was copied as-is from 5.15.

Thanks

Edit: the irq=POLL statement is exactly the same on 5.15, so that's not an issue here.

4 Likes

QCA8081 should just work.

Can you post the whole final DTS, the CPU port is lacking something

2 Likes

Sure:

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

/dts-v1/;

#include "armada-7040.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
	model = "MikroTik RB5009";
	compatible = "mikrotik,rb5009", "marvell,armada7040",
		     "marvell,armada-ap806-quad", "marvell,armada-ap806";

	chosen {
		stdout-path = "serial0:115200n8";
	};

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

	aliases {
		led-boot = &led_user;
		led-failsafe = &led_user;
		led-running = &led_user;
		led-upgrade = &led_user;
	};

	sfp_i2c: sfp-i2c {
		compatible = "i2c-gpio";
		sda-gpios = <&cp0_gpio1 0 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&cp0_gpio1 1 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
	};

	keys {
		compatible = "gpio-keys";

		reset {
			label = "reset";
			gpios = <&cp0_gpio1 28 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led_user: user {
			label = "green:user";
			gpios = <&cp0_gpio2 26 GPIO_ACTIVE_LOW>;
		};

		sfp {
			label = "green:sfp";
			gpios = <&cp0_gpio2 25 GPIO_ACTIVE_LOW>;
		};

		hdr1 {
			label = "blue:hdr1";
			gpios = <&cp0_gpio1 4 GPIO_ACTIVE_LOW>;
		};

		hdr2 {
			label = "blue:hdr2";
			gpios = <&cp0_gpio2 19 GPIO_ACTIVE_LOW>;
		};
	};

	sfp: sfp {
		compatible = "sff,sfp";
		i2c-bus = <&sfp_i2c>;
		mod-def0-gpios = <&cp0_gpio1 11 GPIO_ACTIVE_LOW>;
		los-gpios = <&cp0_gpio1 2 GPIO_ACTIVE_HIGH>;
		tx-fault-gpios = <&cp0_gpio1 6 GPIO_ACTIVE_HIGH>;
		tx-disable-gpios = <&cp0_gpio1 5 GPIO_ACTIVE_HIGH>;
		rate-select0-gpios = <&cp0_gpio1 3 GPIO_ACTIVE_HIGH>;
	};
};

&uart0 {
	status = "okay";

	pinctrl-0 = <&uart0_pins>;
	pinctrl-names = "default";
};


&spi0 {
	status = "okay";

	spi-flash@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <20000000>;

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

			partition@0 {
				label = "ATF";
				reg = <0x0 0x95c04>;
				read-only;
			};
			partition@1 {
				label = "backup_RouterBOOT";
				reg = <0x95c04 0x193FC>;
				read-only;
			};
			hard_config: partition@2 {
				label = "hard_config";
				reg = <0xaf000 0x1000>;
				read-only;
			};
			partition@3 {
				label = "RouterBOOT";
				reg = <0xb0000 0x10000>;
			};
			partition@4 {
				label = "soft_config";
				reg = <0xc0000 0x10000>;
			};
			partition@5 {
				label = "DTS";
				reg = <0xd0000 0x10000>;
				read-only;
			};
			partition@6 {
				label = "free_space";
				reg = <0xe0000 0x20000>;
			};
			partition@7 {
				label = "kernel";
				reg = <0x100000 0xf00000>;
			};
			partition@8 {
				label = "first_1M";
				reg = <0x0 0x100000>;
			};
		};
	};
};

&cp0_nand_controller {
	status = "okay";

	nand@0 {
		reg = <0>;
		nand-rb = <0>;
		nand-ecc-mode = "hw";
		nand-ecc-strength = <4>;
		nand-ecc-step-size = <512>;
		nand-on-flash-bbt;

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

			partition@0 {
				label = "ubi";
				reg = <0x0 0x40000000>;
			};
		};
	};
};

&cp0_gpio2 {
	enable-usb-power {
		gpio-hog;
		gpios = <23 GPIO_ACTIVE_HIGH>;
		output-high;
		line-name = "enable USB power";
	};

	enable-leds-power {
		gpio-hog;
		gpios = <27 GPIO_ACTIVE_HIGH>;
		output-high;
		line-name = "enable LED-s power";
	};
};

&cp0_usb3_1 {
	status = "okay";
};

&cp0_i2c0 {
	status = "okay";
	clock-frequency = <100000>;
};

&cp0_mdio {
	status = "okay";
};

&cp0_ethernet {
	status = "okay";
};

&cp0_eth0 {
	/* This port is connected to 88E6393X switch */
	status = "okay";
	phy-mode = "10gbase-r";
	managed = "in-band-status";
	nvmem-cells = <&macaddr_hard>;
	nvmem-cell-names = "mac-address";
	mac-address-increment = <0>;
};

&cp0_mdio {
	status = "okay";

	switch@0 {
		/* Actual device is MV88E6393X */
		compatible = "marvell,mv88e6190";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0>;
		//strict-cpu-mode = <1>;
		//reset-gpios = <&cp0_gpio2 2 GPIO_ACTIVE_HIGH>;

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;
				label = "cpu";
				ethernet = <&cp0_eth0>;
			};

			port@1 {
				reg = <1>;
				label = "p8";
				phy-handle = <&switch0phy1>;
				nvmem-cells = <&macaddr_hard>;
				nvmem-cell-names = "mac-address";
				mac-address-increment = <7>;
			};

			port@2 {
				reg = <2>;
				label = "p7";
				phy-handle = <&switch0phy2>;
				nvmem-cells = <&macaddr_hard>;
				nvmem-cell-names = "mac-address";
				mac-address-increment = <6>;
			};

			port@3 {
				reg = <3>;
				label = "p6";
				phy-handle = <&switch0phy3>;
				nvmem-cells = <&macaddr_hard>;
				nvmem-cell-names = "mac-address";
				mac-address-increment = <5>;
			};

			port@4 {
				reg = <4>;
				label = "p5";
				phy-handle = <&switch0phy4>;
				nvmem-cells = <&macaddr_hard>;
				nvmem-cell-names = "mac-address";
				mac-address-increment = <4>;
			};

			port@5 {
				reg = <5>;
				label = "p4";
				phy-handle = <&switch0phy5>;
				nvmem-cells = <&macaddr_hard>;
				nvmem-cell-names = "mac-address";
				mac-address-increment = <3>;
			};

			port@6 {
				reg = <6>;
				label = "p3";
				phy-handle = <&switch0phy6>;
				nvmem-cells = <&macaddr_hard>;
				nvmem-cell-names = "mac-address";
				mac-address-increment = <2>;
			};

			port@7 {
				reg = <7>;
				label = "p2";
				phy-handle = <&switch0phy7>;
				nvmem-cells = <&macaddr_hard>;
				nvmem-cell-names = "mac-address";
				mac-address-increment = <1>;
			};

			port@9 {
				reg = <9>;
				label = "p1";
				phy-mode = "sgmii";
				phy-handle = <&qca8081>;
				managed = "in-band-status";
				nvmem-cells = <&macaddr_hard>;
				nvmem-cell-names = "mac-address";
				mac-address-increment = <0>;
			};

			port@a {
				reg = <10>;
				label = "sfp";
				phy-mode = "10gbase-r";
				managed = "in-band-status";
				sfp = <&sfp>;
				nvmem-cells = <&macaddr_hard>;
				nvmem-cell-names = "mac-address";
				mac-address-increment = <8>;
			};
		};

		mdio {
			#address-cells = <1>;
			#size-cells = <0>;

			switch0phy1: switch0phy1@1 {
				reg = <0x1>;
			};

			switch0phy2: switch0phy2@2 {
				reg = <0x2>;
			};

			switch0phy3: switch0phy3@3 {
				reg = <0x3>;
			};

			switch0phy4: switch0phy4@4 {
				reg = <0x4>;
			};

			switch0phy5: switch0phy5@5 {
				reg = <0x5>;
			};

			switch0phy6: switch0phy6@6 {
				reg = <0x6>;
			};

			switch0phy7: switch0phy7@7 {
				reg = <0x7>;
			};
		};

		mdio1 {
			compatible = "marvell,mv88e6xxx-mdio-external";
			#address-cells = <1>;
			#size-cells = <0>;

			qca8081: qca8081@0 {
				reg = <0>;
			};
		};
	};
};

&hard_config {
	compatible = "nvmem-cells";
	#address-cells = <1>;
	#size-cells = <1>;

	macaddr_hard: macaddr@10 {
		reg = <0x10 0x6>;
	};
};
1 Like