[Xiaomi Router 4A 100M (R4AC)] Wireless issues, PHY is undefined for device 'radio0'

Hello. I have a Xiaomi Router 4A 100M which I've recently flashed the latest MIR4A (R4AC's image bricks my router) OpenWRT into, and I'm having issues with the wireless radios randomly disconnecting, sometimes giving Connected, no data , refuse to connect or just straight up get disabled.

here's a snippet of the logread

Thu Jan 19 19:26:20 2023 daemon.notice netifd: radio0 (16608): WARNING: Variable 'data' does not exist or is not an array/object
Thu Jan 19 19:26:20 2023 daemon.notice netifd: radio0 (16608): Bug: PHY is undefined for device 'radio0'
Thu Jan 19 19:26:21 2023 daemon.notice netifd: Wireless device 'radio0' is now down
Thu Jan 19 19:26:21 2023 kern.info kernel: [83637.439817] device wlan0 left promiscuous mode
Thu Jan 19 19:26:21 2023 kern.info kernel: [83637.444586] br-lan: port 2(wlan0) entered disabled state

I changed wireless name, password (WPA/WPA2 mixed) and disabled 802.11w, everything else is left as stock, but the issue still persists. Only a reboot or just waiting a dozen or so minutes after restarting the wireless radio temporarily fixes the issue. Any help will be appreciated.

dmesg | grep -e pci output :

[    0.247633] mt7620-pci 10140000.pcie: Port 0 N_FTS = 1b105000
[    0.408090] PCI host bridge /pcie@10140000 ranges:
[    0.476667] pci_bus 0000:00: root bus resource [mem 0x20000000-0x2fffffff]
[    0.483374] pci_bus 0000:00: root bus resource [io  0x10160000-0x1016ffff]
[    0.489954] pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0]
[    0.496511] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[    0.504205] pci 0000:00:00.0: [14c3:0801] type 01 class 0x060400
[    0.509971] pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x7fffffff]
[    0.515996] pci 0000:00:00.0: reg 0x14: [mem 0x20200000-0x2020ffff]
[    0.522121] pci 0000:00:00.0: supports D1
[    0.525925] pci 0000:00:00.0: PME# supported from D0 D1 D3hot
[    0.533327] pci 0000:01:00.0: [14c3:7662] type 00 class 0x028000
[    0.539113] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x000fffff 64bit]
[    0.545705] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0000ffff pref]
[    0.552222] pci 0000:01:00.0: PME# supported from D0 D3hot D3cold
[    0.559582] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[    0.565924] pci_bus 0000:00: busn_res: [bus 00-ff] end is updated to 01
[    0.572378] pci 0000:00:00.0: BAR 0: no space for [mem size 0x80000000]
[    0.578704] pci 0000:00:00.0: BAR 0: failed to assign [mem size 0x80000000]
[    0.585438] pci 0000:00:00.0: BAR 8: assigned [mem 0x20000000-0x200fffff]
[    0.591979] pci 0000:00:00.0: BAR 9: assigned [mem 0x20100000-0x201fffff pref]
[    0.598958] pci 0000:00:00.0: BAR 1: assigned [mem 0x20200000-0x2020ffff]
[    0.605511] pci 0000:01:00.0: BAR 0: assigned [mem 0x20000000-0x200fffff 64bit]
[    0.612584] pci 0000:01:00.0: BAR 6: assigned [mem 0x20100000-0x2010ffff pref]
[    0.619528] pci 0000:00:00.0: PCI bridge to [bus 01]
[    0.624328] pci 0000:00:00.0:   bridge window [mem 0x20000000-0x200fffff]
[    0.630869] pci 0000:00:00.0:   bridge window [mem 0x20100000-0x201fffff pref]

[   17.201419] mt76x2e 0000:01:00.0: card - bus=0x1, slot = 0x0 irq=4
[   17.208039] mt76x2e 0000:01:00.0: ASIC revision: 76120044
[   18.489680] mt76x2e 0000:01:00.0: ROM patch build: 20141115060606a
[   18.509540] mt76x2e 0000:01:00.0: Firmware Version: 0.0.00
[   18.515194] mt76x2e 0000:01:00.0: Build: 1
[   18.519347] mt76x2e 0000:01:00.0: Build Time: 201607111443____
[   18.545112] mt76x2e 0000:01:00.0: Firmware running!

config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/10300000.wmac'
        option channel '1'
        option band '2g'
        option htmode 'HT20'
        option cell_density '0'
        option country 'MA'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'AP-G'
        option key 'Tulipe2022'
        option ieee80211w '0'
        option encryption 'psk-mixed'

config wifi-device 'radio1'
        option type 'mac80211'
        option path 'pci0000:00/0000:00:00.0/0000:01:00.0'
        option channel '36'
        option band '5g'
        option htmode 'VHT80'
        option cell_density '0'
        option country 'MA'

config wifi-iface 'default_radio1'
        option device 'radio1'
        option network 'lan'
        option mode 'ap'
        option ssid 'AP-G_5G'
        option key 'Tulipe2022'
        option ieee80211w '0'
        option encryption 'psk-mixed'

Check out this comment: WPA2/WPA3-Mixed Mode: connectivity issues with iOS 15.2 - #6 by webknjaz

Maybe worth a shot to use "pure" encryption option, not mixed?

given a try and tested it for 2 days, problem lessened but not gone.

You could try some debugging by enabling more log messages:

[   18.489680] mt76x2e 0000:01:00.0: ROM patch build: 20141115060606a
[   18.509540] mt76x2e 0000:01:00.0: Firmware Version: 0.0.00
[   18.515194] mt76x2e 0000:01:00.0: Build: 1
[   18.519347] mt76x2e 0000:01:00.0: Build Time: 201607111443____

firmware version 0.0.00 ????

What version of OpenWRT is this? 22.03.3, snapshot of 22.03.3 or Master snapshot?
What version of the kernel?

It's the latest stable release on the MIR4A page, version 22.03.3, kernel version 5.10.161

Sun Jan 22 09:29:14 2023 kern.info kernel: [20709.464941] rt3050-esw 10110000.esw: port 0 link down
Sun Jan 22 09:29:14 2023 kern.info kernel: [20709.470993] br-lan: port 1(eth0.1) entered disabled state
Sun Jan 22 09:29:14 2023 daemon.notice netifd: Network device 'eth0' link is down
Sun Jan 22 09:29:14 2023 daemon.notice netifd: VLAN 'eth0.1' link is down
Sun Jan 22 09:29:14 2023 daemon.notice netifd: VLAN 'eth0.2' link is down
Sun Jan 22 09:29:14 2023 daemon.notice netifd: Interface 'wan' has link connectivity loss
Sun Jan 22 09:29:14 2023 daemon.notice netifd: Interface 'wan6' has link connectivity loss
Sun Jan 22 09:29:14 2023 kern.info kernel: [20709.549384] device wlan0 left promiscuous mode
Sun Jan 22 09:29:14 2023 kern.info kernel: [20709.554074] br-lan: port 3(wlan0) entered disabled state
Sun Jan 22 09:29:14 2023 daemon.warn dnsmasq[1]: no servers found in /tmp/resolv.conf.d/resolv.conf.auto, will retry
Sun Jan 22 09:29:15 2023 daemon.notice netifd: wan (1967): udhcpc: received SIGTERM
Sun Jan 22 09:29:15 2023 daemon.notice netifd: wan (1967): udhcpc: unicasting a release of 192.168.0.108 to 192.168.0.1
Sun Jan 22 09:29:15 2023 daemon.notice netifd: wan (1967): udhcpc: sending release
Sun Jan 22 09:29:15 2023 daemon.notice netifd: wan (1967): udhcpc: entering released state
Sun Jan 22 09:29:15 2023 daemon.notice netifd: Interface 'wan6' is now down
Sun Jan 22 09:29:15 2023 daemon.notice netifd: wan (1967): Command failed: ubus call network.interface notify_proto { "action": 0, "link-up": false, "keep": false, "interface": "wan" } (Permission denied)
Sun Jan 22 09:29:15 2023 daemon.notice netifd: Interface 'wan' is now down
Sun Jan 22 09:29:15 2023 daemon.notice hostapd: Remove interface 'wlan0'
Sun Jan 22 09:29:15 2023 daemon.notice hostapd: wlan0: interface state ENABLED->DISABLED
Sun Jan 22 09:29:15 2023 daemon.notice hostapd: wlan0: AP-STA-DISCONNECTED 34:41:5d:d7:a4:6a
Sun Jan 22 09:29:15 2023 daemon.notice hostapd: wlan0: AP-STA-DISCONNECTED 00:27:15:07:47:ed
Sun Jan 22 09:29:15 2023 daemon.notice hostapd: wlan0: AP-STA-DISCONNECTED ae:bb:14:d7:c6:f3
Sun Jan 22 09:29:15 2023 daemon.notice hostapd: wlan0: AP-STA-DISCONNECTED 7e:41:db:58:15:3f
Sun Jan 22 09:29:15 2023 daemon.notice hostapd: wlan0: AP-DISABLED
Sun Jan 22 09:29:15 2023 daemon.notice hostapd: wlan0: CTRL-EVENT-TERMINATING
Sun Jan 22 09:29:15 2023 daemon.err hostapd: rmdir[ctrl_interface=/var/run/hostapd]: Permission denied
Sun Jan 22 09:29:15 2023 daemon.notice hostapd: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Sun Jan 22 09:29:15 2023 daemon.notice hostapd: nl80211: Failed to remove interface wlan0 from bridge br-lan: Invalid argument
Sun Jan 22 09:29:15 2023 daemon.notice netifd: Wireless device 'radio0' is now down

Interesting. The first thing that goes down is your br-lan, not the actual wifi interfaces?

I tried to look for related issues:

OpenWRT related code that involves the rt3050:

by searching https://github.com/openwrt/openwrt/search?q=rt3050

But i don't know how to interpret this, as I am not a programmer.

while it does say br-lan disconnected, I still have internet access, 5ghz is stable and always working, 2.4ghz AP keeps disappearing after a few hours, and a manual reboot is needed

May have found a fix, set inacitivity polling to 1500, and have this cronjob : */30 * * * * if [ -n "$(wifi status radio0 | grep '"up": false')" ]; then wifi up radio0