Initial support for Mikrotik RB2011 (port from ar71xx). Everything works except …wired networking because I'm stuck at configuring the switches.
RB2011 uses AR9344 SoC. According to the old mach file, gmac0 is connected to the AR8327 switch, gmac1 is the internal switch. Port0 on AR8327 is connected to the CPU, port6 is SFP. Mode defined there is RGMII for port0 and SGMII for port6. gmac1 is in GMII mode. I got ar8327-initvals by reading that mach file, referring to the AR8237 datasheet and comparing it to other ar9344 boards using ar8327 which are already ported to ath79.
AR8327 drives the first 5 gigabit ports and the SFP, and the internal 100Mbit switch is connected to the other 5 ports (6-10).
The closest board already supported is AR9344 PowerCloud Systems CR5000 which also uses AR8327 switch and has 5x Gbit ports, but no amount of messing with mdio0/1 and eth0/1 definitions don't make the ethernet ports work completely.
This commit is the snapshot of the current state where ports are detected and swconfig shows the correct up/down state, ARP table is being filled and I can create a conflict in my main network if I plug this device because it responds to the 192.168.1.1 ARP requests, but I can't ping or connect to anything.
I tried:
- setting correct pll-data for eth0, taken from mach file
- explicitly defining and not defining ports in eth0 node
- eth0 with and without gmac-config
- phy-mode rgmii and rgmii-id (which should be the correct value since the delays are configured in AR8327 registers)
- various tweaks to delays and other parameters in ar8327-initvals
- initializing/using AR8327 over mdio1 and eth1 (since there were some occurrences of them being swapped between ar71xx and ath79)
- probably other stuff that I forgot/didn't initialize the switch at all
Kernel bootlog:
```
[ 0.000000] Linux version 5.4.85 (danijel@danijel-pc) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r15350-b9389186b0)) #0 Fri Dec 25 09:38:13 2020
[ 0.000000] printk: bootconsole [early0] enabled
[ 0.000000] CPU0 revision is: 0001974c (MIPS 74Kc)
[ 0.000000] MIPS: machine is MikroTik RouterBOARD 2011
[ 0.000000] SoC: Atheros AR9344 rev 2
[ 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-0x0000000007ffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000000000000-0x0000000007ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 32480
[ 0.000000] Kernel command line: console=ttyS0,115200 rootfstype=squashfs,jffs2
[ 0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[ 0.000000] Writing ErrCtl register=00000000
[ 0.000000] Readback ErrCtl register=00000000
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 118668K/131072K available (5259K kernel code, 177K rwdata, 1180K rodata, 4256K init, 201K bss, 12404K 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] random: get_random_bytes called from start_kernel+0x32c/0x520 with crng_init=0
[ 0.000000] CPU clock: 600.000 MHz
[ 0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 6370868154 ns
[ 0.000010] sched_clock: 32 bits at 300MHz, resolution 3ns, wraps every 7158278654ns
[ 0.008864] Calibrating delay loop... 299.26 BogoMIPS (lpj=598528)
[ 0.051856] pid_max: default: 32768 minimum: 301
[ 0.057266] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.065574] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.079236] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.090346] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[ 0.098198] pinctrl core: initialized pinctrl subsystem
[ 0.105213] NET: Registered protocol family 16
[ 0.117068] GPIO line 14 (rb-2011:nand:nce) hogged as output/high
[ 0.149590] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[ 0.163755] clocksource: Switched to clocksource MIPS
[ 0.170807] NET: Registered protocol family 2
[ 0.176596] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.186168] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.194888] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.202910] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.210270] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.217745] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.225992] NET: Registered protocol family 1
[ 0.231019] PCI: CLS 0 bytes, default 32
[ 1.103759] random: fast init done
[ 5.100925] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[ 5.115362] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 5.122040] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[ 5.151690] pinctrl-single 1804002c.pinmux: 544 pins, size 68
[ 5.159349] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[ 5.167375] printk: console [ttyS0] disabled
[ 5.172324] 18020000.uart: ttyS0 at MMIO 0x18020000 (irq = 9, base_baud = 1562500) is a 16550A
[ 5.182131] printk: console [ttyS0] enabled
[ 5.182131] printk: console [ttyS0] enabled
[ 5.191195] printk: bootconsole [early0] disabled
[ 5.191195] printk: bootconsole [early0] disabled
[ 5.210596] nand: No NAND device found
[ 5.214552] ar934x-nand 1b000200.nand: nand_scan failed, err:-19
[ 5.222605] spi-nor spi0.0: mx25l512e (64 Kbytes)
[ 5.227557] 1 fixed-partitions partitions found on MTD device spi0.0
[ 5.234145] Creating 1 MTD partitions on "spi0.0":
[ 5.239115] 0x000000000000-0x000000010000 : "RouterBoot"
[ 5.246921] 4 routerbootpart partitions found on MTD device RouterBoot
[ 5.253732] Creating 4 MTD partitions on "RouterBoot":
[ 5.259064] 0x000000000000-0x00000000c000 : "bootloader1"
[ 5.265648] 0x00000000c000-0x00000000d000 : "hard_config"
[ 5.272355] 0x00000000d000-0x00000000e000 : "bios"
[ 5.278324] 0x00000000e000-0x00000000f000 : "soft_config"
[ 5.285818] libphy: Fixed MDIO Bus: probed
[ 5.296586] ag71xx 19000000.eth: invalid MAC address, using random address
[ 5.621643] libphy: ag71xx_mdio: probed
[ 5.652691] switch0: Atheros AR8327 rev. 4 switch registered on mdio.0
[ 6.245692] ag71xx 19000000.eth: connected to PHY at mdio.0:00 [uid=004dd034, driver=Atheros AR8216/AR8236/AR8316]
[ 6.257064] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode: rgmii-id
[ 6.264131] ag71xx 1a000000.eth: invalid MAC address, using random address
[ 6.900153] libphy: ag71xx_mdio: probed
[ 6.905704] libphy: ar8xxx-mdio: probed
[ 6.965551] switch1: Atheros AR8229 rev. 1 switch registered on mdio.1
[ 7.034942] ag71xx 1a000000.eth: connected to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]
[ 7.044886] eth1: Atheros AG71xx at 0xba000000, irq 5, mode: gmii
[ 7.051658] ath79-wdt 18060008.wdt: timeout value must be 0 < timeout < 10, using 10
[ 7.063851] MikroTik RouterBOARD hardware configuration sysfs driver v0.06
[ 7.072218] MikroTik RouterBOARD software configuration sysfs driver v0.03
[ 7.080503] NET: Registered protocol family 10
[ 7.087869] Segment Routing with IPv6
[ 7.091816] NET: Registered protocol family 17
[ 7.096502] 8021q: 802.1Q VLAN Support v1.8
[ 7.124821] Freeing unused kernel memory: 4256K
[ 7.129537] This architecture does not have kernel memory protection.
[ 7.136195] Run /init as init process
[ 7.728231] init: Console is alive
[ 7.732105] init: - watchdog -
[ 7.759694] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[ 7.781484] usbcore: registered new interface driver usbfs
[ 7.787286] usbcore: registered new interface driver hub
[ 7.792918] usbcore: registered new device driver usb
[ 7.805069] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 7.821432] SCSI subsystem initialized
[ 7.831393] ehci-fsl: Freescale EHCI Host controller driver
[ 7.839351] ehci-platform: EHCI generic platform driver
[ 7.845102] ehci-platform 1b000000.usb: EHCI Host Controller
[ 7.851031] ehci-platform 1b000000.usb: new USB bus registered, assigned bus number 1
[ 7.859243] ehci-platform 1b000000.usb: irq 3, io mem 0x1b000000
[ 7.879768] ehci-platform 1b000000.usb: USB 2.0 started, EHCI 1.00
[ 7.887085] hub 1-0:1.0: USB hub found
[ 7.891478] hub 1-0:1.0: 1 port detected
[ 7.903458] usbcore: registered new interface driver usb-storage
[ 7.910319] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[ 7.920295] init: - preinit -
/bin/board_detect: /etc/board.d/01_leds: line 28: syntax error: unexpected newline (expecting ")")
[ 8.231819] usb 1-1: new full-speed USB device number 2 using ehci-platform
[ 8.459810] usb 1-1: device descriptor read/64, error -71
[ 8.654608] random: jshn: uninitialized urandom read (4 bytes read)
[ 8.717825] random: jshn: uninitialized urandom read (4 bytes read)
[ 8.799812] usb 1-1: device descriptor read/64, error -71
[ 8.878724] random: jshn: uninitialized urandom read (4 bytes read)
[ 9.039781] usb 1-1: new full-speed USB device number 3 using ehci-platform
[ 9.267760] usb 1-1: device descriptor read/64, error -71
[ 9.607861] usb 1-1: device descriptor read/64, error -71
[ 9.702867] random: procd: uninitialized urandom read (4 bytes read)
[ 9.725443] eth0: link up (1000Mbps/Full duplex)
[ 9.730335] usb usb1-port1: attempt power cycle
[ 9.743177] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 9.758930] IPv6: ADDRCONF(NETDEV_CHANGE): eth0.1: link becomes ready
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[ 10.383770] usb 1-1: new full-speed USB device number 4 using ehci-platform
[ 10.867777] usb 1-1: device not accepting address 4, error -71
[ 10.999760] usb 1-1: new full-speed USB device number 5 using ehci-platform
[ 11.483781] usb 1-1: device not accepting address 5, error -71
[ 11.489887] usb usb1-port1: unable to enumerate USB device
[ 13.914154] eth0: link down
[ 13.938087] procd: - early -
[ 13.941315] procd: - watchdog -
[ 14.497221] procd: - watchdog -
[ 14.500931] procd: - ubus -
[ 14.513037] random: ubusd: uninitialized urandom read (4 bytes read)
[ 14.553856] random: ubusd: uninitialized urandom read (4 bytes read)
[ 14.560981] random: ubusd: uninitialized urandom read (4 bytes read)
[ 14.568787] procd: - init -
Please press Enter to activate this console.
[ 15.267383] kmodloader: loading kernel modules from /etc/modules.d/*
[ 15.315841] Loading modules backported from Linux version v5.8.18-0-gab435ce49bd1
[ 15.323592] Backport generated by backports.git v5.8.18-1-0-ga630fd46
[ 15.391808] xt_time: kernel timezone is -0000
[ 15.555519] urngd: v1.0.2 started.
[ 15.559272] PPP generic driver version 2.4.2
[ 15.566880] NET: Registered protocol family 24
[ 15.677310] ath9k 18100000.wmac: Direct firmware load for ath9k-eeprom-ahb-18100000.wmac.bin failed with error -2
[ 15.687981] ath9k 18100000.wmac: Falling back to sysfs fallback for: ath9k-eeprom-ahb-18100000.wmac.bin
[ 15.896349] random: crng init done
[ 15.899922] random: 3 urandom warning(s) missed due to ratelimiting
[ 15.954999] ieee80211 phy0: Atheros AR9340 Rev:2 mem=0xb8100000, irq=12
[ 16.020188] kmodloader: done loading kernel modules from /etc/modules.d/*
[ 70.036162] eth0: link up (1000Mbps/Full duplex)
[ 70.049916] device eth0 entered promiscuous mode
[ 70.055169] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 70.068124] br-lan: port 1(eth0.1) entered blocking state
[ 70.073884] br-lan: port 1(eth0.1) entered disabled state
[ 70.079881] device eth0.1 entered promiscuous mode
[ 70.103063] br-lan: port 1(eth0.1) entered blocking state
[ 70.108706] br-lan: port 1(eth0.1) entered forwarding state
[ 70.161192] eth1: link up (1000Mbps/Full duplex)
[ 70.190108] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[ 70.204070] device eth1 entered promiscuous mode
[ 70.217944] br-lan: port 2(eth1.1) entered blocking state
[ 70.223586] br-lan: port 2(eth1.1) entered disabled state
[ 70.229637] device eth1.1 entered promiscuous mode
[ 70.234804] br-lan: port 2(eth1.1) entered blocking state
[ 70.240425] br-lan: port 2(eth1.1) entered forwarding state
[ 71.031881] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
```
Bridge is initialized:
```
root@OpenWrt:/# brctl show
bridge name bridge id STP enabled interfaces
br-lan 7fff.4c5e0c329b4d no eth1.1
eth0.1
```
dmesg shows that the port is up, and swconfig shows correct port status and ARP entry for my PC:
```
[ 155.032106] Atheros AR8216/AR8236/AR8316 mdio.0:00: Port 1 is up
root@OpenWrt:/# swconfig dev switch0 show
Global attributes:
enable_vlan: 1
ar8xxx_mib_poll_interval: 0
ar8xxx_mib_type: 0
enable_mirror_rx: 0
enable_mirror_tx: 0
mirror_monitor_port: 0
mirror_source_port: 0
arl_age_time: 300
arl_table: address resolution table
Port 0: MAC 82:d3:dd:de:0b:47
Port 0: MAC 4c:5e:0c:32:9b:4d
Port 1: MAC 1c:87:2c:60:52:68
igmp_snooping: 0
igmp_v3: 0
Port 0:
mib: ???
enable_eee: ???
igmp_snooping: 0
vlan_prio: 0
pvid: 0
link: port:0 link:up speed:1000baseT full-duplex txflow rxflow
Port 1:
mib: ???
enable_eee: 0
igmp_snooping: 0
vlan_prio: 0
pvid: 1
link: port:1 link:up speed:1000baseT full-duplex txflow rxflow eee100 eee1000 auto
Port 2:
mib: ???
enable_eee: 0
igmp_snooping: 0
vlan_prio: 0
pvid: 1
link: port:2 link:down
Port 3:
mib: ???
enable_eee: 0
igmp_snooping: 0
vlan_prio: 0
pvid: 1
link: port:3 link:down
Port 4:
mib: ???
enable_eee: 0
igmp_snooping: 0
vlan_prio: 0
pvid: 1
link: port:4 link:down
Port 5:
mib: ???
enable_eee: 0
igmp_snooping: 0
vlan_prio: 0
pvid: 2
link: port:5 link:down
Port 6:
mib: ???
enable_eee: ???
igmp_snooping: 0
vlan_prio: 0
pvid: 0
link: port:6 link:up speed:10baseT half-duplex
VLAN 1:
vid: 1
ports: 0t 1 2 3 4
VLAN 2:
vid: 2
ports: 0t 5
```
But ping doesn't work and `ip neigh` says FAILED:
```
root@OpenWrt:/# ip neigh
192.168.1.16 dev br-lan used 0/0/0 probes 6 FAILED
```
Can anyone assist me with the switches so that I can move on to cleaning up the device tree and fixing other unrelated issues in the device tree?