Thursday, February 4, 2016

HowTo: Keep the factory image from booting after you’ve upgraded to DD-WRT

So you’ve upgraded your WRT1900AC router (or other similarly designed router) to DD-WRT and it’s humming along fine, or maybe you’ve done the upgrade and then followed it up with a 30-30-30 reset and suddenly you’re back to the original Linksys Firmware!  Gah, lousy downgrading $#!+!

What’s happening

Linksys routers used to be a popular choice for running DD-WRT back in the days when the vendors were far less happy with you replacing their buggy, insecure firmware with something open and customizable.  Rather than taking the approach of keeping you from replacing their firmware, lately they’ve gone the route of keeping you from breaking your device should you choose to hack around with DD-WRT.

They used to do this by providing a “failsafe” mode that provided an extremely limited, but “possible to fix” mode that would leave you carefully timing a TFTP upload during the first two seconds of boot (this still exists, I believe).  Many-a-panicked afternoons were spent in this home praying my $150 router didn’t just turn into a doorstop because of this.  They’ve gotten way better since.  Your flash memory is split into two partitions, only one of which has the currently running firmare.  The other has the last version of the firmware that you successfully installed.  When you upgrade, it replaces the unused partition and changes an NVRAM value to tell the bootloader to use the other partition for subsequent boots.

Hopefully no more TFTP adventures, but it comes at a small cost.  Should something bad enough happen, or should you do a “factory reset”, you’re likely going to end up booting the other partition – the one you were trying to get away from.

Making the install a little more Undo Proof

If you’ve followed the installation guides to the letter, you probably did what I did.  Upgraded, reboted and then did a 30-30-30 factory reset.  I’m not sure if it’s the timing of *when* you do the 30-30-30 or just doing the 30-30-30 that causes it, but the boot partition ends up flipping right back to the original firmware.

I think I ended up doing the 30-30-30 during the boot-up process into the new firmware which, I’m guessing, caused the boot to fail and reverted me back to the last version.  I’m honestly not sure, but after that happened, I simply skipped the 30-30-30 until I finished the next step.

Install DD-WRT … Twice

Yup.  Simply installing one SVN version out of date, then the latest SVN version (you might even be able to install the latest on both, but I didn’t try it), ensured that I had both partitions on DD-WRT.  After that, I did a factory reset through the web interface (which didn’t take me to the backup partition, incidentally) and I was ready to go with a fresh router that can’t fallback to the factory image.

This doesn’t solve everything, unfortunately, because there are aparently other reasons it may decide to toss you into the backup partition.  In my case, it looks like a failed boot might have caused it to revert the second and third times.  But once you have DD-WRT installed, you can drop to SSH and run nvram get bootpartition, and simply set it to the other one via nvram set bootpartition.  That’s a heck of a lot easier than redoing the upgrade during the rare times this might happen.

No comments: