Original firmware overwrites OpenWrt every reboot

I have the exact opposite problem of what others have: I do not want the original firmware back:

My system ( Linksys EA6350 v4 ) restores the original firmware at every reboot. So I assume the original firmware is stored somewhere else and started checking things:

I installed fdisk and did a fdisk -l | grep dev which showed me that there were 12 "Disks":

  • 11 /dev/mtdblockX (with X the numbers from 0 to 10)
  • 1 /dev/ubiblock0_0

Running mount | grep ^\/dev showed me 2 device-files:

/dev/root on /rom type squashfs (ro,relatime)
/dev/ubi0_1 on /overlay type ubifs (rw,noatime,assert=read-only,ubi=0,vol=1)

So I assumed that all firmware, OpenWrt and the original, is stored "somewhere" on /dev/ubiSOMETHING and ran ls /dev/ubi* which gives me /dev/ubi0 /dev/ubi0_0 /dev/ubi0_1 /dev/ubi_ctrl /dev/ubiblock0_0 .

This makes me assume that dd if=/dev/ubiSOMETHING of=/dev/ubiSOMETHING-ELSE can be used to make sure that OpenWrt is also written on the backup and it will survive reboots.

But... There are 3 problems:

  • I have no idea what SOMETHING and SOMETHING-ELSE should be
  • Using dd with a mounted partition as input "feels" like it will fail horribly
  • Maybe my "ubi-assumption" is wrong
1 Like

I had a similar problem with another device and I solved this way:

  1. Install OpenWRT factory image on top of stock firmware. Device reboots into OpenWRT
  2. Right after the first OpenWRT boot, install OpenWRT sysupgrade image.

Step 2 above did the trick. After this step OpenWRT remained active after reboot.

The initramfs image is ram-based and does not overwrite the stock fw. It's only meant to get you off stock and into OpenWrt so you can test functionality and/or flash the sysupgrade image which is the permanent image that overwrites stock.

It is likely a dual-boot device, like many newer Linksys devices.

The OEM firmware does not overwrite OpenWrt, but is all the time in the other partition. When booting your new OpenWrt fails, the bootloader reverts to the fallback firmware (the other partition, your old OEM firmware).

Search for OpenWrt Linksys dual-boot

Do not attempt to overwrite the OEM firmware yet. It serves now as the fallback, as your OpenWrt fails. Once you boot into OpenWrt, the following next sysupgrade then overwrites it.

1 Like

I also read this somewhere, didn't help...

Possibly here...

That's the same as what dsouza set, it didn't help

Possibly an issue with the env settings not updated and still pointing at the previous install?

1 Like

That was in response to where you "read this somewhere"...

Wait, correction: For some extremely strange reason now it seems to work. In case it helps someone else this is what I did (Although I certainly hope that not all steps were necessary :wink:)

  1. Flash the OpenWrt factory → System will reboot & it will still run linksys firmware
  2. Flash the OpenWrt factory → System will reboot & it will still run linksys firmware
  3. Flash the OpenWrt factory → System will reboot & it will still run linksys firmware
  4. Flash the newest firmware of linksys itself → System will reboot & it will run that new version of the linksys firmware
  5. Flash the OpenWrt factory → System will reboot into OpenWrt
  6. Configure a lot, reboot → System will run Linksys firmware again
  7. Flash the OpenWrt factory → System will reboot into OpenWrt
  8. Flash the OpenWrt sysupgrade→ System will reboot into linksys
  9. Flash the OpenWrt factory → System will reboot into OpenWrt
  10. Flash the OpenWrt sysupgrade→ System will reboot into linksys
  11. Flash the OpenWrt factury→ System will reboot into OpenWrt
  12. Accept that it will always go back into Linksys, configure OpenWrt, make a backup of the config and try to remember never to reboot
  13. Play around some more in the config, notice that i din't like my new configuration after all, upload the backup again while forgetting that it will reboot into linksys
  14. Notice that somehow it magically boots into OpenWrt :grinning:

I just did another reboot, just to make sure → Linksys again :sleepy:

Take a look at this device page. The git commit for EA6350v4 is similar to the EA7300v2.

It describes a 2-step workaround to stop it reverting back to booting Linksys firmware on EA7300 v2
https://openwrt.org/toh/linksys/ea7300_v2#installation
I wonder if one or both steps will work for EA6350 v4 ?

I'm also in the process of creating EA6350v4 device page....
https://openwrt.org/toh/linksys/ea6350_v4

2 Likes

That trick did it. (I tried 3 reboots to make sure).
So, this it what you should do:

  1. Add the following to /etc/rc.local (before the exit 0) :

/rom/sbin/mtd unlock s_env
/rom/sbin/mtd erase s_env

  1. Run the 2 commands

Result: From now on all reboots will bring you back to openwrt.

Useful to know:
If you do a couple of reboots and erase these 2 commands in rc.local again, then your current OpenWrt configuration will become the "backup" config.
If you ever mess something up you will be able to reboot into your old openwrt config.

3 Likes

Hi.
I read the thread and was about to propose this trick. I'm the one who wrote this in the doc. It was suggested by another user a few months ago, in another thread.

1 Like

@garo and @badulesia I will update the device wiki page.

The device page for the EA7300v2 also refers to performing a 'hard reset' three times to switch to the other partition to boot linksys OEM firmware. I presume this works.

For other linksys routers such as EA6350v3, this method is known to work for switching between partitions.

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.

I wonder can both methods be used on EA6350v4 to choose between booting OpenWrt or Linksys, without the need to reinstall OpenWrt from Linksys GUI?

Also, does anyone have any experience with 'upgrading' OpenWrt on the v4. Will squashfs-sysupgrade image try to write to the partition containing the Linksys OEM fw, or to its existing OpenWrt partition?

All these devices are very close, use the same architecture (mt7621), and probably have common software, at least for the boot (I mean in Linksys software). So any trick for one device is to experiment for another.

Default behavior with Linksys devices dual partitioned is that flashing is done on the "other" partition. So yes it'll likely write the Linksys partition.

On Linksys devices, I never perform upgrading. I always keep the original Linksys software in the "other" partition as a backup. Performing an upgrading will erase it. I prefer to boot on the Linksys software, than perfom a flash with an OpenWrt factory image. It will replace the actual OpenWrt partition. After boot, I restore the settings, that's it.

I read from @garu earlier post and elsewhere, tried to flash EA6350 v4 twice by first using the factory image then followed by sysupgrade image. This double step process surely should have overwritten both partitions?

But v4 eventually reverted to booting from stock Linksys.....

That's why I'm wondering, did the v4 fail to execute the sysupgrade, or did it write it to the existing partition where OpenWrt existed?

Most likely.

Keep in mind that I have never performed a sysupgrade, because I do want to keep the Linksys firmware.
Here's my experience in the matter with a EA7300v2. Let's call the partitions A and B.

At first start, A is booted with Linksys. You flash OpenWrt, on B. But somehow, Linksys install procedure won't declare OpenWrt as valid. The support for these devices is rather young. My guess is that the OpenWrt image doesn't fit the Linksys GUI flash procedure. The flash is done, but not validated to be booted. Thus A is still the valid boot, with Linksys. That is what @garo describes as "original firmware overwrites OpenWrt".

You must first flash Linksys over itself, on B. It will be declare as valid, and it boots from B. Than you flash OpenWrt, on A. It will boot and work, but somehow the boot will be declared as not valid, and a fail bootcounter is increased. After three such boots, the boot process will declare A as non valid and switch to B with Linksys.

The goal of the rc.local tweak is to erase the bootcounter. So at each OpenWrt boot, the boot will think the fail bootcounter is 1.

You can still willingly boot to B using the physical switch procedure, or Luci-app-advancedreboot.

@garo earlier posts suggests he tried to apply factory and sysupgrade and yet it still reverted to linksys stock firmware.

Flash the OpenWrt factory → System will reboot into OpenWrt
Flash the OpenWrt sysupgrade→ System will reboot into linksys

Flash the OpenWrt factory → System will reboot into OpenWrt
Flash the OpenWrt sysupgrade→ System will reboot into linksys

So what did sysupgrade actually do?

Food for thought.....

  • from which partition did he started to flash ?
  • remember that I have willingly never done a sysupgrade.