Linksys EA8300 revert to stock

Alright so I am trying to revert my firmware back to stock firmware on my Linksys ea8300. I followed the wiki on https://openwrt.org/toh/linksys/linksys_ea8300 and specifically these instructions:

OEM Firmware

FIRMWARE (as of 2019-02-05) Ver. 1.1.4.191539 Latest Date: 11/8/2018 Download 49.0 MB

Release Notes

GPL distribution http://downloads.linksys.com/downloads/gpl/EA8300_v1.1.3.184925_GPL.tar.gz includes linux-3.4.103.tar.xz

Boot log for “firmware version 1.1.3.184925” indicates 3.14.77

Revert to Stock
To revert to stock, the OEM firmware should be available on the device. For the purposes of this description, it is at /tmp/FW_EA8300_1.1.4.191539_prod.img

Realize that any time you are writing to flash using low-level commands, there is the chance of unrecoverable corruption. Make sure that you understand what these commands are doing and ensure that the power to the device is not interruptible.

The first step is to determine which firmware you wish to flash. The currently mounted OpenWrt firmware can usually be determined by

root@test:~# cat /sys/devices/virtual/ubi/ubi0/mtd_num
13
11 indicates that kernel is mounted, 13, that alt_kernel is mounted.

In most cases people should overwrite the “other” firmware.

Erase the other firmware partition and flash the firmware

mtd erase kernel
mtd write /tmp/FW_EA8300_1.1.4.191539_prod.img kernel
After confirming success, you can set the next-boot partition with

fw_setenv boot_part 1 # to set for kernel
fw_setenv boot_part 2 # to set for alt_kernel

Everything works fine until I get to the last step where you set the next-boot partition with fw_setenv. I get the following error:

root@OpenWrt:~# fw_setenv boot_part 1
Cannot parse config file '/etc/fw_env.config': Invalid argument
Error: environment not initialized

I am new to OpenWrt but certainly not Linux, however, I'm not really sure why I am getting this error. Any help would be GREATLY appreciated!!!

BTW: The router is still on, I haven't rebooted it yet.

Is there an output if you enter:

cat /etc/fw_env.config

What is the output of:

./fw_printenv

I don't own this device but the part

In most cases people should overwrite the “other” firmware.

Erase the other firmware partition and flash the firmware.
mtd erase kernel

looks to me there is sth. missing in the wiki if there are 2 kernel partitions.

This is what I get when I try to use cat to read the file:

root@OpenWrt:/etc# cat /etc/fw_env.config 
cat: read error: I/O error

But I can use cat to read other files.

Then I ran a find command which came back with three matches for fw_printenv:

root@OpenWrt:~# find / -iname "*fw_printenv*"
/rom/usr/sbin/fw_printenv
/tmp/lock/fw_printenv.lock
/usr/sbin/fw_printenv

Here's what happens when I try to execute each of them:

root@OpenWrt:/rom/usr/sbin# ./fw_printenv 
Cannot parse config file '/etc/fw_env.config': Invalid argument
root@OpenWrt:/tmp/lock# ./fw_printenv.lock 
-ash: ./fw_printenv.lock: Permission denied
root@OpenWrt:/usr/sbin# ./fw_printenv 
Cannot parse config file '/etc/fw_env.config': Invalid argument

(there was also a fw_setenv in the same folder as the latter and I tried it as well)

root@OpenWrt:/usr/sbin# ./fw_setenv boot_part 1
Cannot parse config file '/etc/fw_env.config': Invalid argument
Error: environment not initialized

And so you think there is a portion missing in the wiki? Any ideas on how this might be able to be remedied ? Also, thank you for the reply!

I don't have really a clue about. I was messing around with flash devices like 10 years ago. Most knowledge is gone because I don't use this stuff on a "daily" base. So I might be wrong about!

Normally if you write to mtd you would do it to a given block/partition according to the flash layout which you can see on wiki page for your device. I don't know if mtd is able to determine parition 11 and/or 13 for writing the kernel file.

What is the output of:

cat /sys/devices/virtual/ubi/ubi0/mtd_num

My guess is you have to write to alt_kernel with:

mtd write /tmp/FW_EA8300_1.1.4.191539_prod.img alt_kernel

Because of this:

11 indicates that kernel is mounted, 13, that alt_kernel is mounted.
In most cases people should overwrite the “other” firmware.

For what you would determine this parameter first otherwise.
To me it looks like you have deleted/overwritten your running system partition. That's why you cannot find fw_env.config (which is an OpenWrt config file). I would not turn off the router now if you don't have access via serial console.

My advise would be to try to download a proper OpenWrt image for your device and (re-)flash this via console (if possible) or extract and write it via mtd. And start from scratch again.

But I'm not an expert. So be aware. Maybe another one is knowing more about it.

Alright thanks for the help. The output you requested is :

root@OpenWrt:~# cat /sys/devices/virtual/ubi/ubi0/mtd_num
11

Maybe I confused this. Does the wiki mean that if 11 is running you have to flash to 13 ? And yeah I think i'm going to reflash openwrt onto the 11 kernel. Uhhg so confusing.

Oh also, any idea of a good guide on how to reflash openwrt via ssh on the ea8300?

Y, that is that was confusing me also. The wiki is not clear about which kernel partition has to be flashed or is/will be activated as default.

In most cases people should overwrite the “other” firmware.

I would understand it like if "11" is the output (of cat /sys/devices/virtual/ubi/ubi0/mtd_num) you should write to 13 aka alt_kernel and the exectue fw_setenv boot_part 2.

For this situation there is probably no guide available.

First check if the command sysupgrade is available by just executing

sysupgrade

in console.

If it is available then get the url* pointing to the proper OpenWrt image file. Change directory to "tmp" with

cd /tmp

Now load the image to your device with:

wget url*

You are ready to flash with:

sysupgrade -v filename

The EA8300 uses 2 different partitions. If you only flashed OpenWRT one time, the original firmware is on the other partition.

Would that mean that a simple:

fw_setenv boot_part 2

in OpenWrt console and a reboot would be enough to get back to stock firmware?

(Beside that the threadstart has overwritten OpenWrt now (I guess so). So he/she cannot execute the command anymore if kernel is overwritten.)

First do this to see what is your active partition:
fw_printenv boot_part

The issue I am having here is that when I try to run fw_printenv boot_part I get this:

root@OpenWrt:~# fw_printenv boot_part
Cannot parse config file '/etc/fw_env.config': Invalid argument

Another thing is that I tried to revert to stock firmware with MTD on the wiki and I flashed the mounted kernel 11, so this is not the alt_kernel so the stock firmware is still probably on the alt_kernel. I just can't change the boot partition because when I try I get the above error. I'm not sure if it will just fail over to the alt_kernel if the main kernel fails. The wiki seems to indicate that.

I'm not sure if this is working or end up in a corrupted/mismatched kernel image on the flash partition.

But you don't have much options.

  • reboot and hope for a failover to other partition.
  • reboot and hope the image got written correctly with mtd tool.
  • trying the sysupgrade approach from above (if sysupgrade/wget is still working) and reboot.
  • connect your device to an USB-TO-TTL adapter and access via serial console to "repair".

Hey guys, I got it working. I flashed OpenWRT firmware back to the "kernel' with mtd write. I can get into the web interface now. Damn that was gut wrenching for a while. Anyways thank you for the help!!!

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

Here's what I did to solve the problem.
First I ssh'd into the router.

Then I had to find which kernel was running because this router is a dual firmware device and to do that I ran:

root@test:~# cat /sys/devices/virtual/ubi/ubi0/mtd_num 

The output was 11. There could have been two output options here. 11 or 13. 11 Is for the primary kernel and 13 if for the alt_kernel. So in my case 11 means that the primary kernel was running.

Then I used mtd to erase the primary kernel and flash the OpenWRT firmware in its place.

mtd erase kernel
mtd write /tmp/openwrt-19.07.5-ipq40xx-generic-linksys_ea8300-squashfs-factory.bin_prod.img kernel

EDIT: Also I don't want to forget to mention I used scp to transfer the firmware to the device. You can also use wget.

Now if you had 13 as output from the cat command above then in place of 'kernel' you would use 'alt_kernel'. After that I rebooted the router by running 'reboot' and the device booted up fine.

There are also instructions that I found gave me the confidence to reboot after the flash:

If the device fails to boot after install or upgrade:

1. Switch On and wait 15 seconds

2. Switch Off and wait 10 seconds

3. Repeat steps 1 and 2, three times, then go to 4.

4. U-boot will switch to booting the previous working firmware - you should be able to access your router on LAN.

The above method can be used to toggle between the two firmware.

That will allow you to switch between the two firmware installed on the device in case one fails to boot.

Thanks again for the help guys!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.