OpenWRT for an old Linksys WRT160Nv2

Background

Back in 2009 I purchased a Linksys WRT160Nv2 wireless router for my home. I did not do much homework at the time because I was busy with a new job, a baby, and just wanted to get wireless connectivity at home. I stopped using the device when I moved again in 2012 as Verizon provides me a router device to connect to their FIOS service.

For my home “lab”, if you can even call it that, I am looking to hook up some old devices and machines.  At first I was pricing out some small home router/switch combos, but in digging through a box of old equipment, I found the WRT160Nv2, and thought I might be able to repurpose it with OpenWRT, DD-WRT or some other open-source software on the device.

After some initial research, it turns out this router/switch device is a bit of kludge. The WRT160Nv1 and WRT160Nv3 of this series of device had decent hardware, but for WRT160Nv2 it looks like Linksys tried to cut costs by using Ralink chipset and not putting enough memory in the device. As such, both OpenWRT and DD-WRT do not support the hardware. Furthermore, the vendor abandoned the platform and the factory firmware has known vulnerabilities and bugs.

In searching the OpenWRT forums, I uncovered a topic leading to a project on GitHub called OpenWrt Leitec. It is a modified build of the OpenWRT software for Ralink RA2880 routers. The WRT160Nv2 has limited support for this build due to the fact the router only has 16 MB of memory.  I am going to give that a try because I don’t plan to use this device as a wireless router, but just as an Ethernet switch. Hopefully I can disable much of that functionality once I get OpenWRT installed on the device!

Building the OpenWRT Firmware

Note to self: Your stupid Windows computer went to sleep, and VMWare Desktop Pro couldn’t handle that and starting thrashing the disk.  It took the system 10 minutes to recover after wake-up. Turn off the PC sleep settings and just let the monitor go to sleep!

Building the firmware is rather straightforward.  I have a Windows 8.1 desktop computer with VMWare Desktop Pro. Within that I have a simple Linux VM that I used for building the firmware. Note that OpenWRT does not support Windows for building the firmware, one needs Linux, BSD, or Mac OS X.  The command sequence is as follows:

mkdir projects; cd projects
git clone https://github.com/leitec/openwrt-leitec.git
cd openwrt-leiteic
make menuconfig

The make menuconfig build command brings up a console-based UI for customized the firmware build. One needs to select the RA288x target and subtargets in order to build for the Ralink chipset.

MakeMenuConfig

The graphic above shows the target/subtarget already selected, but one would select the Target System option and go into the Target system submenu, shown below.

Target

For the WRT160Nv2, which is based on the RT2880 chipset, select the Ralink RT288x option and return. From the main menu, then go into the Subtarget submenu.

Subtarget

Select the RT288x based boards options and return to the main menu. From the main menu, navigate to the “Exit” option at the bottom of the screen. This will bring up a save prompt as shown below:

SaveConfig

Save the configuration and you should be returned to the system shell.  From here, one can begin building the OpenWRT firmware.  Start the makefile!

make

The build process begins by compiling all of the tools necessary for the target chipset, such as m4, xz, autoconf, gdb, gcc, et cetera. These tools are needed for cross-compilation for the target platform; the default tools on most systems are for x86_64 based software and not the embedded chipset on the router devices.

Build Errors

I was able to successfull build all of the tools, but during the toolchain build for “toolchain/gcc/final” compile stage, I encoutered build errors. To get the error messages, re-run the build script with the “V=s” option.

make V=s 2>&1 > build_log.txt

There were a few warnings and notes thrown out, but the first error I encountered was as follows:

cnfs.gperf:101:1: error: 'gnu_inline' attribute present on 'libc_name_p'
cnfs.gperf:26:14: error: but not here

A bit of google searching turned up a simple patch one can make to the source code. After modifying the code with that patch, the build process moved along happily. At the end of the build process, in the bin/ramips directory are all of the firmware images.

image_files

 

The firmware file to be flashed to the device is openwrt-ramips-rt288x-wrt160nv2-squashfs-factory-code.bin.

Firmware Installation

I had not powered on this device for over three years, and after navigating to the admin website (192.168.1.1) after plugging it into my Ethernet port, I released I had forgotten the admin password for the router.  Luckily, Linksys makes it easy to reset the router to a default factory configuration.

 

 

WRT_factory_reset

It should be noted that after flashing the firmware from the proprietary Linksys firmware to the OpenWRT firmware, this option will no longer be available.  However, OpenWRT has options for recovery and re-programming with the original factory firmware. In the factory setting, there is no username for the Linksys router webpage, and the password is ‘admin’.

I followed the directions to upgrading firmware from the Linksys website, which essentially tells one to navigate to the Linksys router’s webpage, login, and then navigate to the Administration tab. In the Administration section, select the Firmware Upgrade sub-tab. The resulting webpage is easy to navigate–simply select the OpenWRT .bin firmware image from the build press, and then press the Start Upgrade button.

During my install, the progress bar went to 50%, and then jumped to a page stating that the firmware was successfully written to the device. I was apprehensive at first because I thought there must have been an error, why would it jump to complete at only 50%? Then again, progress bars hugely unreliable indicators of progress with software tasks…

I open up Tera Term and processed to connect to the device at 192.168.1.1 using the telnet protocol…

WRT_Telnet

Success! OpenWRT was installed and is running on the router! To enable ssh, simply setup a root password by running the ‘passwd’ command. After setting a password and logging out, the router is now accessible with ssh and the telnet daemon is disabled. Next I fired up Putty, my preferred Windows SSH client…

WRT_ssh

Success!!! The router is now ready for configuration of capabilities.  It is a good idea to review the limitations of the WRT160Nv2 once more as the limited memory on the router prohibits it from running the web GUI interface as well as software such as OpenVPN.

It is my intention to use this device as a wired router device for now. Perhaps in future I will also look at enabling the 802.11 features too.

Conclusion

My take away from this little project is as follows:

  1. Always do your homework before purchasing technology, I knew better than just buying something from the store, but I was lazy and just bought the medium grade device from the local store. Now today I have a device that is so crippled that it is hardly supported by open source software.
  2. Open source software is perfect for re-purposing old hardware and giving it new life after the manufacturer has long abandoned the product.
  3. Or just make sure you have a lot of money for your technology! I would love to put a Juniper EX2200 in my lab instead, but I don’t have that type of cash to burn on a hobby lab.
Advertisements

12 thoughts on “OpenWRT for an old Linksys WRT160Nv2

  1. Thanks! got it working on my wrt160nv2 too. This and the other posts were very helpful. I wasn’t able to compile it on a recently setup Debian 8 VM, but using the file name you provided here I found a working mirror to download it 😛
    Do you think it’s possible to disable some services like syslogd/ntpd to free some ram or that’d be a bad idea?

    • Congrats! I am sure you can disable some services to save memory, but it will take some research to know which ones to disable and how to reconfigure. I disabled wireless on mine and am just using it as an Ethernet switch between a freebsd box and a windows box. If I figure out anything though I will post here.

    • Very sorry to hear that! I hope there is a way to recover it. Any response with a direct Ethernet cable? I didn’t mention it above, but I used direct Ethernet cable to flash the new firmware, I should add some language about that to the post.

      • I tried telnet and http, with ethernet cable, no dice. Not your fault, I thought I’d post a comment to help someone else from not doing the same thing! (Happened to have an extra router so it could’ve been worse)

  2. I was able to get the firmware flashed and I am able to ssh in but I cannot access it through the web ui how am I to go about configuring?

    • If you just want to get it setup check out some of my other posts on this router on my blog here. Instructions are presented for connecting to the Internet and setting up an AP. Other option is to go to the openwrt wiki. You will have to use the command line to config the router regardless though.

      As explained at the Leica github page, unfortunately this router has so little memory that it cannot run the web UI. After you ssh in try running the top command: you wilk see there is hardly any memory left even without running the wireless AP!

  3. First of all thanks for writing this easy to read post. While fiddling with my old router trying to give it a new life I ran into an issue when building openwrt-leilec.

    When building I get an error: ‘gnu_inline’ attribute present on ‘libc_name_p’.

    After doing some research I see that this might have something to do with the compiler version as seen here https://lists.openwrt.org/pipermail/openwrt-devel/2015-July/034271.html

    This made me wonder what Linux/gcc version have you used to build?

    I’m using a VM running Ubuntu 16.04 LTS

    The command ‘gcc –version’ outputs: gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160431

    cheers!

    • If you read in my post, I ran into that same issue when I was building with Ubuntu 15 and its system gcc compiler. I had to make some source code modifications based on the patch (diff output) that I linked to in the post. It was just four lines of code though, so not too bad. After making the fixes, I was then able to compile with no issues and build the binary images.

      I am happy to say that today I am using that router for a small private network for embedded systems development. I have my workstation hooked up so it can access two or three different hardware development kits. OpenWRT is great and it is worth the hassle to try to get the device working with OpenWRT Leitec.

  4. This worked out pretty great for me, except towards the end of the build (after applying the patch you mentioned) I got some error output regarding a recipe for timeconst.h or something.

    I first attempted to fix this by removing the defined() calls in kernel/timeconst.pl, but it appeared that it was being rebuilt after any subsequent attempts with make. I solved this by changing the file attributes on kernel/timeconst.pl to immutable.

    The following worked for me, but your mileage may vary (assuming you’re still in the ‘openwrt-leiteic’ directory):

    There are three defined() calls in the file build_dir/linux-ramips_rt288x/linux-3.3.8/kernel/timeconst.pl

    Remove the “defined(” and the “)” after the argument IN ALL CASES.
    Example:
    change
    if (defined(@val))
    to
    if (@val)

    Then run

    chattr +i build_dir/linux-ramips_rt288x/linux-3.3.8/kernel/timeconst.pl

    to set the file immutable and attempt to build again.

    Thanks for the great write up. Now this old paperweight might finally get some good use.

    • Glad to hear you got it working. I am using mine as a non public facing switch these days, it is working great!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s