OpenWrt support for TP-Link Deco M4R

I am going to upgrade one of my M4's with the procedure described above (Flash stock debug firmware via recovery web, download https://downloads.openwrt.org/snapshots/targets/ath79/generic/openwrt-ath79-generic-tplink_deco-m4r-v1-squashfs-sysupgrade.bin, split the image into kernel and rootfs and flash the files individually with mtd.
But the files https://downloads.openwrt.org/snapshots/targets/ath79/generic/openwrt-ath79-generic-tplink_deco-m4r-v1-squashfs-factory.bin and https://downloads.openwrt.org/snapshots/targets/ath79/generic/openwrt-ath79-generic-tplink_deco-m4r-v1-squashfs-factory.bin is also available. Can I use one of those (the last) and flash from stock debug firmware without splitting into kernel and rootfs?

I don't understand: What is your "flashing helper"?

Unless you want to run the OpenWrt snapshot, 22.03-rc2 has added Deco M4 support.

The debug firmware will refuse to flash images from the web GUI just like the stock fw. The firmware is based on OpenWrt so it does have sysupgrade functionality that can be used from telnet but my attempts to use it weren't successful (fails to flash because of some old bug), the best method right now is mtd.

The flashing helper is no longer needed because you can download OpenWrt images from the downloads website. It was useful before they weren't there.

Thank you.

I have now flashed with snapshot. But it seemes like I am missing a wan interface. Both ethernet ports seems to be connected to the same (br-lan) interface. If I connect port 2 to my mainrouter, and a client to port 1, I get dhcp directly from my mainrouter. Normally, when I flash OpenWrt on a new device, it is running in routermode.

root@OpenWrt:~# ifconfig
br-lan    Link encap:Ethernet  HWaddr CC:32:E5:3B:69:3C
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fd35:8a2d:260c::1/60 Scope:Global
          inet6 addr: fe80::ce32:e5ff:fe3b:693c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9061 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2055 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1027106 (1003.0 KiB)  TX bytes:286359 (279.6 KiB)

eth0      Link encap:Ethernet  HWaddr CC:32:E5:3B:69:3C
          inet6 addr: fe80::ce32:e5ff:fe3b:693c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9233 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2079 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1239438 (1.1 MiB)  TX bytes:298825 (291.8 KiB)
          Interrupt:4

eth0.1    Link encap:Ethernet  HWaddr CC:32:E5:3B:69:3C
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9149 errors:0 dropped:13 overruns:0 frame:0
          TX packets:2055 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1053867 (1.0 MiB)  TX bytes:286359 (279.6 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:481 errors:0 dropped:0 overruns:0 frame:0
          TX packets:481 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:37484 (36.6 KiB)  TX bytes:37484 (36.6 KiB)
root@OpenWrt:~# brctl show
bridge name     bridge id               STP enabled     interfaces
br-lan          7fff.cc32e53b693c       no              eth0.1
root@OpenWrt:~# swconfig dev switch0 show
Global attributes:
        enable_vlan: 1
        ar8xxx_mib_poll_interval: 500
        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 cc:32:e5:3b:69:3c
Port 5: MAC 00:50:b6:fb:fb:21

        igmp_snooping: 0
        igmp_v3: 0
Port 0:
        mib: MIB counters
RxGoodByte  : 320199 (312.6 KiB)
TxByte      : 1508392 (1.4 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: No MIB data
        enable_eee: 0
        igmp_snooping: 0
        vlan_prio: 0
        pvid: 0
        link: port:1 link:down
Port 2:
        mib: No MIB data
        enable_eee: 0
        igmp_snooping: 0
        vlan_prio: 0
        pvid: 0
        link: port:2 link:down
Port 3:
        mib: MIB counters
RxGoodByte  : 734168 (716.9 KiB)
TxByte      : 1823956 (1.7 MiB)

        enable_eee: 0
        igmp_snooping: 0
        vlan_prio: 0
        pvid: 1
        link: port:3 link:down
Port 4:
        mib: No MIB data
        enable_eee: 0
        igmp_snooping: 0
        vlan_prio: 0
        pvid: 0
        link: port:4 link:down
Port 5:
        mib: MIB counters
RxGoodByte  : 1827095 (1.7 MiB)
TxByte      : 449387 (438.8 KiB)

        enable_eee: 0
        igmp_snooping: 0
        vlan_prio: 0
        pvid: 1
        link: port:5 link:up speed:1000baseT full-duplex txflow rxflow auto
Port 6:
        mib: No MIB data
        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 3 5

I believe this is because the router doesn't have dedicated wan ports, you can create a second VLAN, and let's say port 1 is connected to a modem:
VLAN 1: CPU tagged Port 1 off Port 2 untagged
VLAN 2: CPU tagged Port 1 untagged Port 2 off

Now you can create an interface for WAN.

That did it.
Port 1 is "Lan 1" in Luci and port "3" in /etc/config/network
Port 2 is "Lan 2" in Luci and port "5" in /etc/config/network

in /etc/config/network i replaced:

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '3 5 0t'

with

config interface 'wan'
        option proto 'dhcp'
        option device 'eth0.2'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '3 0t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '5 0t'

I would suggest, that is the default, when you flash a new device. I have only tried one other device with only 2 ports (Asus Map-AC2200), and it has both one wan and one lan port. (But internally, there is two devices, eth0 and eth1).

One more issue: I had to configure the device with stock firmware and the Deco app, before I could get an IP address with dhcp. If somebody know if it is possible to skip that part (e.g. by knowing which ip addresses to set or some arp magic), please share...

There is only eth0 here and other devices that also only have eth0 are also defined in a similar way in 02_network.

I haven't experimented with this, but my secondary router would eventually default to 192.168.0.1 when the main router wasn't available/wasn't running stock firmware (though I had all my routers set up already with the app).

Ok - so i guess the default configuration is correct (regarding the "missing" wan)
And we have to configure the device either as main og secondary router before flashing OpenWrt
I was a little to optimistic.
After my configuration of the switch with VLAN1 and VLAN2, I tried to reboot with a cable to my main router in Port 1 and a cable to my client to Port 2.
My client still gets dhcp from the main router. So there is an error - in my setup or in the firmware.

When configuring wan for eth0.2: When booting, the switch is not setup immediately. Therefore when M4 boots, a client attached to port 2 will get link on the port, and a dhcp offer from a dhcpserver attached to port 1. When M4 is fully booted, the switch is working with VLAN isolation - but at that time, the client already has got the wrong ip address.

When I turn on "Hardware flow offloading", nat only works until I reboot. After reboot I have to turn it off agin to get nat working. That might be a problem with the current snapshot..

I think that might be because the bootloader dictates how the switch is configured until OpenWrt boots up and reconfigures it. I don't know if there is a solution for this.

The router doesn't support hardware nat, the stock firmware uses sfe which is software offloading iirc. Not sure why it breaks nat though.

Really fantastic, thanks for all your work @KinteLiX and @bobthebuilder for getting this supported, the community thanks you!

I was on a snapshot from 21, and tried to manually upgrade but landed up with both decos bricked in the same way, likely because of the previous hacks.
When trying the sysupgrade from inside, they would just reboot to the already installed firmware.

Went back to debug firmware and upgraded both to 22.03.0-rc2 correctly, then made sure to be able to upgrade to rc3 using sysupgrade, and it worked flawlessly.

I admire all the tinkering and work to get this supported, thank you!

1 Like

In all my tinkering, I see that I was never able to get the DHCP to work on LAN with the debug firmware, since it will try to look for some WAN connection and assume that as the uplink.
It wasn't always useful for me to have something dish DHCP, so I would connect via wireless to configure the router while it was in debug fs.
It seems that the initial details are stored in some other location that is always preferred, because even after a year running the OpenWRT when I went back to debug, the WLan of my 1st router came back up as the old name .

When I had troubles with my second one, I facotory reset it while it was in debug mode, and that enabled the default Deco wireless network without a password for me to quickly connect, and configure it with the software.

Since I never used an internet connection, I served the firmware update files from a local web server setup for that.

Note, it might not be the best to play with firmware files over wifi, but it was okay for me... :slight_smile:

You should stick to a wired connection when flashing anything. Don't want to flash garbled data. And better not rely on any DHCP. If you do something like this then always set a static IP on your computer.

It seems that the initial details are stored in some other location that is always preferred, because even after a year running the OpenWRT when I went back to debug, the WLan of my 1st router came back up as the old name .

OpenWrt stores all its data on the "rootfs"/"rootfs_data" partition like any other normal linux distro. But there is of course a whole "config" partition OpenWrt doesn't touch apart from extracting the default MAC address. Could very well be that all of the configuration of the oem firmware is stored there to make upgrading the firmware easier.

First of all @KinteLiX @bobthebuilder thanks for all your hard work in making this work.

I have a set of Deco M4R's (v2) and just installed OpenWRT 22.03.0-rc3. For me the hardest thing was to press the reset button and plug in the power cord at the same time. But I've managed and installed the Debug firmware. After which I've set up a small HTTP server with the latest 22.03.0-rc3 build for this device and followed the clear instructions from #51. Flashing worked first time and the device was available at 192.168.1.1 :partying_face: .

After which I followed the guide to configure Wireless Network Bridge for both AP and a single client. And also configured that the Deco's use my self-hosted DHCP / DNS combo. Installation was relatively painless and I was running within a couple of hours.

Performance tests really show what Mattz5GHz (Sorry, cannot mention you as a new user :person_shrugging: ) already reported. The wireless speed caps at about 200mbps or 27.5MB/s. I've tested using some SMB/NFS copies, so nothing scientific. This seems mostly on par with the stock firmware.

Anyway I'm really glad with my decision to flash OpenWRT. The stock firmware made most of IoT devices behave oddly. Having weird intermittent connection issues. Probably because I live in a really busy wireless area and the TP-Link firmware probably changes channels quite often. Furthermore I was hoping for a little bit of a speed boost, since the link speed seems sufficient. But hey, additional configuration is a really welcome addition! Thanks!

2 Likes

Little update after running OpenWRT for about 24 hours. Overall stability and configuration has been wonderful! Although I find LuCI sometimes a little overwhelming in features. A search function would be a pleasant addition.

I'm however a little disappointed by the performance of the devices. When running iperf3 the speed caps at about 300mbps because of CPU throttling. I know the device is limited and CPU bound and I was looking into: Overclocking Router Devices . Also doing file transfers (over wifi) don't have constant transfer speeds, but rising and falling constantly. Together with the CPU utilization btw.

I read that someone overclocked his Archer C6 v2 with the same chipset to about 1GHz which resolved most performance issues. However I also found that hardware offloading can be available and there is a GitHub repo which has that.

Anyway, food for thought :smile:

Anyway, food for thought

It's all open source here. If you want it, feel free to add it.

Upgrading OpenWRT on DecoM4r

First of all, many thanks to KinteLIX, BobTheBuilder, Mattz5Ghz, Foica David (manual at github) and all others that I might forget to mention, who made this device possible in Openwrt.

I flashed the device successfully to 22.03.0-rc5 release, and am very happy with it.
The only thing I wasn't actually made to work is to configure it as a repeater wirelessly connecting to my Mikrotik ap's. L2 dhcp requests aren't forwarded back to the wired clients connected to the DecoM4.
But that seems to be a structural problem related to the wireless "4 address communication", which is not limited to Openwrt.

The above is actually not my question.
My question is about upgrading Openwrt to the latest AFTER you already installed Openwrt onto the DecoM4.
I ask since I will probably will not be skilled enough to unbrick a bricked device.
So I want to do it first-time-right.

As per manual: While installing Openwrt the first time, you have to split fw-file into two parts (with dd), and then flash using MTD in putty. This because the partition mapping is apparently non standard.

So the question now is:
Is this splitting also needed to upgrade?
Or, can you just use the Luci webif firmware-upgrade function?
Or, do you have to go temporarily back to the Tp-link debug fw, and THEN go to the latest (like a first time Openwrt-install)?

Mattz5Ghz post seems to hint to the latter....

So... Please advise.

Thank You all very much!

Oz

My ipq4019 based M4Rv3 is stable with factory firmware, after 2 weeks runtime. I have an 8 pin clip with USB SPI adaptor if there is NOR flash inside the unit.

You should have a look at the Deco M5 post because the M4R V3 is almost an M5 in the case of an M4R:

1 Like