Skip to content

Instantly share code, notes, and snippets.

@tuyenld
Last active February 19, 2021 17:26
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuyenld/fa216b146a560bca1be7569262240043 to your computer and use it in GitHub Desktop.
Save tuyenld/fa216b146a560bca1be7569262240043 to your computer and use it in GitHub Desktop.
Openwrt

seit

how to revert to stock firmware WR840N v5

Hi all. I want to share some experience how to revert to stock firmware WR840N v5.

  • 1.Copy or wget original(stock) firmware to /tmp folder on LEDE
  • 2.Strip original image with dd cmd to remove bootloader part from image
  • 2.1. SSH to LEDE cd to /tmp and run:
dd if=originalfw.bin of=originalfw_striped.bin skip=257 bs=512
  • 3.Execute: sysupgrade originalfw_striped.bin
  • 4.After reboot I have stock firmware on my router

To return to original firmware (uninstall Gargoyle) - Tested with TP-Link WR741ND:

  • 1: Download latest firmware from tp-link (with "boot" in its name, ex.: "wr741nv4_en_3_16_6_up_boot(130524).bin").
  • 2: Download a app called "winscp517".
  • 3: Download a app called "putty".
  • 4: With "winscp", login (SCP mode) as:
hostname: 192.168.1.1 (or one you configured in connection - lan)
username: root
password: (if you have created in gargoyle or default "password")

and copy the firmware file to "tmp" folder

    1. Open PuTTY as SSH to 192.168.1.1 and perform the following commands:
cd tmp
dd if=TL-WR840Nv5_VN_0.9.1_3.16_up_boot[170517-rel46524].bin of=tplink.bin skip=257 bs=512 

mtd -r write /tmp/tplink.bin firmware
# and wait until flash complete!

Link download firmware

https://downloads.lede-project.org/snapshots/targets/ramips/mt76x8/openwrt-ramips-mt76x8-tl-wr840n-v5-squashfs-sysupgrade.bin

-sysupgrade.bin -> Use to upgrade TP-link whic is running OpenWRT
-factory.bin -> Use to upgrade TP-link which is running stock firmware to OpenWRT

Upgrade OpenWRT

robimarkoJan Just flash sysupgrade.bin for 840 v5 through LUCI web ui

Install WiFi driver manually

http://vonger.cn/?p=14366 emm. I thought it is clean copy mt7628.ko to your device. then insmod. copy mt7628an.dat to /etc/wireless/mt7628/mt7628an.dat(my bad, forget this file, I have updated the blog)

  • install iwpriv package.
  • use iwpriv set it up

Random WR840N v5 firmware

robimarko Those are full memory dumps. You can flash this TFTP image https://drive.google.com/file/d/0B1VOQQ-_EIXKejVNYU9Ja2hzRW8/view?usp=sharing

And then just sysupgrade to openwrt

https://forum.lede-project.org/t/support-for-tl-wr840n-es-ver-5-0-eu/6281/213 Try this:

  • Configure your ethernet interface with the ip 192.168.0.66 and mask 255.255.255.0
  • Rename the file lede-ramips-mt76x8-tl-wr840n-v5-squashfs-tftp-recovery.bin by tp_recovery.bin
  • I use Tftpd64, Settings, TFTP tab, in Base Directory it selects the place where the renamed file is.
  • Disconnect the router from the power supply, connect it to the PC through the cable.
  • Press the reset button and connect it to the power supply, when you see a tiny window in the Tftpd program, release the reset button, wait 1 or 2 minutes and that’s it.

pradorocchi Hi, sorry for the delay. Here folows the links,

A basic one: (No LuCI apps added, just SSH, LuCI interface and firewall):
Size: 3.19 MB
https://github.com/pradorocchi/OpenWrt-firmwares/blob/master/tl-wr840n-v5-squashfs-sysupgrade.bin?raw=true 35
A more complete one: (SSH + LuCI + uPNP + Bandwidth Monitor + QoS + SQM + AdBlocker + Firewall):
Size: 3.56 MB
https://github.com/pradorocchi/OpenWrt-firmwares/blob/master/tl-wr840n-v5-FULL-squashfs-sysupgrade.bin?raw=true 83

pradorocchi Mar 91 @bw4517, mac80211 drivers are updated on both images to the latest HEAD version of Feb 27, 2018 from https://github.com/openwrt/mt76

USB driver, PPP protocol and opkg were removed on the images to free space to put the Luci and other Apps.

pradorocchi this from TP-Link GUI

Flash factory image first than sysupgrade to this.

pradorocchi Yes, I´ll clarify. Don´t upgrade via the tp-link original firmware, it WILL brick for sure!

It will work by sysupgrading if you already have some OpenWRT image running on your router. Even if yours is without Luci, you can sysupgrade from it to mine and you will have Luci interface and the applications that are included in my images. No risk to brick your device this way!

[What I called before as a ‘factory image’ is a TFTP image.] . . Some background and techincal information:

I did not uploaded a TFTP image and the reasons why I didn´t. I didn´t uploaded by consideration about all the conversation above it on this thread, by reading all from the beginning I preferred to respect the same reasons that the the driver´s-author had, and he choose to not include a TFTP version of the image for those reasons exposed on this thread.
But he had to built one that works via TFTP, and it´s posted on this thread. I also have one that I made for me and it works via TFTP. My TFTP image includes Luci. (it´s the same as the sysupgrade images I posted, but a TFTP version of them). I always generate both.
That´s how I stared testing and trying experiments to reduce size and to fit applications, this way I started generating new and better sysupgrades images after it, easily testing each one.
If you want to TFTP, I advice you to read very well all considerations written on this thread about TFTP images on this router. At my understanding (I may be wrong and correct me if I am) at my understanding it seems that TFTP may not work on all 840Nv5 devices, even the devices being the same model number, but this is not a certain for sure. it seems it would need more people providing information about the 840Nv5 model (something with the bootloader) to be 100% risk-free TFTP images to this router. So there [may have or not have] a risk involved in TFTP not working with some 840Nv5 devices.
To protect users, it´s was decide here [before I join this thread] to better only generate syspgrade images for this model at this time. So I respected their decision and I did not uploaded my TFTP image. But as developers, we know the risks and can choose to TFTP.
About bricking: if you brick your device and the Leds keep blinking, no problem, you can easily unbrick it. It means the bootloader is working well and you are safe to unbrick it. I bricked mine N times during tests, and reverted always.
– End of the background talk and thanks for your patience – 😉

. . . The options are:
if you are already running any version of OpenWRT on your device, go ahead and sysupgrade to mine with Luci, it will work, no risk involved.
But if you are using the TP-Link original firmware, you can first use the OpenWrt TFTP image posted on this thead, and from that image you can sysupgrade to the image containing lucy that I posted.
Ask me to upload a TFP version of my image that contains Luci.
The risks of having trouble exists for options 2 and 3 and are the same risks (as discussed above on this thread before I made part of it)
There´s no risk if you are already running openwrt on your device, simply sysupgrade to the image I uploaded with Luci, you can revert back to yours or forward again any times if you need to compare performance or signal ranges (as the MT76 driver is newer on my image) .**
Sorry for the delay in answering your doubts, weekends are better for me to answer. Sometimes I explain too much, but better excess of information than lack of it. 😉
I can quickly answer during this weekend if we need to expand this conversation.

Live USB

# Ref: https://we.riseup.net/lackof/openwrt-on-x86-64
# Ref: https://openwrt.org/docs/guide-user/installation/openwrt_x86
# Ref: https://blog.mapstrata.com/post/lede_x86_build/
#
$ wget https://downloads.openwrt.org/releases/17.01.4/targets/x86/64/lede-17.01.4-x86-64-combined-ext4.img.gz
$ lsblk  # Lít all USB attacked to PC
$ gunzip lede-17.01.4-x86-64-combined-ext4.img.gz

# It will create TWO partion (boot + root file system)
$ sudo dd if=lede-17.01.4-x86-64-combined-ext4.img of=/dev/sda  # sda is USB DISK list above lsblk command

IPv6

network-ipv6

opkg list | grep -i odhcp6c

Check version

cat /etc/openwrt_release

Install package

opkg list-installed | grep "libustream"

opkg install /tmp/hiawatha_7.7-2_ar71xx.ipk

Some type of image

For most routers, the only difference between sysupgrade and factory image is just the necessary header & packaging, so that the OEM firmware's flashing routine will accept the Openwrt/LEDE image.

compressed-read-only partition (squashfs)

The -factory.bin - images are for the first installation. The -sysupgrade.bin - images are for the updating existing OpenWrt installations. - For most routers, you can't flash a sysupgrade image using the OEM firmware.

  1. Login to SSH console/terminal and see the output of df -h. The overlayfs should be mounted as /. See exmaple:
tmpfs                    14472        68     14404   0% /tmp
/dev/mtdblock3         1909456     11536   1799260   1% /overlay
overlayfs:/overlay        1088       984       104  90% /

Error log

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 2.3M      2.3M         0 100% /rom
tmpfs                    29.5M    532.0K     29.0M   2% /tmp
tmpfs                    29.5M     56.0K     29.5M   0% /tmp/root
overlayfs:/tmp/root      29.5M     56.0K     29.5M   0% /
tmpfs                   512.0K         0    512.0K   0% /dev
root@OpenWrt:~# 

Check

Initrd not found or empty - disabling initrd

 Crashlog allocated RAM at address 0x3f00000
workingset: timestamp_bits=30 max_order=14 bucket_order=0
squashfs: version 4.0 (2009/01/31) Phillip Lougher
jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.


 fixed-partitions partitions found on MTD device spi0.0
Creating 3 MTD partitions on "spi0.0":
0x000000000000-0x000000020000 : "boot"
0x000000020000-0x0000003f0000 : "firmware"
2 tplink-fw partitions found on MTD device firmware
0x000000020000-0x00000017d048 : "kernel"
0x00000017d048-0x0000003f0000 : "rootfs"
mtd: device 3 (rootfs) set to be root filesystem
1 squashfs-split partitions found on MTD device rootfs
0x0000003b0000-0x0000003f0000 : "rootfs_data"
0x0000003f0000-0x000000400000 : "factory"

m25p80 spi0.0: s25fl064k (8192 Kbytes)

VFS: Mounted root (squashfs filesystem) readonly on device 31:3.
Freeing unused kernel memory: 208K
This architecture does not have kernel memory protection.
init: Console is alive
init: - watchdog -
random: fast init done
kmodloader: loading kernel modules from /etc/modules-boot.d/*
kmodloader: done loading kernel modules from /etc/modules-boot.d/*
init: - preinit -
rt3050-esw 10110000.esw: link changed 0x00
random: procd: uninitialized urandom read (4 bytes read)
jffs2: Too few erase blocks (4)  --> Your image is probably too big, leaving not enough space for jffs2.
mount_root: failed to mount -t jffs2 /dev/mtdblock4 /tmp/overlay: Invalid argument
mount_root: overlay filesystem has not been fully initialized yet
mount_root: switching to jffs2 overlay
mount_root: switching to jffs2 failed - fallback to ramoverlay
urandom-seed: Seed file not found (/etc/urandom.seed)

  1. there is not enough free space on the /overlay partition, it may not get mounted, or may get mounted read-only. Then you may have tmpfs mounted for /, and all settings go just to ramdisk.

  2. Check log by command:

logread 

Factory Reset

  1. Soft factory reset
umount /overlay && firstboot && reboot
  1. Hard factory reset
# erase and reformat the whole jffs2 partition and create it again
umount /overlay && jffs2reset && reboot
  1. (Quick overview of OpenWrt's internals)[https://openwrt.org/docs/guide-developer/overview]
    • How a package is compiled
    • Package feeds
    • Package Versions
    • Repeatable builds

=================================

  1. Upgrade from factory image via TFTP

TFTP image: lede-ramips-mt76x8-tl-wr840n-v5-squashfs-tftp-recovery.bin -> tp_recovery.bin https://drive.google.com/file/d/0B1VOQQ-_EIXKejVNYU9Ja2hzRW8/view?usp=sharing

2.Configure your ethernet interface with the: ip 192.168.0.66 mask 255.255.255.0

  1. Run TFTP server

  2. Press the reset button and connect it to the power supply, when you see a tiny window in the Tftpd program, release the reset button, wait 1 or 2 minutes and that’s it

  3. Use sysupgrade to upgrade OpenWRT root@LEDE:/tmp# sysupgrade tl-wr840n-v5-FULL-squashfs-sysupgrade.bin

@tuyenld
Copy link
Author

tuyenld commented Jan 19, 2019

@CaptainCustardMC
Copy link

Thank you so much for saving my router.

@wyatt1989
Copy link

good evening i have the WR840N v5 i had a working open wrt on this but tryed loading the original back it was a flop it kept doing the flashing light thing lol i now have lede on and the flashing light has stoped but i have no idea were to go from here to try and load the original firm back i can log into lede by using putty but again after logging with root completly lost lol any help would be a life saver

@wyatt1989
Copy link

i have come right by learning sysupgrade commands thank you :)

@aldrin06gemini
Copy link

I've already flash the TFTP image: lede-ramips-mt76x8-tl-wr840n-v5-squashfs-tftp-recovery.bin
My TP-Link WR840N v5 has stayed on Green LED light and no longer blinks unlike before so I guess I did the TFTP flash correctly.

But I don't have to go to this step.. .

Use sysupgrade to upgrade OpenWRT root@LEDE:/tmp# sysupgrade tl-wr840n-v5-FULL-squashfs-sysupgrade.bin

Can someone tell me how to do it, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment