Porting Firmware to TP-Link Archer C20 v5

but thanks for providing the image tho, at least I can still boot the router with snapshot :smiley:

Sounds great :+1::+1::+1::+1::+1:

Hello, can someone compile a list of commands I needed to upload files using tftp from serial connection? My router is completely bricked and does not even turned on anyway.

Can I assume that this command from v4 is the same as the v5 one?:

tftp 0x80060000 tp_recovery.bin;erase tplink 0x20000 0x7a0000;cp.b 0x80080000 0x20000 0x7a0000

You just need to put the tp_recovery.bin file in the /tftp folder in a linux system with tftp protocol installed and statically assign 192.168.0.66 as its IP address.
Press the reset button while starting the router then it will boot from the tftp server

I am having the same issue . The device works for some time then after a random number of reboots the device's overlay data is reverted to a fresh flash one .
As far as i can tell when we change a configuration . JFFS2 creates a new node and changes the value pointing to the new node .
There is also a cleaning mechanism in the background .
https://bootlin.com/blog/managing-flash-storage-with-linux/

I cannot begin to start troubleshooting this any one knows where to start ?

this happens after error

[ 353.498856] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c10d0
[ 353.506850] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c10d0
[ 353.514858] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c5ac0
[ 353.522868] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c10d0
[ 353.530829] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c10d0
[ 353.538811] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c5ac0
[ 353.546802] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c5ac0
[ 353.554811] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c10d0
[ 353.562821] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c5ac0
[ 353.570782] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c5ac0
[ 353.578766] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c10d0
[ 353.586780] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c10d0
[ 353.594791] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c5ac0
[ 353.602803] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c10d0
[ 353.610764] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c10d0
[ 353.618745] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c5ac0
[ 353.626737] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c5ac0
[ 353.634746] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c10d0
[ 353.642764] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c5ac0
[ 353.650727] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c5ac0
[ 353.658709] jffs2: Node CRC ffffffff != calculated CRC f09e7845 for node at 000c1

You mean upload via tftp seria version 18.06.5? or like tp_recovery.bin ?my problem is tha upload your tp_recovery.bin load to my router a snapshot without luci i try to load luci but i have the same error with cosmowave

root@OpenWrt:~# opkg update
Downloading http://downloads.openwrt.org/snapshots/targets/ramips/mt76x8/package                                                                                                                                                             s/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_core
Downloading http://downloads.openwrt.org/snapshots/targets/ramips/mt76x8/package                                                                                                                                                             s/Packages.sig
Signature check passed.
Downloading http://downloads.openwrt.org/snapshots/targets/ramips/mt76x8/kmods/4                                                                                                                                                             .14.171-1-6ea698da0e19b76bff9e967224d4fea6/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_kmods
Downloading http://downloads.openwrt.org/snapshots/targets/ramips/mt76x8/kmods/4                                                                                                                                                             .14.171-1-6ea698da0e19b76bff9e967224d4fea6/Packages.sig
Signature check passed.
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/base/Pac                                                                                                                                                             kages.gz
Updated list of available packages in /var/opkg-lists/openwrt_base
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/base/Pac                                                                                                                                                             kages.sig
Signature check passed.
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/luci/Pac                                                                                                                                                             kages.gz
Updated list of available packages in /var/opkg-lists/openwrt_luci
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/luci/Pac                                                                                                                                                             kages.sig
Signature check passed.
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/packages                                                                                                                                                             /Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_packages
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/packages                                                                                                                                                             /Packages.sig
Signature check passed.
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/routing/                                                                                                                                                             Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_routing
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/routing/                                                                                                                                                             Packages.sig
Signature check passed.
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/telephon                                                                                                                                                             y/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_telephony
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/telephon                                                                                                                                                             y/Packages.sig
Signature check passed.
root@OpenWrt:~# opkg install luci
Installing luci (git-20.076.40261-12e1d94-1) to root...
```Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/luci/luc                                                                                                                                                             i_git-20.076.40261-12e1d94-1_all.ipk
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for luci:
 *      kernel (= 4.14.172-1-6ea698da0e19b76bff9e967224d4fea6)
 * opkg_install_cmd: Cannot install package luci.

and i stuk with snapson ,no luci, only ssh 
suggest anything?

Yeah I uploaded version 18.06.5 via tftp and it works fine You can find it here

On flashing stock fw:

tl;dr: To flash the device with the stock fw,

printf \\xef\\xcd\\xab\\x89 > /dev/mtdblock8

This will activate web fw recovery on next boot. Upload TP-Link fw via the web interface. The server address will be 192.168.0.1.

Detail:
using sysupgrade to flash the device back to the stock fw wouldn't work for some reason. You'll brick the device and you'll need the serial console to run httpd on the first u-boot.

The first partition of the spi flash contains the boot loader with web server for firmware recovery. The boot loader checks if 4 bytes at the flash address 0x007e0000 is ef cd ab 89. Normally, this section of the flash memory is left untouched(00 00 00 00), so the first boot loader loads the second boot loader, which kickstarts the kernel. If the value is indeed ef cd ab 89, the boot loader assumes that the flashing was not successful and runs httpd program, which allows you to upload firmware to recover the device. You can basically upload any firmware, be it a stock fw or an OpenWrt one.

I figured this out by observing serial output of the stock fw when commencing fw upgrade. one line of the output is:

spiflash_ioctl_write, Write to 0x007e0000 length 0x10000, ret 0, retlen 0x10000

I cut the power to the device before it started to write the uploaded fw and I inspected the contents of spi flash memory by using spi command on u-boot terminal.

The section of the flash memory is exposed as /dev/mtdblock8 on OpenWrt. It starts with a bunch of zeros for the first bytes and then 0xff for the rest of the partition.

I thought someone without access to the serial console would appreciate this... Or you can just create a tftp-recovery image with a stock fw.

My 19.07.2 build using mt76x8 config:

i am back to original stock firmware now thanks to dxtd
how to install openwrt from beginning?

and i have error 4503 when installing fro tplink web interface and boot loop when tftp

fw version 0.9.1 4.16 v0001.0 Build 181127 Rel.56357n(4555) europe
Hardware version: Archer C20 v5 00000005

Thanks, the tftp image is more stable than sysupgrade (for me), I don't know why when I'm using sysupgrade version and then create some static leases for my device, all the wifi is turned off and I cannot turn it on. but the tftp version is stable and no bugs at all.

Just rename your image to tp_recovery.bin upload it via tftp to your router then after upload successfully close tftp and let the router restarts itself
I suggest you to use build version 18.06.5 instead today I'm going to test the build version 19.07.2 that dxdt uploaded and let you know! I hope this version works flawlessly :wink::pray:


When I wanted to upgrade my router via (openwrt-19.07.2-ramips-mt76x8-tplink_archer-c20-v5-squashfs-sysupgrade) I got this message then updated it by force but everything was OK :+1:


Also WiFi is OK with both bands :+1: :pray:

ok i did it
1 i used tp_link_recovery from this linkhttps://github.com/Linaro1985/openwrt/releases/tag/tplink_archer_c20v5
2 now i have snapshot but i didn't make it work with any version 18.06 allways boot loop, i try this snapshot from this link https://github.com/Linaro1985/openwrt/releases/tag/191219
3 try to install 18.06 but the same boot loop and i try the new 19.07 from dxdt https://github.com/ashegoulding/openwrt/releases/tag/v19.07.2-tl_archer_c20v5 and finaly i have with 19.07

thanks *From Greece) in advanse for all yours help!!!

Sounds Good
When you download the rar file there are 3 images just rename (openwrt-19.07.2-ramips-mt76x8-tplink_archer-c20-v5-squashfs-tftp-recovery) to tp_recovery.bin then .......
after that update your router with (openwrt-19.07.2-ramips-mt76x8-tplink_archer-c20-v5-squashfs-sysupgrade)
Good Luck my friend :pray: :+1:

When in doubt, TFTP.

That might have had something to do with the stock fw. I've never tested the factory binary myself. Sorry. The web interface might not have been able to handle the factory firmware I built. To be fair, sysupgrade can't handle stock fw, either. I'm not saying these two problems are related. I'm just saying that I wouldn't be surprised if you can't flash OpenWrt with stock web interface.

I'm speculating a lot here, but if your device is acting up after flashing via stock web interface, my money is on flashing failure. The device could still run with "half flashed" firmware. 4 of the partitions are ROM, one of which being "radio". OpenWrt would be able to boot up without those partitions. This might be the explanation for radio related problems.

but the problem here, I flashed the sysupgrade after I flashed openwrt via tftp.

My mistake:


I don't know why I took out "archer" part. As you already know, this is just a safety catch. The fw should work just fine.

All in all, I take it that OpenWrt has abandoned Archer C20 v5 because there isn't an easy way to ship the image with the second boot loader. Building our own second u-boot would be an option, but it's too much work. So, we're left with the stock u-boot loader. Technically, I shouldn't be distributing my build since it contains the stock u-boot loader. It defeats the purpose of OpenWrt from the very beginning - transparency :slight_smile:. I'm not violating any law, though. Last time I checked, u-boot is licenced with GPLv2. Maybe I can ask them for the source code of the second boot loader.

I just found that .dts file for Archer C20 v5 was already added to master branch. I assumed that they didn't merge @Linaro's commit because C20 v5 model was not on the menuconfig. I was wrong. They didn't expose the model because of the aforementioned issue. I would've approached this differently if I had known this. Apologies, again. I should've made a series of patches to these files, not commits:

	modified:   target/linux/ramips/base-files/etc/board.d/01_leds
	modified:   target/linux/ramips/base-files/etc/board.d/02_network
	modified:   target/linux/ramips/image/mt76x8.mk

--

My hardware died on me. Might have been my bad soldering skill. Or I might have flashed it too many times testing it. I have 2 C20 v5's and the other one is for personal use. I don't wanna risk losing WiFi in my house, so I won't use it for OpenWrt until I made sure of everything. Given the COVID-19 situation, I don't think I'll get hold of another C20 v5 any time soon so don't get too excited for now.

:+1:

Edit:
Turns out, we do have the source code.

https://www.tp-link.com/us/support/gpl-code/

I might be able to add a build step for the second boot loader.