Support for new Archer c5 v4

Hi! Can I flash the compiled firmware straight from stock? Thanks.

A little update, I got stuck in here:

make[5]: Entering directory '/home/felipearanda/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/linux-5.15.17'
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  CHK     include/generated/compile.h
  CC      drivers/net/ethernet/ralink/mtk_eth_soc.o
In file included from ./include/linux/printk.h:11,
                 from ./include/linux/kernel.h:19,
                 from ./include/linux/list.h:9,
                 from ./include/linux/module.h:12,
                 from drivers/net/ethernet/ralink/mtk_eth_soc.c:15:
drivers/net/ethernet/ralink/mtk_eth_soc.c: In function 'fe_features_check':
drivers/net/ethernet/ralink/mtk_eth_soc.c:817:41: error: request for member 'needed_tailroom' in something not a structure or union
  817 |                 WARN_ONCE(tag_ops->proto.needed_tailroom,
      |                                         ^
./include/linux/once_lite.h:15:41: note: in definition of macro 'DO_ONCE_LITE_IF'
   15 |                 bool __ret_do_once = !!(condition);                     \
      |                                         ^~~~~~~~~
drivers/net/ethernet/ralink/mtk_eth_soc.c:817:17: note: in expansion of macro 'WARN_ONCE'
  817 |                 WARN_ONCE(tag_ops->proto.needed_tailroom,
      |                 ^~~~~~~~~
In file included from ./arch/mips/include/asm/bug.h:42,
                 from ./include/linux/bug.h:5,
                 from ./arch/mips/include/asm/cmpxchg.h:11,
                 from ./arch/mips/include/asm/atomic.h:22,
                 from ./include/linux/atomic.h:7,
                 from ./include/linux/cpumask.h:13,
                 from ./include/linux/smp.h:13,
                 from ./arch/mips/include/asm/cpu-type.h:12,
                 from ./arch/mips/include/asm/timex.h:19,
                 from ./include/linux/timex.h:65,
                 from ./include/linux/time32.h:13,
                 from ./include/linux/time.h:60,
                 from ./include/linux/stat.h:19,
                 from ./include/linux/module.h:13,
                 from drivers/net/ethernet/ralink/mtk_eth_soc.c:15:
drivers/net/ethernet/ralink/mtk_eth_soc.c:821:41: error: invalid type argument of '->' (have 'unsigned int')
  821 |                           tag_ops->proto->name);
      |                                         ^~
./include/asm-generic/bug.h:91:62: note: in definition of macro '__WARN_printf'
   91 |                 warn_slowpath_fmt(__FILE__, __LINE__, taint, arg);      \
      |                                                              ^~~
./include/linux/once_lite.h:19:25: note: in expansion of macro 'WARN'
   19 |                         func(__VA_ARGS__);                              \
      |                         ^~~~
./include/asm-generic/bug.h:150:9: note: in expansion of macro 'DO_ONCE_LITE_IF'
  150 |         DO_ONCE_LITE_IF(condition, WARN, 1, format)
      |         ^~~~~~~~~~~~~~~
drivers/net/ethernet/ralink/mtk_eth_soc.c:817:17: note: in expansion of macro 'WARN_ONCE'
  817 |                 WARN_ONCE(tag_ops->proto.needed_tailroom,
      |                 ^~~~~~~~~
drivers/net/ethernet/ralink/mtk_eth_soc.c: In function 'fe_probe':
drivers/net/ethernet/ralink/mtk_eth_soc.c:1624:9: warning: ignoring return value of 'device_reset' declared with attribute 'warn_unused_result' [-Wunused-result]
 1624 |         device_reset(&pdev->dev);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
make[9]: *** [scripts/Makefile.build:277: drivers/net/ethernet/ralink/mtk_eth_soc.o] Error 1
make[8]: *** [scripts/Makefile.build:540: drivers/net/ethernet/ralink] Error 2
make[7]: *** [scripts/Makefile.build:540: drivers/net/ethernet] Error 2
make[6]: *** [scripts/Makefile.build:540: drivers/net] Error 2
make[5]: *** [Makefile:1868: drivers] Error 2
make[5]: Leaving directory '/home/felipearanda/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/linux-5.15.17'
make[4]: *** [Makefile:24: /home/felipearanda/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/linux-5.15.17/.modules] Error 2
make[4]: Leaving directory '/home/felipearanda/openwrt/target/linux/ramips'
make[3]: *** [Makefile:11: compile] Error 2
make[3]: Leaving directory '/home/felipearanda/openwrt/target/linux'
time: target/linux/compile#3.76#1.19#5.02
    ERROR: target/linux failed to build.
make[2]: *** [target/Makefile:30: target/linux/compile] Error 1
make[2]: Leaving directory '/home/felipearanda/openwrt'
make[1]: *** [target/Makefile:23: /home/felipearanda/openwrt/staging_dir/target-mipsel_24kc_musl/stamp/.target_compile] Error 2
make[1]: Leaving directory '/home/felipearanda/openwrt'
make: *** [/home/felipearanda/openwrt/include/toplevel.mk:230: world] Error 2

Hi! I was able to keep compiling by commenting out this part of the code:

		/*WARN_ONCE(tag_ops->proto.needed_tailroom,
			  "The DSA TAG %s is added to the end of the packet."
			  "It will break HW and SW checksum for any driver "
			  "incompatible with that TAG (different vendor)",
			  tag_ops->proto->name);*/

But I believe this is part of the HW offload fix @luizluca created, right?

No. I believe you still need to use the tftp recovery method (or the serial port). Nothing has changed in that front.

I'll try to cleanup that branch a little bit more. There were some upstream changes that I need to put in sync.

Yes, it is more a "disable HW offload" than a fix :wink: There is no possible fix.

Got it! So, is it ok to leave that part off? It successfully built the image. Thank you for your time on this project :slight_smile:

1 Like

A post was split to a new topic: Full dump of TP Link Archer C5 v4 needed

Hi luizluca, I'm trying to compile sysupgrade image for my C5 v4, using the branch tplink_c5v4_dsa_5.15up.
For config, select:

  • Target system : MediaTek Ralink MIPS
  • Subtarget : MT7620 based boards
  • Target profile : TP-Link Archer C5 v4

also

  • Enable experimental features by default

The image compiles successfully, but when flash it to the router, no ports seems to work (wan & lan). Only wifi works when enable it from serial console.

Am I missing something, or doing something wrong?
Thanks in advance!

i guess you are missing a kernel driver patch for the switch or not enabled the vendor specifc DSA tag + vendor specifc DSA switch support for your device..

Because the branch is specific for TP-Link Archer C5 v4 DSA, i suppose the necessary patches are included and the switch support is enabled when select the same model. Am I right?

i think this device isn't officially supported by openwrt
the releases available here https://github.com/benwht/openwrt/releases which work well, use a realtek switch patch

i remember bec i used the patch for building for my c5 v4 few years ago

Yes, I also used benwht's patch and know that his patch works. But because that patch is not applicable for OpenWrt 21.02, I decided to switch to luizluca's https://github.com/luizluca/openwrt/tree/tplink_c5v4_dsa_5.15up to try it.
And that's why I asked if anybody tried to compile luizluca's specific branch to help me set it correctly.

You need "Use the testing kernel version" (Global build settings), not "Enable experimental features by default"

1 Like

@luizluca, "Enable experimental features by default" auto-selects "Use the testing kernel version". The wan and lan ports don't work with neither tplink_c5v4_dsa_5.15up nor tplink_c5v4_dsa branches. There is Rx activity, but no Tx traffic.

1 Like

It should have worked. You do need to have packages kmod-switch-realtek-mdio installed. If is selected by default in a clean config but nothing prevents the user to unselect it.

I just refreshed my branch with equivalent results https://github.com/luizluca/openwrt/tree/tplink_c5v4_dsa

The issues I current have with that branch are:

  1. forwarding is done in SW (current driver limitation)
  2. only one LAN port works at a time (maybe because of 1)
  3. only one wireless card recognized
  4. I still need to disable all resets (there is an unknown issue with reset and 5.15)

And there is an unfixable limitation with any mediatek+realtek DSA: no TCP checksum offload.

1 Like

Greetings. I have a few setup questions.

  1. Did I do the right thing when I combined all the interfaces of the router into one bridge? Without this, nothing worked stably on the internal network connected to the router.
  2. How to view all packets passing through all ports of the router to the outside and entering from the Internet? Is it possible to configure a SPAN port on this router?

Hello,

I believe the port is finished. Again the repo is the same.

It requires testing kernel (CONFIG_HAS_TESTING_KERNEL=y) and it might automatically select CONFIG_PACKAGE_kmod-switch-realtek-mdio (menuconfig does not prevent you from removing it). Everything I tested worked as expected, even failsafe.

It include dozens of pending patches, but only for OpenWrt. Many of those patches for OpenWrt are related to mediatek network driver for mt7620. I might start to submit them soon. All required upstream changes are already merged (backported from 5.16 .. 5.19/net_next). However, I'm not sure it is safe (for other devices) to have that much of backported patches. DSA is still evolving upstream and the changes I picked might also break another DSA driver. Anyway, time is our ally and we'll get them for free as soon as OpenWrt goes to the next LTS kernel (post 5.15).

Changes since the last update:

  1. Resets started to work (not fixed by me). I removed the hack and USB and both wireless started to work
  2. The issue with only 1 LAN client was the internal mediatek switch not happy with realtek forwarding frames in CPU. I disabled the source mac learning and it now works as expected.

I don't believe the port can get much better than this. Except from a better switch driver (that actually does forwarding in HW) or a better 2.4G wifi (yes, it still sucks as before), there is no more room for large improvements. The mix "mediatek Soc + any non-mediatek DSA switch" might be slower than swconfig because mediatek cannot handle TCP checksum offload with a DSA tag. I didn't evaluated if an 802.1Q DSA tag might work better but the driver might need to improve before we try.

I didn't do a performance compassion between DSA, swconfig and factory but I expect DSA to be the slowest one. And don't expect good LAN to LAN performance until we get a proper fowarding in HW.

As I said, I might start to send some preliminary patches to the list soon. Even if all of them get merged, I might still wait for the next testing kernel before submitting the device port. The required backported patches might also be submitted by someone willing to use that Realtek driver for another device. @hauke submitted some upstream patches indicating he is working on another Realtek device. There are plenty of them already in OpenWrt.

Once all generic patches are applied, the device patch is a boring DTS declaration (with a minor LED config).

Have fun!

3 Likes

compiled the latest firmware

OpenWrt v21.2
OpenWrt v22.3

2 Likes

Hi, thanks for share. The wifi 2.4g was solved?

How can i install? Can you make a tutorial?

Download the "openwrt-ramips-mt7620-tplink_archer-c5-v4-squashfs-tftp-recovery.bin`

  1. rename the openwrt-ramips-mt7620-tplink_archer-c5-v4-squashfs-tftp-recovery.bin* to tp_recovery.bin
  2. start a TFTP server from IP address 192.168.0.66 and serve the image named tp_recovery.bin
  3. select the firmware file and press "enter"
  4. connect your device to the router LAN port (1-4)
    to start the TFTP recovery process on the router, press and hold the “Reset button” and then power up the router. Keep the “Reset button” pressed until the WPS LED turns on (it's the LED with two arrows pointing in different directions)
  5. If everything went well, you should see a read request on your TFTP server
1 Like