Back to Stock Factory Firmware Linksys E4200 V2? OpenWrt FW to Linksys FW

That depends on which partition you booted from. The active rootfs will be mounted as ubi. The inactive one just sits there named rootfsX.

Ah you're a genius! I was able to downgrade with:

sysupgrade -F lede-17.01.4-kirkwood-linksys-viper-squashfs-sysupgrade.tar

So to implement that idea, here is what I did. Not having an actual E4200 I have no idea if it will work though.
You will need a Linux machine of course. This may be possible in the router if there is enough space in the RAM disk (be sure to rm intermediate files as you're done with them).

Download and unzip the Linksys 2.1.41 firmware and have just the .img file in a directory. That is where this saga begins.
For the true newbie, the "#" lines are comments, do not type them.

# Make a directory that will be at the root of the tar file.
mkdir sysupgrade-linksys-viper
# Change into that directory
cd sysupgrade-linksys-viper
# Create a "CONTROL" file specifying the model of the router, so sysupgrade likes it
echo "BOARD=linksys-viper" > CONTROL
# Pull the kernel code out of the factory firmware, which is one directory up (../)
dd if=../FW_E4200V2_2.1.41.164606.img of=kernel bs=1 count=2692560 
# and the rootfs
dd if=../FW_E4200V2_2.1.41.164606.img of=root bs=1 skip=2752512
# The tar directory tree is now complete, back out of it
cd ..
# and make the tar file
tar -cf factory.sysupgrade.tar sysupgrade-linksys-viper/

You now have a factory.sysupgrade.tar file ready to flash with sysupgrade. This probably won't even need -F but you should absolutely positively -n (do NOT save settings) or uncheck the save settings box on the GUI. Cramming OpenWrt config files into a Linksys filesystem would make no sense.

(the magic numbers above are 0x2915d0 = 2692560, which is the actual length of the kernel in that version, found using a hex editor to look for the zero padding at the end. We would like the kernel file to be smaller than the 0x2a0000 partition so that bad blocks can be accomodated. 2752512 is 0x2a0000 which is the space reserved for the kernel so it is how to get to the rootfs. dd does not accept hexadecimal numbers.)

1 Like

well, tried to do it on my end but only place that allowed me to place the full size of the img file was in the tmp folder but couldn't figure out how to get the location since the root is in the root folder and not the root of the device. yeah i don't have anything linux except this and figured i'd try this at least lol.
folder view below of what i'm talking about.

Use /tmp. It works just like a disk except it is in RAM so it is all lost when you reboot.

This you may want to copy the final tar file out to your PC before flashing and rebooting.

ok, so i use cd /tmp first then pretty much follow the rest?

Yes. You can erase the original img file once you have finished the dd process. That will make some space for tne tar file.

ok, yeah was thinking the same thing.
ok, stuck on this command now lol. dd if=../FW_E4200V2_2.1.41.164606.img of=kernel bs=1 count=2692560
trying to do change it to the tmp but yeah... just giving me no such file or directory. sorry for being sucky at this...

Dd with bs=1 is very slow, wait for it...

If you're not doing this in /tmp though you're going to overfill the flash...

no i have everything in the tmp folder as of now. img file is in tmp and the upgrade folder is in the tmp folder ../tmp/systemupgrade-linksys-viper
did edit my previous post with the no such file or directory. just stuck on the folder location thing.

What is your current folder? What do you get when you type

ls

and hit enter?

current folder i'm cd'ed in this is the path/directory.
/tmp/sysupgrade-linksys-viper
the img file is in temp and i'm cd in sysupgrade-linksys-viper

figured it'd be like this dd if=/tmp/FW_E4200V2_2.1.41.164606.img of=kernel bs=1 count=2692560
or
dd if=../tmp/FW_E4200V2_2.1.41.164606.img of=kernel bs=1 count=2692560
neither worked though lol

So what do you mean by you can't change directory to /tmp?

What do you mean didn't work? Was there an error message?

The second dd copies about 20MB one byte at a time. It took 25 seconds on my i7 desktop.

root@OpenWrt:/tmp/sysupgrade-linksys-viper# dd if=../FW_E4200V2_2.1.41.164606.im
g of=kernel bs=1 count=2692560
dd: can't open '../FW_E4200V2_2.1.41.164606.img': No such file or directory

what i'm stuck on. sorry again, literally know nothing linux...
only thing changed was the the tmp folder making trhe directory this way
/tmp/sysupgrade-linksys-viper
and added the tmp a couple different ways and says the same thing.

Where do you have the img file? In /tmp directly or in susupgrade-linksys-viber?

i have it in the /tmp folder

Could you please type the following and tell me what it gives you

ls /tmp/

root@OpenWrt:/tmp/sysupgrade-linksys-viper# ls /tmp/
FW_E4200v2_2.1.41.164606.img  luci-modulecache
TZ                            overlay
board.json                    resolv.conf
dhcp.leases                   resolv.conf.auto
dnsmasq.d                     run
etc                           shm
hosts                         state
lib                           sysinfo
lock                          sysupgrade-linksys-viper
log                           tmp
luci-indexcache

Here is the thing: in the img file name, the "v" letter is lowercase, while in the commands you type it's uppercase.

Change it to lowercase.