Page 1 of 1

Flashing a Router to its OEM Stock Firmware

Posted: Sat Apr 28, 2018 12:47 pm
by JimHelms
This tutorial will demonstrate one method to flash the OEM (stock) firmware onto a router that currently is using custom firmware (i.e., GoldenOrb, LEDE, OpenWRT). Like all the tutorials, use this method at your own risk!

For this example, we will restore the Linksys WRT1900ACS to its OEM firmware. We will also be using a Windows machine but the method is equally applicable to a Linux machine.

This particular method depends on several variables:
  • That you have internet service to the router, and
  • That you can locate the download "link" to the router's stock OEM firmware, and
  • That the OEM firmware image is not a zipped/compressed (i.e., must be an image file ready to upload and flash)
This method also requires command line access into the router. This will be accomplished by downloading and using PuTTy.

LOCATING THE DOWNLOAD LINK TO THE OEM FIRMWARE:

The first task is to locate the "actual" download link to the OEM firmware. This is the link that when clicked on, will begin downloading the OEM firmware image. Test that the link will actually start downloading the image as opposed to taking you to another webpage where a different link must be clicked on to start the download.

In this example, we will located the Linksys firmware download for the WRT1900ACS version 2 (which is the router we are working with).

In the image below, if I were to click on the "Download" link, the firmware will start downloading. Perfect. I will now copy the the actual http://..... link by right clicking the Download link and select Copy Link Location

Linksys - Copy Link.png

PREPARING OUR RESTORE COMMANDS:

To make this an easy process, we will save the actual link just copied to a text document. This is allow us to prepare all the commands necessary to execute the firmware installation.

The actual link that was copied above is shown below.

Code: Select all

http://downloads.linksys.com/downloads/firmware/FW_WRT1900ACSV2_2.0.1.186724_prod.img

The first commmand we will use will fetch and download the OEM image to a temp file location on the router. The command and format will be:

Code: Select all

cd /tmp ; opkg update ; opkg install wget ; wget DOWNLOAD_LINK_LOCATION

whereas, we will substitute DOWNLOAD_LINK_LOCATION with the "actual" download link:

Code: Select all

 cd /tmp ; opkg update ; opkg install wget ; wget http://downloads.linksys.com/downloads/firmware/FW_WRT1900ACSV2_2.0.1.186724_prod.img
The second command will upgrade/install the OEM firmware, and will use the format:

Code: Select all

sysupgrade -F -n -v NAME_OF_FIRMWARE_IMAGE
whereas, we will substitute NAME_OF_FIRMWARE_IMAGE with the name of the actual firmware image. In this example, the firmware is named:

Code: Select all

FW_WRT1900ACSV2_2.0.1.186724_prod.img
So our second upgrade command will be:

Code: Select all

sysupgrade -F -n -v FW_WRT1900ACSV2_2.0.1.186724_prod.img
The two commands in our text document that we now have constructed are:

Code: Select all

cd /tmp ; opkg update ; opkg install wget ; wget http://downloads.linksys.com/downloads/firmware/FW_WRT1900ACSV2_2.0.1.186724_prod.img

sysupgrade -F -n -v FW_WRT1900ACSV2_2.0.1.186724_prod.img

USING PUTTY TO ACCESS THE ROUTER

Now that we have our line commands, we will access the router using PuTTy. We will start PuTTy by clicking on the putty.exe which will bring up the login window.

In the Session category, we will enter:
  • The IP address of the router (in our case, as with most, 192.168.1.1)
  • The Port number 22
  • Select SSH as the type
  • Click on the Open button
Putty IP.png

After the connection is opened, a Security Alert Warning may pop up. If so, proceed by clicking the YES button:

Putty warning.png

The shell login widow will now appear asking for your login name and password that you currently use to access your router In most cases, unless you have changed it at some point, the login name will be "root". Enter the name and password, pressing enter after each:

Putty Password.png

After our login is accepted, we will now enter our fist command to fetch the OEM firmware:

Putty Get Firmware.png

You can watch the screen until it notes the firmware image download is 100%:

Putty Download Firmware.png

We will now enter the second command to upgrade (install) the firmware image:

Putty Upgrade Image.png

You may get a warning about checking the image, but will force the upgrade nonetheless. This is common and there may be situations that require us to actually force the upgrade via command.

Watch for Upgrade Completed and click on the X to close out PuTTY while the router is rebooting:

Putty Upgrade Completed.png

When the router completes rebooting, you should now be able to access the router using the OEM stock router's login user name and password.

Done.png

DONE!

In the second part of this tutorial, I will demonstrate how to flash the firmware WITHOUT internet service.

Re: Flashing a Router to its OEM Stock Firmware

Posted: Sat Apr 28, 2018 2:33 pm
by JimHelms
There are times, for whatever reason, our router with custom firmware, has NO internet access. This requires a similar approach.

Rather than having the router fetch the download image, we will download the OEM firmware image by other means, and place it in the temp folder.

For now, download the image and place on your PC's desktop or other location where you have easy access to the image. For this example, we will be working with the same WRT1900ACS OEM firmware image which I have placed on my desktop.

NOTE: This method may also be helpful for reinstalling an image or downgrading to a different kernel image.

In order to use this method, we will require access to the router's firmware files. To gain this access, we will download and use WinSCP.

Open a WinSCP session, and enter the following session information, and click the Login button:

Code: Select all

File protocol: SCP
Host name: 192.168.1.1
Port Number: 22
User Name: root
Password: (whatever password you use to log into router)
WinSCP Login.png


Once again, we may see a warning about host keys not matching, which can be Upgraded:


WinSCP Warning.png


You should now see split window viewer on the WinSCP. The left window screen shows your computer while the right side shows the router's firmware files.

You will notice the left screen is pointed to my Desktop where the FW_WTR1900ACS firmware image is located.
The right screen is pointed to the router's /root folder . Notice the temp folder.


WinSCP file structure.png


On the right side screen, select the temp folder. On the left window, click on the Firmware, then select Upload from the Upload pull down box:


WinSCP Select upload.png


WinSCP will now ask to confirm the action (i.e., uploading the Firmware file into the temp directory) by clicking OK:


WinSCP Confirm upload.png


Once the firmware has completed its uploading, you should now be able to see the image in the temp folder.
You may then terminate (exit) the WinSCP session:


WinSCP Image uploaded.png


Now, we will again use PuTTy to upgrade the firmware by following the basic login and logic in the first part of this tutorial.

The two commands and format we will use this go around are:

Code: Select all

cd /tmp
which points us to the temp folder, and:

Code: Select all

sysupgrade -n -F NAME_OF_FIRMWARE_IMAGE
which commands the system upgrade.

Again, we substitute the NAME_OF_FIRMWARE_IMAGE for the actual name of our firmware.

In this example, our upgrade commands, entered one at a time, will be:

Code: Select all

cd /tmp

Code: Select all

sysupgrade -n -F FW_WRT1900ACSV2_2.0.1.186724_prod.img

In Part one of this tutorial, I mentioned there are occasions we must force the upgrade via commands.

If it refuses to do the upgrade, for whatever reason, and we are reasonably certain the new firmware is the correct firmware and/or is compatible with our router, we can force the upgrade using the following commands:

Code: Select all

cd /tmp

Code: Select all

sysupgrade -F -n -v FW_WRT1900ACSV2_2.0.1.186724_prod.img

Hopefully, when completed, you have now upgraded the router to the firmware you selected.