Support for Mikrotik RB3011UiAS-RM?

It is very nice that you continued my work. Unfortunately, I am still very busy with other work, and still won’t return to work on RB3011. Here is my dts file for RB3011. It is based on a file from Natgear and requires some cleanup. But the ethernet switch completely worked. And even with sfp.

Hope this helps you in your work.

Very well, thanks. Let me sync this with my stuff later today. I haven't really tried the SFP yet even though for me that was the whole reason I even choose the RB3011 :smile:.

Well, well. Finally, at least some network bootable preview [1] and the sources [2]. This is in no way cleaned-up or anything but the following works for me:

  • Regular network boot with [1].
  • SFP: fixed link via eth1 doing dhcp, proper sfp integration (e.g. ethtool -m eth1) still fails for me but during boot SFP PHY does get properly detected by I2C.
  • Switch0: fixed link via eth0 serving eth1-eth5 working with default 192.168.1.1 incl. luci.
  • Switch1: eth6-eth10 detects stuff plugged in but so far traffic via eth3 still fails (e.g. probably still similar issue as @adron faced).

What does not work so far:

  • Traffic via eth2 or eth3.
  • USB but I also did not really explore that one much.
  • I experimented with DSA setup but so far while switch0 management worked I could not get any traffic flowing but I admit I'm also relatively new to that whole topic.

Untested:

  • Flash installation.

My next steps are gonna be cleaning it up into separate commits to be submittable upstream.

I would love to be able to experiment some more with linux-next but so far I failed getting any such booted with adron's qcom-ipq-aux-loader. Any suggestions welcome.

And, of course, any feedback concerning any of this is welcome.

Enjoy...

[1] https://www.ziswiler.net/owncloud/index.php/s/ReI0emenqAyhlwv
[2] https://github.com/ziswiler/openwrt/tree/rb3011uias

1 Like

Very cool to see some more action on this - I've been working on RB3011 support myself and posted a few patches to linux-arm-msm this week to enable initial support. I've had working support with the second bank of 5 ports - gmac3 is attached via sgmii to port0 on switch2, and I needed to kick QCA8K_REG_SGMII_CTRL there in order to get the ports working (with the upstream qca8k driver, which isn't as useful as the OpenWRT switch driver, presenting ports only as extra ethernet interfaces).

Very, good. Yeah, last I checked there was nothing there but I wasn't monitoring linux-arm-msm too closely. I actually experimented with a DSA setup myself but retreated to OpenWrt's swconfig approach for now just to get something out which is actually working. Doing mainline gmac/qca8k experiments was actually the next step I intended to do. For now, I tried the approach from @adron which boiled down to a patch here [1]. Could you share how/what exactly you did to the qca8k stuff as that may just be the missing link in the DSA experiments I did so far. As I am rather new to the DSA stuff I also ordered one of them latest WRT32X devices to have some reference hardware. Looking forward to get RB3011 OpenWrt support ironed out.

[1] https://github.com/ziswiler/openwrt/commit/fa418ecd8f34008726f75a9e6cf31c1731a0f647

My upstream patches are at

https://lore.kernel.org/linux-arm-msm/cover.1589824955.git.noodles@earth.li/T/#t

(pretty much the same as yours but varied for mainline)

and I'm using

https://the.earth.li/~noodles/rb3011-mainline.diff

on top of that to get something that boots to the initrd and has both
switches working. Using @adron's qcom-ipq-aux-loader generally, but also
his u-boot sometimes because it makes it easier to poke things (but then
does some of the hardware init so I have to go back to the loader to
make sure that still works).

Have you had any success with the USB? I haven't managed to convince it
to be happy.

I got the second switch working with your tree, @sumo. Just had to switch to port 0 / SGMII for gmac3:

diff --git a/target/linux/ipq806x/base-files/etc/board.d/02_network b/target/linux/ipq806x/base-files/etc/board.d/02_network
index 1d5d6eaf61..4d79bcbb9d 100755
--- a/target/linux/ipq806x/base-files/etc/board.d/02_network
+++ b/target/linux/ipq806x/base-files/etc/board.d/02_network
@@ -39,7 +39,7 @@ mikrotik,rb3011uias)
        ucidef_add_switch "switch0" \
                "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth2"
        ucidef_add_switch "switch1" \
-               "1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth3"
+               "0@eth3" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
        ;;
 nec,wg2600hp)
        ucidef_add_switch "switch0" \
diff --git a/target/linux/ipq806x/files-5.4/arch/arm/boot/dts/qcom-ipq8064-rb3011uias.dts b/target/linux/ipq806x/files-5.4/arch/arm/boot/dts/qcom-ipq8064-rb3011uias.dts
index dfd5d2238b..9906295c1b 100644
--- a/target/linux/ipq806x/files-5.4/arch/arm/boot/dts/qcom-ipq8064-rb3011uias.dts
+++ b/target/linux/ipq806x/files-5.4/arch/arm/boot/dts/qcom-ipq8064-rb3011uias.dts
@@ -653,9 +653,10 @@
                ethernet-phy@0 {
                        reg = <0>;
                        qca,ar8327-initvals = <
-                               0x00004 0x7600000   /* PAD0_MODE */
+                               0x00004 0x0000080   /* PAD0_MODE */
                                0x00008 0x1000000   /* PAD5_MODE */
                                0x0000c 0x80        /* PAD6_MODE */
+                               0x00010 0x2613A0    /* SERDES DISABLE */
                                0x000e4 0xaa545     /* MAC_POWER_SEL */
                                0x000e0 0xc74164de  /* SGMII_CTRL */
                                0x0007c 0x4e        /* PORT0_STATUS */

Very, good. I can confirm that with your patch the second switch started working as well. I guess me and @adron previously misunderstood how the second switch is wired.

I re-based my sources [1] and uploaded an updated network bootable preview [2].

Concerning USB no progress as of yet.

[1] https://github.com/ziswiler/openwrt/tree/rb3011uias
[2] https://www.ziswiler.net/owncloud/index.php/s/ReI0emenqAyhlwv

I managed to get working USB; the port is usb3_0, but it then wants USB30_1_UTMI_CLK / USB30_1_MASTER_CLK - if I use the USB30_0 variants boot just hangs until the watchdog kicks in and reboots.

Hello friends. After a year and a half, I returned to work on the RB3011. Now I am analyzing all your developments. I also plan to modify the drivers for the switch chip and network interfaces to work with each port as an independent network interfaces(like in ROS).

Great.
No need to modify the drivers, you just need to start using QCA8k driver, DSA one for QCA8337 switch.
Then they will present as physical ports in Linux

Great news. So someone has already done it. And what about IPQ-40XX? Is this or a similar driver applicable there too?

The answer of my question about IPQ-40XX and other switches is here: https://openwrt.org/docs/techref/hardware/switch

Hello friends. I completed analyzing and reworking of the openwrt code for the 3011th. A working version is ready (based on the sumo code).
OpenWRT-ziswiler-RB3011

Also I want to share my research on the rb3011 switch chips. I compiled the kernel module for RouterOS and with its help read the switch chip registers.
Based on these data, it became clear how exactly the operation of the network subsystem is rebuilt when the SFP is pluged in.

So, in RB3011 we have 4 network interfaces:
	gmac0: 0x37000000 - eth0 - rgmii to switch0[0]
	gmac1: 0x37200000 - eth1 - rgmii to switch1[0] or sgmii to SFP !!!
	gmac2: 0x37400000 - eth2 - sgmii to switch0[6] only work if SERDES_AEN Autoneg is DISABLED!
	gmac3: 0x37600000 - eth3 - sgmii to switch1[6 or 0 if SFP! ] only work if SERDES_AEN Autoneg is DISABLED!

*** without SFP ***
RouterOS dmesg grep:
	switch0: open mac 0 as rgmii
	switch1: open mac 1 as rgmii
	switch0: open mac 2 as sgmii
	switch1: open mac 3 as sgmii
NSS_COMMON_CLK_GATE register = 0xf0fcc
	gmac0: RgMII_RX_EN = 1, RgMII_TX_EN = 1, SgMII_RX_EN = 0, SgMII_TX_EN = 0, GATE_PTP_EN = 1
	gmac1: RgMII_RX_EN = 1, RgMII_TX_EN = 1, SgMII_RX_EN = 0, SgMII_TX_EN = 0, GATE_PTP_EN = 1
	gmac2: RgMII_RX_EN = 0, RgMII_TX_EN = 0, SgMII_RX_EN = 1, SgMII_TX_EN = 1, GATE_PTP_EN = 1
	gmac3: RgMII_RX_EN = 0, RgMII_TX_EN = 0, SgMII_RX_EN = 1, SgMII_TX_EN = 1, GATE_PTP_EN = 1
switches registers dump(without SFP):
	0x0004: 0x07680000, 0x07680000 /* PAD0_MODE */
	0x0008: 0x01000000, 0x01000000 /* PAD5_MODE */
	0x000c: 0x00000080, 0x00000080 /* PAD6_MODE */
	0x0010: 0x40000000, 0x40000000 /* POWER_ON_STRIP ! */
	0x00e0: 0xc741e7de, 0xc741e7de /* SGMII_CTRL */
	0x00e4: 0x0002a545, 0x0006a545 /* MAC_POWER_SEL */
	0x007c: 0x00000c7e, 0x00000c7e /* PORT0_STATUS */
	0x0094: 0x00000c7e, 0x00000c7e /* PORT6_STATUS */
	0x0970: 0x1e864443, 0x1e864443 /* QM_PORT0_CTRL0 */
	0x0974: 0x000001c6, 0x000001c6 /* QM_PORT0_CTRL1 */
	0x0978: 0x19008643, 0x19008643 /* QM_PORT1_CTRL0 */
	0x097c: 0x000001c6, 0x000001c6 /* QM_PORT1_CTRL1 */
	0x0980: 0x19008643, 0x19008643 /* QM_PORT2_CTRL0 */
	0x0984: 0x000001c6, 0x000001c6 /* QM_PORT2_CTRL1 */
	0x0988: 0x19008643, 0x19008643 /* QM_PORT3_CTRL0 */
	0x098c: 0x000001c6, 0x000001c6 /* QM_PORT3_CTRL1 */
	0x0990: 0x19008643, 0x19008643 /* QM_PORT4_CTRL0 */
	0x0994: 0x000001c6, 0x000001c6 /* QM_PORT4_CTRL1 */
	0x0998: 0x1e864443, 0x1e864443 /* QM_PORT5_CTRL0 */
	0x099c: 0x000001c6, 0x000001c6 /* QM_PORT5_CTRL1 */
	0x09a0: 0x1e864443, 0x1e864443 /* QM_PORT6_CTRL0 */
	0x09a4: 0x000001c6, 0x000001c6 /* QM_PORT6_CTRL1 */

*** With SFP ***
RouterOS dmesg grep:
	switch0: open mac 0 as rgmii
	eth5: open mac 1 as sgmii
	switch0: open mac 2 as sgmii
	switch1: open mac 3 as sgmii
NSS_COMMON_CLK_GATE register = 0xf03ee
	gmac0: RgMII_RX_EN = 1, RgMII_TX_EN = 1, SgMII_RX_EN = 0, SgMII_TX_EN = 0, GATE_PTP_EN = 1
	gmac1: RgMII_RX_EN = 0, RgMII_TX_EN = 0, SgMII_RX_EN = 1, SgMII_TX_EN = 1, GATE_PTP_EN = 1
	gmac2: RgMII_RX_EN = 0, RgMII_TX_EN = 0, SgMII_RX_EN = 1, SgMII_TX_EN = 1, GATE_PTP_EN = 1
	gmac3: RgMII_RX_EN = 0, RgMII_TX_EN = 0, SgMII_RX_EN = 1, SgMII_TX_EN = 1, GATE_PTP_EN = 1
switches registers dump diff(when SPF is plugged in):
	-0x0004: 0x07680000, 0x07680000 /* PAD0_MODE */
	+0x0004: 0x07680000, 0x00080080 /* PAD0_MODE */
	-0x0008: 0x01000000, 0x01000000 /* PAD5_MODE */
	+0x0008: 0x01000000, 0x00000000 /* PAD5_MODE */
	-0x000c: 0x00000080, 0x00000080 /* PAD6_MODE */
	+0x000c: 0x00000080, 0x00000000 /* PAD6_MODE */
	-0x0094: 0x00000c7e, 0x00000c7e /* PORT6_STATUS */
	+0x0094: 0x00000c7e, 0x00000e80 /* PORT6_STATUS */

The following scheme is used for switch0:
	gmac0(RGMII) is connected to switch0[0](RGMII) - OK
	gmac2(SGMII) is connected to switch0[6](SGMII) - OK
That is, without SFP, the following scheme is used for switch1:
	gmac1(RGMII) is connected to switch1[0](RGMII) - OK
	gmac3(SGMII) is connected to switch1[6](SGMII) - OK
When plugging in SFP, the following scheme is used for switch1:
	gmac1(SGMII) is connected to SFP(SGMII) - OK
	gmac3(SGMII) is connected to switch1[0](SGMII) - OK
2 Likes

Excellent work, @adron.

I cloned your repo, compiled an image and gave it a try (only netboot). It wasn't an exhaustive test, but I'd say it mostly worked. :+1:

On the LuCi interface Network=>Switch I could spot something weird: whenever I made changes to switch0 (e.g., create a new VLAN with one port), there were also applied to switch1. It could be something related to LuCi rather than to the device itself.

Hello. Yes, most likely this is a bug in LuCI. I don't use it at all. Now I am working on transferring all developments to the latest(trunk version) of openwrt.

Thats LuCi, ports are most likely not ordered in the physical ordering but rather how it was easier to route them on the board.
That can be fixed in the network script to reorder them

Ok, here is the latest openwrt trunk with RB3011 support.
Now i switch to work on DSA for RB3011.

1 Like

Hi @adron,

Nice work!

I had a look at your changes, and might have a few ideas:

There is a new interface for the routerboot soft_config settings: rb_softconfig sysfs driver. It is accessed through /sys/firmware/mikrotik/soft_config/. If there are cases where rbcfg provides functionality that the new sysfs driver does not, please detail them.

There is an RB3011 DTS in upstream Linux that uses the qca8k DSA switch driver

There is an Openwrt SFP package kmod-sfp

Cheers

Hello. I didn't know that rbcfg functionality was ported to the kernel. Thanks for pointing to this.

I tested rb_softconfig sysfs driver and updated my OpenWRT repo.

1 Like