Pimp your TL-MR3020 mobile router

The One-Watt Server

Article from Issue 152/2013
Author(s):

Many devices now run Linux – but mostly as a closed source firmware that you cannot access. We show how to use OpenWrt to free the TL-MR3020 router from its proprietary firmware and convert it into an all-around server for your home network.

TP-Link [1] manufactures routers in various performance classes. The TL-MR3020 (Figure 1) is marketed by the manufacturer as a mobile router because it is small and light. However, it does not support 3G (see the "Hardware" box), although you can upgrade via the USB port. Thus, the router is aimed at people who do not need 3G or have a UMTS stick and therefore do not want to invest in an expensive mobile UMTS router. However, the "normal" use of the router is not the focus of this article; instead, I will describe how to convert it into a mini-server.

Hardware

The TL-MR3020 is a small, white plastic box (Figure 1) measuring 7.4 x 6.7 x 2.2 centimeters and weighing only 60 grams. A mini-USB connector is used for the power supply, and the AC adapter provided supplies 1 watt. Moreover, the router will also work without any problems on a USB port. Additionally, the TL-MR3020 includes a USB 2.0 port and an RJ45 Ethernet port (100Mbps). TP-Link provides a short, flat patch cable for the latter. On the wireless side, the small router supports IEEE 802.11b/g/n at up to 150Mbps.

The TL-MR3020 uses five LEDs to indicate its status, four of which can be programmed. There is also a button for the wireless setup via WPS and a slide switch with three positions (3G/WISP/AP). Inside, the router has a 400MHz ARM CPU and 32MB RAM. The operating system resides on a 4MB flash chip. The USB port is used with the original firmware to connect a UMTS stick for operation as a mobile 3G router. Without a stick, the device acts as a wireless access point.

As a useful addition to the TL-MR3020, I would recommend a mini-USB hub by Pearl (Figure 1). This device integrates a micro-SDHC reader and thus provides the advanced root filesystem described in this article on a memory card without blocking the USB port.

The router board contains additional ports, but TP-Link does not route them out. If you can use a soldering iron, you could attach other components, such as a serial console, an I2C interface, or an external antenna. The OpenWrt wiki shows some pictures and links to relevant instructions on its TL-MR3020 pages [3].

Figure 1: The TL-MR3020 TP-Link (left) is no larger than the palm of your hand. The mini-USB hub by Pearl (right) acts as an expander.

To do this, you'll replace the existing firmware with OpenWrt [2], a special Linux distribution for microdevices. OpenWrt has a package management system that is in no way inferior to that of classical distributions; thus, only the limitations of the hardware can curb your creativity.

Prelude

The TL-MR3020 is well-suited to this purpose for two reasons: On one hand, it costs EUR 30 (US$ 40) – which is not too much, if you happen to "brick" the device. On the other hand, the manufacturer does not put any obstacles in the way of installing third-party firmware.

To begin, download the correct version of OpenWrt [3] and follow the brief, but perfectly sufficient, instructions that come with the router to connect to the device's web interface. When you get there, upload the new firmware to the TL-MR3020 by selecting Upgrade in the new web form (Figure 2).

Figure 2: OpenWrt is uploaded as a firmware update via the original web interface on the TL-MR3020.

Uploading the firmware is the only really critical step in the whole process. A defective firmware image will send the router off to the happy hunting grounds  – your only chance is a soldering iron. Thus, before loading the image, it is essential to check out the postings on the OpenWrt wiki [3] and follow the appropriate instructions.

After installing OpenWrt, the next step is the basic configuration, particularly for the network. Then, you need to set up a number of software packages that upgrade USB support for data media (USB sticks or hard disks). This step lets you boot the router from an external disk. On the now-extended root filesystem, you then add more software packages from the OpenWrt repository for the actual application.

First Contact

After the firmware upgrade and device reboot, you can connect your PC or laptop to the router with the use of a cable. Configure the network (you can normally use the network manager for this) and login via Telnet on 192.168.1.1 (Figure 3). The router runs a DHCP server that supplies a suitable address to your PC or laptop.

Figure 3: Done: The first login on OpenWrt.

At this point, you should set a password for root. OpenWrt then switches off the Telnet server for safety reasons and starts the SSH server. Next, adjust the network configuration so that the router is on your home network; then, you can move on and add more software. For details of the OpenWrt configuration system, see the "Configuring OpenWrt" box.

Configuring OpenWrt

The OpenWrt configuration system remains very consistent across all system-related packages. All configuration files are located in /etc/config and are simply structured plaintext files that are most easily changed in an editor.

For production operation of the router later on, the web interface is the preferred alternative to the editor: Here, you can conveniently modify individual configuration parameters and query the system state (Figure 4). Another alternative is an interface for the command line. The command

$ uci get system.slider.handler

reads the value of the handler option in the slider section of the /etc/config/system file. For scripts, the /lib/functions.sh library offers a few utilities that significantly facilitate the handling of settings.

Figure 4: Using the web interface on OpenWrt to retrieve the system state.

To use the router as a server on your home network, the network configuration should look like Listing 1 (/etc/config/network) and Listing 2 (/etc/config/wireless). Lines 9-15 in Listing 1 configure the WLAN interface. In Listing 2, line 19 ensures that the server is integrated into the network as a WLAN client rather than as an access point or router.

Listing 1

/etc/config/network

 

Listing 2

/etc/config/wireless

 

After a reboot, the device should be found at the configured network address. If not, emergency mode can help: During the boot process, press the WPS button once it starts flashing. If the LED light flashes quickly, then release it again. Now the device is in Failsafe mode with the default address 192.168.1.1 and running the Telnet daemon. You can connect to Telnet and make the necessary corrections. However, no DHCP server is available on the router in this mode. You must assign a matching IP address to your own computer manually.

More Software

The original firmware image does not contain all the components that are necessary for running the root filesystem on a USB stick, so you will need to add them now. After successfully completing the network configuration, the mini-router can access the Internet and use the convenient package management system to install additional software retroactively.

The pivotal point is the opkg command, which you need to run as root. To do so, first call opkg update to upgrade the package list. Then, install the specified packages using the following command:

# opkg install <package>

If you are looking for a particular package, the list subcommand outputs a package list with brief descriptions. For the USB installation, you primarily need a set of kernel packages (Listing 3). It's best to partition and format the USB stick (/dev/sdb in the listing – you might need to adjust this) on your PC. Besides the root partition, you'll want a home partition and, above all, swap space.

Listing 3

Preparing the USB Stick

 

Then, you can simply plug the stick into the router and change the configuration of the mountpoints in the /etc/config/fstab file. Lines 10-16 in Listing 4 are important. The last line of Listing 3 copies the entire root filesystem to the stick. Creating a backup now is advisable. The system will still boot, even without the stick inserted: In this case, it simply ignores the nonexisting devices.

Listing 4

Configuring Mountpoints

 

After a reboot with a stick attached, you finally have more disk space. Any packages you now add can be stored there. All told, having the root filesystem on a USB device is handy. You can modify the configuration with the usual editors on a PC and easily copy data between locations (e.g., for backups).

At this point, the basic configuration is complete except for a few things, such as the hostname. The remainder of the procedure depends on how you will be using the router, and you can use the package manager to retrieve and configure the required software. The procedure on OpenWrt is no different from that of any other distribution.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Tuning WLAN Routers

    Learn how to take control of your home routing device with OpenWrt.

  • Repurposed Router Projects

    If you have an old router lying around, you can put it to good use with a few easy projects and learn something along the way.

  • Free Software Projects

    OpenWRT puts Linux on WLAN routers and helps users set up large-scale WLANs at home, and the FreeWRT derivative adds a professional touch. If you don’t have your own compile farm, the OpenSUSE build service may be just what you need. And we investigate the obstacles to new packages for Debian.

  • SSH Reverse Tunnels

    We’ll show you a practical project for monitoring home energy usage with SSH and OpenWrt.

  • Security Lessons: Linux WAP

    If you are looking for a cheap and secure wireless router setup, check out Tomato, DD-WRT, or OpenWrt.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News