TL-R470T+ v6 compiling custom firmware from GPL sources provided by TP-Link
Hi there,
I was pretty disappointed to find out that the TL-R470T+ recently purchased comes with firmware that removed any remote access (telnet/ssh) into the router!! From reading online (before purchase) and even looking in the (older) documentation it showed telnet as a possibility..
In addition their router only provides for PAID ddns services, and not any of the free ones :) that's a bit annoying, given that openwrt has a module with all the providers already...
Anyways, one thing leads to another, and it is mentioned that the router uses OpenWRT and GPL source code is provided by TP-Link:
https://www.tp-link.com/us/support/download/tl-r470t%252b/#GPL-Code
Searching online, did not find anyone else who rebuilt successfully, one post mentioned the code is non-usable, that got me curious!! So, here are my attempts, download that tar.bz2:
1e8252cf441c4456cd12fdb066d75759 TL-R470T-plus6.0_GPL.tar.bz2
untar, run make menuconfig (as the README suggests), fails with:
1)
scripts/config/mconf: 1: scripts/config/mconf: Syntax error: “(” unexpected
Searching online, found Japanese website, with similar error:
https://www.bbsmax.com/A/Gkz1QPojzR/
Suggestion was: cd scripts/config
make clean & make
That WORKED, menuconfig appeared, I selected the TL-R470T config, and SAVED as .config
2) Running make failed with:
autoreconf: running: /home/stormy/dev_router_series_r470_gpl/dev_router_series/staging_dir/host/bin/automake --add-missing
Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at /home/stormy/dev_router_series_r470_gpl/dev_router_series/staging_dir/host/bin/automake line 4160.
Searching found similar error (interaction of perl & automake: https://github.com/raspberrypi/noobs/issues/470
Solution is to escape the curley braces {} as below:
Orig: $text =~ s/\${([^ \t=:+{}]+)}/&substitute_ac_subst_variables_worker ($1)/ge;
Fix: $text =~ s/\$\{([^ \t=:+\{\}]+)\}/&substitute_ac_subst_variables_worker ($1)/ge;
3) Next the "make" continues for a while, and fails when trying to download kernel sources for 3.10.14, with many URLs, here is just one failure:
"@KERNEL/linux/kernel/v3.x"
--2019-12-24 20:01:50-- ftp://ftp.all.kernel.org/pub/linux/kernel/v3.x/linux-3.10.14.tar.xz
=> '-'
Resolving ftp.all.kernel.org (ftp.all.kernel.org)... failed: Name or service not known.
wget: unable to resolve host address 'ftp.all.kernel.org'
basically, the download.pl script has bunch of hardcoded locations, all of which are not valid, or the file missing.
For example: http://mirror2.openwrt.org/sources, as well as the ftp.all.kernel.org, and others too.
Thinking, oh, maybe this generic place will do: https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/
Edited download.pl, and changed to that path, then make failed to apply patches to Kconfig as follows:
Applying /home/stormy/dev_router_series_r470_gpl/dev_router_series/target/linux/generic/patches-3.10.14/400-mtd-patches.patch using plaintext: patching file drivers/mtd/chips/cfi_cmdset_0002.c patching file drivers/mtd/Kconfig Hunk #1 FAILED at 15. Hunk #2 succeeded at 154 (offset -60 lines). 1 out of 2 hunks FAILED -- saving rejects to file drivers/mtd/Kconfig.rej patching file drivers/mtd/Makefile Hunk #1 succeeded at 13 (offset -8 lines). patching file drivers/mtd/mtdpart.c Hunk #1 FAILED at 29. Hunk #2 FAILED at 52. Hunk #3 FAILED at 239. Hunk #4 FAILED at 259. Hunk #5 FAILED at 282. Hunk #6 FAILED at 290. Hunk #7 FAILED at 303. Hunk #8 FAILED at 323. Hunk #9 FAILED at 342. Hunk #10 FAILED at 350. Hunk #11 FAILED at 522. Hunk #12 FAILED at 599. Hunk #13 FAILED at 621. Hunk #14 FAILED at 657. Hunk #15 FAILED at 724. Hunk #16 FAILED at 806. Hunk #17 FAILED at 849. Hunk #18 FAILED at 869. Hunk #19 FAILED at 895. Hunk #20 FAILED at 909. Hunk #21 FAILED at 962. Hunk #22 FAILED at 993. Hunk #23 FAILED at 1024. Hunk #24 FAILED at 1048. Hunk #25 FAILED at 1126. Hunk #26 FAILED at 1158. Hunk #27 FAILED at 1177. Hunk #28 FAILED at 1195. 28 out of 28 hunks FAILED -- saving rejects to file drivers/mtd/mtdpart.c.rej patching file drivers/mtd/nand/nand_ecc.c patching file drivers/mtd/nand/plat_nand.c patching file drivers/mtd/redboot.c patching file include/linux/mtd/mtd.h Hunk #1 FAILED at 59. Hunk #2 FAILED at 337. Hunk #3 FAILED at 355. 3 out of 3 hunks FAILED -- saving rejects to file include/linux/mtd/mtd.h.rej patching file include/linux/mtd/nand.h Hunk #1 FAILED at 659. 1 out of 1 hunk FAILED -- saving rejects to file include/linux/mtd/nand.h.rej patching file include/linux/mtd/partitions.h Hunk #3 FAILED at 68. Hunk #4 FAILED at 82. Hunk #5 FAILED at 94. Hunk #6 FAILED at 108. 4 out of 6 hunks FAILED -- saving rejects to file include/linux/mtd/partitions.h.rej Patch failed! Please fix /home/stormy/dev_router_series_r470_gpl/dev_router_series/target/linux/generic/patches-3.10.14/400-mtd-patches.patch!
Looking around, nothing obvious, so then thought, oh, wait, maybe they need the linux sources from another/better place :) tried:
https://www.linux-mips.org/pub/linux/mips/kernel/v3.x/linux-3.10.14.tar.xz
rm -f dl/linux-3.10.14.tar.xz ; make
it pulled the kernel tree from other location, now the patching failed at a much earlier place:
Applying /home/stormy/dev_router_series_r470_gpl/dev_router_series/target/linux/generic/patches-3.10.14/1001-8021q_vlan_support_untag.patch using plaintext: patching file include/uapi/linux/if_vlan.h patching file net/8021q/vlan.c Hunk #1 succeeded at 501 (offset -2 lines). Hunk #2 succeeded at 588 (offset -2 lines). patching file net/8021q/vlan_dev.c patching file net/8021q/vlan.h patching file net/8021q/vlanproc.c Hunk #1 succeeded at 285 (offset -6 lines). Applying /home/stormy/dev_router_series_r470_gpl/dev_router_series/target/linux/generic/patches-3.10.14/130-mips_remove_plat_dma_functions.patch using plaintext: patching file arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h Hunk #1 FAILED at 46. 1 out of 1 hunk FAILED -- saving rejects to file arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h.rej patching file arch/mips/include/asm/mach-generic/dma-coherence.h patching file arch/mips/include/asm/mach-ip27/dma-coherence.h patching file arch/mips/include/asm/mach-ip32/dma-coherence.h patching file arch/mips/include/asm/mach-jazz/dma-coherence.h patching file arch/mips/include/asm/mach-loongson/dma-coherence.h patching file arch/mips/include/asm/mach-powertv/dma-coherence.h patching file arch/mips/mm/dma-default.c Hunk #1 succeeded at 289 (offset -4 lines). Hunk #2 succeeded at 322 (offset -4 lines). Hunk #3 succeeded at 335 (offset -4 lines). Patch failed! Please fix /home/stormy/dev_router_series_r470_gpl/dev_router_series/target/linux/generic/patches-3.10.14/130-mips_remove_plat_dma_functions.patch!
Searched on openwrt.org, closest i could find is: https://sources.openwrt.org/linux-3.10.58.tar.xz, not sure how to switch to it, in .config found:
CONFIG_LINUX_3_10=y
but not sure that's relevant/useful..
Found in target/linux/mtk/Makefile:
LINUX_VERSION:=3.10.14
KERNEL_PATCHVER=3.10.14
One can try to change that, to pickup that 3.10.58 kernel from openwrt.org, however, that sould divert a bit too much from the path...
Long story short, question to all, specifically TP-Link, can you please lend a hand and help getting the GPL bits to compile to the firmware that got build from 2018 for v6?
This is not a "demand", this is a nice request, if one provides GPL source code, it would be nice if it actually worked... I definitely realize that things shift/change on the internet, that's understandable, so, here, lets fix that, pls someone find out which kernel to use in this case ?
Thanks.
Stormy.