[GCC 7.2 BUILD] Optimized TP-Link Archer C7 V2 AC1750 LEDE Firmware

@r00t
First of all, awesome work. I've been using your builds over the last 6 months, all worked flawless fine. But with latest two builds, my connection drops every 5 seconds and router become very lag. I can't access my router settings to make changes.

I am using latest official release right now :disappointed_relieved:
Any tips?

@r00t
Checked why my router was not booting after changing arch to mipsel (via serial interface): breed booted, loaded the kernel, kernel booted, but couldn't load the init. The file was found but couldn't be executed.
Seems that changing the arch in the makefile isn't enough, some things were compiled whit different endianness.

Edit: Was reading about the mipsel repo in openwrt and is for the brcm47xx and ramips targets.
So in conclusion, if you want to optimize your build using CPU_TYPE=74kc you are with your own packages, nothing more, nothing less. I'll stick with 74kc for a while.

Thanks for the guidance, it compiled fine. Now can you tell me please, is it possible to just compile for the Archer C7 v2 only?, or is it it has to compile for all the a71xx-generic routers?

this is a script i wrote so no need to add sudo and access root, you just place the lines on the script you want to use for your trunk and use whatever .config file you want and download the patches from @root, once hes fixed the broken patch.

do you know the difference between big endian and little endian? big endian byte order small to big, little endian byte order big to small, better whip out gdb lol

Sorry, I can't reproduce this and didn't get any reports of similar issues so far. You'll have to investigate this yourself and share logs.

Yeah I want to avoid running a private repo, so going to stick with 24kc for now. Using 74kc and not providing a repo isn't an option - I got several complaints pouring in about opkg not working just an hour after I pushed the 74kc release, lol.

i think with the 74kc @cliobrando is trying to achieve could incorporate the hardware nat patch gwlim is working on right?

Time ago was reading why LEDE developers use mips_24kc as the default arch, and was about maintainability: 34kc and 74kc (even 1004kc) archs are backward compatible with 24kc, and the performance gains using specific arch optimizations are minimal vs the effort to maintain a lot of different packages repos for every arch. So they create a unique repo for all the similar archs.

I doubt that compiling the code as 24kc optimizes the CPU pipelining for the 74kc (24kc has 8 stage pipelining vs 14/15 stage pipeline of the 74kc), but I don't know if optimizing the code at this level will have a real impact on the daily use of the router. maybe some benchmarks will be benefited by this.

have you seen gwlims builds for archer c7 v2 with hardware nat? https://github.com/gwlim/Openwrt_Firmware/tree/master/TP-Link_Archer_C7_V2/LEDE-17.01/April-2017-Image

There's no hardware NAT for Archer C7, it requires a driver that is closed source.
Only fastpath is available for Archer C7 and isn't hardware accelerated.

Before someone mentions Network Offload: isn't available for Archer C7 (Need kernel 4.14), and is only hardware accelerated in some mediatek socs (in owrt) iirc.

What exactly are broken in his patches? Is it that when you apply his patches you are getting some errors?

Well his image looks like it clearly states hardware nat on it.

@r00t
Found a workaround:
Compile using CPU_TYPE=74kc
Change feeds to 24kc:
/etc/opkg/distfeeds.conf

src/gz openwrt_core http://downloads.lede-project.org/snapshots/targets/ar71xx/generic/packages
src/gz openwrt_base http://downloads.lede-project.org/snapshots/packages/mips_24kc/base
src/gz openwrt_luci http://downloads.lede-project.org/snapshots/packages/mips_24kc/luci
src/gz openwrt_packages http://downloads.lede-project.org/snapshots/packages/mips_24kc/packages
src/gz openwrt_routing http://downloads.lede-project.org/snapshots/packages/mips_24kc/routing
src/gz openwrt_telephony http://downloads.lede-project.org/snapshots/packages/mips_24kc/telephony

Then edit /etc/opkg.conf
add at the end of the file:

arch all 1
arch noarch 1
arch mips_24kc 100
arch mips_74kc 1

Then you can install packages from the 24kc repo (they are compatible with 74kc).
So you will get: all packages that come with the firmware will be optimized with 74kc, and you can download packages from the lede repo compiled with 24kc.

I think they called HW Nat -> FastPath.
Some tests were made at that time with a Qualcomm SDK that never worked as intended.

System Log

Kernel Log

I had done some benchmarks on my WDR4300 (AR9344 74kc) with dhrystone, whetstone and coremark...

On all three benchmarks the resultet performance gain was between 1 and 3 percent with -march 74kc in comparison to -march 24kc.

I'm sure that the pipelining of the cpu has nothing to do with the -march or -mtune gcc option.
The compiler does only generate sequential code and does not instruct the cpu which commands or data should be prefetched or loaded to which pipeline.

1 Like

Thanks for the aclaration, I was wrong about that.

I have followed the instruction to the letter, did not get this directory when i applied the patch.

mv ./target/linux/generic/patches-4.9/* ./target/linux/generic/pending-4.9/ rm -rf…

tried twice to compile, and got this with the patched applied.

patching file src/usbipd.c
Hunk #1 FAILED at 453.
1 out of 1 hunk FAILED -- saving rejects to file src/usbipd.c.rej
Patch failed!  Please fix ./patches-2.0/100-musl-compat.patch!
Makefile:109: recipe for target '/home/debian-ssh/lede/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/usbip-2.0/.prepared_f04c5c165e07c9ff01da392ed839b4c1_18f1e190c5d53547fed41a3eaa76e9e9' failed
make[3]: *** [/home/debian-ssh/lede/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/usbip-2.0/.prepared_f04c5c165e07c9ff01da392ed839b4c1_18f1e190c5d53547fed41a3eaa76e9e9] Error 1
make[3]: Leaving directory '/home/debian-ssh/lede/feeds/packages/net/usbip'
Command exited with non-zero status 2
time: package/feeds/packages/usbip/compile#0.03#0.00#0.11
package/Makefile:107: recipe for target 'package/feeds/packages/usbip/compile' failed
make[2]: *** [package/feeds/packages/usbip/compile] Error 2
make[2]: Leaving directory '/home/debian-ssh/lede'
package/Makefile:103: recipe for target '/home/debian-ssh/lede/staging_dir/target-mips_24kc_musl/stamp/.package_compile' failed
make[1]: *** [/home/debian-ssh/lede/staging_dir/target-mips_24kc_musl/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/debian-ssh/lede'
/home/debian-ssh/lede/include/toplevel.mk:216: recipe for target 'world' failed
make: *** [world] Error 2

I copied the r00t patches folder to my lede directory, copied the ./config also, ran the patch syntax, did not get that directory as mentioned, saw no errors after the patch was applied. Ran make defconfig, then make -j1 V=s

Very frustrated

so i installed gwlims image and it appears that the qca ssdk is installed on it, anybody tried to upstream the patch?? if you try the image:


you then run ssdk_sh whicn brings you to a cli where you set the nat etc...