Reflashing a WRT54GL

I have been happily running a Linksys WRT54GL router with an open source firmware on my home network for the past few years. Last weekend I tried to get an OpenVPN client installed to connect my network with another. No problem I thought – all it should take is to install the package using the OpenWRT package manager:

opkg install openvpn

However, this failed, as the newly installed packages took up too much space on the router. Even after removing all but the essential packages, this continued to be the case – understandably so, as for example the required OpenSSL package required by OpenVPN is almost 1 MB in size, and the router only has 4 MB of total space.

After reading up on the issue, I found a number of people suggesting to either compile my own OpenWRT image, or to use their package builder which does the job of creating a custom image for you. While I was able to create images that way, ultimately I was never able to reduce the size without sacrificing too much functionality. Much to my enjoyment, the last build I installed on the router also ended up bricking it, so that I was unable to SSH into it any longer. Happy days are here…

Looking for alternatives, I decided to give dd-wrt a chance, but first I had to find a way to restore the router’s original firmware. Now, as long as you’re able to log into the router, it possible to do so by overriding the image file. First, download the image:


Next, fix the file by removing a part of the header:

dd bs=32 skip=1 if=FW_WRT54GL_4.30.15.002_US_20101208_code.bin of=original.trx
> 105119+0 records in
> 105119+0 records out
> 3363808 bytes (3.4 MB) copied, 0.56599 s, 5.9 MB/s

And finally, override the router’s flash memory with the new image:

mtd -e linux -r write original.trx linux
> Unlocking linux ...
> Erasing linux ...
> Writing from original.trx to linux ...
> Rebooting ...

Obviously, that didn’t work in my case, so I had to find another way to restore the image.

Another way to unbrick the WRT54 is to upload a new image using TFTP. This can be done during a narrow window of time just after the router has been restarted. From Windows, the easiest way is to open up 2 command line windows. Then, run a continuous ping in one of them to the router’s default IP address:

ping -w 10 -t

In the other window, type the following command, but do not hit “Enter” yet (where <image.bin> is the new image file you want to upload).

tftp -i PUT <image.bin>

Start the router, and keep an eye on the ping. Once it starts to get a response, hit enter in the other window. If you see a message that the transaction was successful, there’s a good chance that the new image was installed. Wait for the router to settle (i.e., for the power light to stop blinking), and reboot it.

Once the router was running with the original image again, I could log into the web interface to upload dd-wrt. I needed to first install a small image, and then later upgrade to the OpenVPN image. Both of these can be found after searching in the Router Database. Quite a lot of work just to get a VPN connection going, but oh well…

Leave a Reply

Your email address will not be published.